|
|
|
|
|
|
|
|
library(tidyverse) |
|
|
library(here) |
|
|
library(arrow) |
|
|
|
|
|
|
|
|
|
|
|
gene_table = arrow::open_dataset(here("data/genome_files/hf/features")) %>% |
|
|
as_tibble() |
|
|
|
|
|
|
|
|
df = read_tsv(here("data/mcisaac/idea_tall_expression_data/idea_tall_expression_data.tsv")) %>% |
|
|
|
|
|
mutate(GeneName = str_remove(GeneName,',')) %>% |
|
|
mutate(GeneName = str_remove(GeneName, '\'')) |
|
|
|
|
|
tf_table = df %>% |
|
|
select(TF) %>% |
|
|
distinct() %>% |
|
|
filter(TF != 'YLL054C') %>% |
|
|
left_join(gene_table, by = c('TF' = 'symbol')) %>% |
|
|
select(TF, locus_tag) %>% |
|
|
bind_rows(tibble(TF='YLL054C', locus_tag="YLL054C")) %>% |
|
|
dplyr::rename(regulator_locus_tag = locus_tag) %>% |
|
|
mutate(regulator_symbol = TF) %>% |
|
|
mutate(regulator_locus_tag = ifelse(TF %in% c("GEV", "Z3EV"), TF, regulator_locus_tag)) |
|
|
|
|
|
stopifnot(setequal(tf_table$TF, unique(df$TF))) |
|
|
|
|
|
mcisaac_gene_table_incomplete = df %>% |
|
|
select(GeneName) %>% |
|
|
distinct() %>% |
|
|
left_join(gene_table, by = c('GeneName' = 'symbol')) %>% |
|
|
filter(complete.cases(.)) %>% |
|
|
mutate(symbol = GeneName) %>% |
|
|
select(GeneName, locus_tag, symbol) %>% |
|
|
bind_rows(df %>% |
|
|
select(GeneName) %>% |
|
|
distinct() %>% |
|
|
left_join(gene_table, |
|
|
by = c('GeneName' = 'locus_tag')) %>% |
|
|
filter(complete.cases(.)) %>% |
|
|
mutate(locus_tag = GeneName) %>% |
|
|
select(GeneName, locus_tag, symbol)) %>% |
|
|
distinct() %>% |
|
|
dplyr::rename(target_locus_tag = locus_tag, target_symbol = symbol) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mcisaac_gene_aliases = read_csv("data/mcisaac/mcisaac_gene_lookup.txt") %>% |
|
|
|
|
|
|
|
|
bind_rows(tibble(GeneName="AAD16", locus_tag="YFL056C")) %>% |
|
|
dplyr::rename(target_locus_tag=locus_tag) %>% |
|
|
mutate(target_symbol=GeneName) |
|
|
|
|
|
|
|
|
mcisaac_gene_table = mcisaac_gene_table_incomplete %>% |
|
|
bind_rows(mcisaac_gene_aliases) |
|
|
|
|
|
stopifnot(setequal(mcisaac_gene_table$GeneName, unique(df$GeneName))) |
|
|
|
|
|
mcisaac_for_parquet = df %>% |
|
|
mutate(date=str_remove_all(as.Date(date, format='%m/%d/%Y'),'-')) %>% |
|
|
left_join(tf_table) %>% |
|
|
left_join(mcisaac_gene_table) |
|
|
|
|
|
mcisaac_tf_to_regulator_locus_tag = mcisaac_for_parquet %>% |
|
|
select(TF, regulator_locus_tag) %>% |
|
|
distinct() |
|
|
|
|
|
mcisaac_GeneName_to_target_locus_tag = mcisaac_for_parquet %>% |
|
|
select(GeneName, target_locus_tag) %>% |
|
|
distinct() |
|
|
|
|
|
mcisaac_for_parquet %>% |
|
|
select(regulator_locus_tag, regulator_symbol, target_locus_tag, target_symbol, |
|
|
time, mechanism, restriction, date, strain, |
|
|
ends_with("median"), starts_with("log2")) %>% |
|
|
write_parquet("~/code/hf/hackett_2020/hackett_2020.parquet", |
|
|
compression = "zstd", |
|
|
write_statistics = TRUE, |
|
|
use_dictionary = c( |
|
|
regulator_locus_tag = TRUE, |
|
|
regulator_symbol = TRUE, |
|
|
target_locus_tag = TRUE, |
|
|
target_symbol = TRUE, |
|
|
time = TRUE, |
|
|
mechanism = TRUE, |
|
|
restriction = TRUE, |
|
|
date = TRUE, |
|
|
strain = TRUE)) |
|
|
|