| |
|
|
| 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() |
|
|
| |
| |
| |
| |
| |
|
|
| db_mcisaac_data = read_csv("data/mcisaac/database_mcisaac_20251126.csv") %>% |
| select(id, regulator_locus_tag, mechanism, restriction, time, notes) %>% |
| mutate( |
| strain = trimws(str_extract(notes, "(?<=strain_id:)[^;]+")), |
| date = trimws(str_extract(notes, "(?<=date:)[^;]+")), |
| mechanism = toupper(mechanism)) %>% |
| select(-notes) %>% |
| dplyr::rename(db_id = id) %>% |
| bind_rows( |
| mcisaac_for_parquet %>% |
| filter(regulator_locus_tag %in% c("GEV", "Z3EV")) %>% |
| select(regulator_locus_tag, time, mechanism, |
| restriction, date, strain) %>% |
| distinct() %>% |
| mutate(db_id = 0)) %>% |
| arrange(db_id) %>% |
| mutate(sample_id = row_number()) |
|
|
| final_mcisaac = mcisaac_for_parquet %>% |
| left_join(db_mcisaac_data) %>% |
| select(sample_id, db_id, |
| regulator_locus_tag, regulator_symbol, |
| target_locus_tag, target_symbol, |
| time, mechanism, restriction, date, strain, |
| ends_with("median"), starts_with("log2")) |
|
|
| |
| |
| |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |