| | library(tidyverse) |
| | library(here) |
| | library(httr) |
| | library(arrow) |
| | library(readxl) |
| |
|
| | |
| | |
| | gene_table = arrow::open_dataset(here("data/genome_files/hf/features")) %>% |
| | as_tibble() |
| |
|
| | |
| | |
| | |
| | |
| | |
| |
|
| | |
| | |
| | |
| |
|
| | add_datatype_to_colnames = function(df, skip_indicies){ |
| | |
| | suffixes <- c("_M", "_A", "_pval") |
| |
|
| | |
| | repeated_suffixes <- rep(suffixes, length.out = length(colnames(df)[-skip_indicies])) |
| |
|
| | |
| | modified_vector <- paste0(colnames(df)[-skip_indicies], repeated_suffixes) |
| |
|
| | colnames(df)[-skip_indicies] = modified_vector |
| |
|
| | |
| | |
| | |
| | df[-1,] |
| | } |
| |
|
| | get_clean_headers = function(path, skip_indicies = 1:3) { |
| | headers <- read_tsv(path, n_max = 1, name_repair = "minimal") %>% |
| | add_datatype_to_colnames(skip_indicies = skip_indicies) %>% |
| | colnames() |
| |
|
| | |
| | headers <- str_replace(headers, " vs\\.? ", ";") |
| |
|
| | |
| | empties <- which(is.na(headers) | headers == "") |
| | if (length(empties) > 0) { |
| | headers[empties] <- paste0("X", seq_along(empties)) |
| | } |
| |
|
| | headers |
| | } |
| |
|
| | read_in_kemmeren_data = function(path, ...){ |
| | read.delim(path, |
| | sep='\t', |
| | skip=2, |
| | check.names=FALSE, |
| | col.names=get_clean_headers(path, ...)) %>% |
| | as_tibble() |
| | } |
| |
|
| | stopifnot(identical(get_clean_headers(here('data/kemmeren/deleteome_all_mutants_ex_wt_var_controls.txt.xz')), |
| | get_clean_headers(here('data/kemmeren/deleteome_all_mutants_controls.txt.xz')))) |
| |
|
| | deleteome_all_mutants_controls = |
| | read_in_kemmeren_data(here('data/kemmeren/deleteome_all_mutants_controls.txt.xz')) |
| |
|
| | deleteome_ex_wt_var_controls = |
| | read_in_kemmeren_data(here('data/kemmeren/deleteome_all_mutants_ex_wt_var_controls.txt.xz')) |
| |
|
| | by_hand_locustag_map = tibble( |
| | systematicName = c('YAR062W', 'YDL038C', 'snR10', 'YGR272C', 'YIL080W', 'YIL168W', 'YIR044C'), |
| | locus_tag = c('YAR061W', 'YDL039C', 'YNCG0013W', 'YGR271C-A', 'YIL082W-A', 'YIL167W', 'YIR043C')) %>% |
| | deframe() |
| |
|
| | by_hand_symbol_map = gene_table %>% |
| | filter(locus_tag %in% by_hand_locustag_map) %>% |
| | select(locus_tag, symbol) %>% |
| | deframe() |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | target_df = deleteome_all_mutants_controls %>% |
| | select(reporterId, systematicName, geneSymbol) %>% |
| | distinct() %>% |
| | left_join(select(gene_table, locus_tag, symbol) %>% |
| | mutate(systematicName = locus_tag)) %>% |
| | mutate(locus_tag = ifelse(is.na(locus_tag), by_hand_locustag_map[systematicName], locus_tag)) %>% |
| | mutate(symbol = ifelse(is.na(symbol), by_hand_symbol_map[locus_tag], symbol)) %>% |
| | group_by(locus_tag) %>% |
| | mutate(multiple_probes = n()>1) %>% |
| | ungroup() %>% |
| | mutate(variable_in_wt = reporterId %in% |
| | setdiff(deleteome_all_mutants_controls$reporterId, |
| | deleteome_ex_wt_var_controls$reporterId)) %>% |
| | dplyr::rename(target_locus_tag = locus_tag, |
| | target_symbol = symbol) |
| |
|
| | rm(deleteome_ex_wt_var_controls) |
| | gc() |
| |
|
| | deleteome_all_mutants_controls_long = deleteome_all_mutants_controls %>% |
| | pivot_longer(-c(reporterId, systematicName, geneSymbol), |
| | names_to='sample_metric', values_to='values') %>% |
| | separate(sample_metric, c('sample', 'metric'), sep="_") %>% |
| | pivot_wider(names_from='metric', values_from='values') %>% |
| | separate_wider_delim(cols=sample, |
| | names=c('kemmeren_regulator', 'control'), |
| | delim=";") %>% |
| | mutate(kemmeren_regulator = toupper(str_remove(tolower(kemmeren_regulator), "-del-1$|-del-mata$|-del$"))) %>% |
| | mutate(kemmeren_regulator = ifelse(kemmeren_regulator == "ARG5,6", "ARG56", kemmeren_regulator)) |
| |
|
| | kem_sup1_regulator_info = read_excel(here("data/kemmeren/supplemental_table1_strain_info.xlsx")) %>% |
| | mutate(`profile first published` = str_replace(`profile first published`, ", ", ",")) |
| | kem_sup1_regulator_info_straininfo = read_excel(here("data/kemmeren/supplemental_table1_strain_info_origins.xlsx")) |
| |
|
| | kem_sup1_regulator_info = kem_sup1_regulator_info %>% |
| | left_join(kem_sup1_regulator_info_straininfo) %>% |
| | mutate(`profile first published` = citation) %>% |
| | select(-citation) |
| |
|
| | parsed_regulators = deleteome_all_mutants_controls_long %>% |
| | select(kemmeren_regulator) %>% |
| | distinct() |
| |
|
| | regulators_munging_list = list() |
| |
|
| | regulators_munging_list$x1 = parsed_regulators %>% |
| | mutate(gene = kemmeren_regulator) %>% |
| | left_join(kem_sup1_regulator_info) %>% |
| | filter(complete.cases(.)) |
| |
|
| | regulators_munging_list$x2 = parsed_regulators %>% |
| | filter(!kemmeren_regulator %in% regulators_munging_list$x1$kemmeren_regulator) %>% |
| | mutate(`orf name` = kemmeren_regulator) %>% |
| | left_join(kem_sup1_regulator_info) %>% |
| | filter(complete.cases(.)) |
| |
|
| | stopifnot(length(intersect(regulators_munging_list$x1$kemmeren_regulator, regulators_munging_list$x2)) == 0) |
| |
|
| | regulators_munging_list$x3 = read_csv(here("data/kemmeren/supplement_failure_regulator_mapping.csv.gz")) |
| |
|
| | stopifnot(length(intersect(regulators_munging_list$x2$kemmeren_regulator, regulators_munging_list$x3$kemmeren_regulator)) == 0) |
| |
|
| | regulators_munging_df = bind_rows(regulators_munging_list) %>% |
| | |
| | mutate(`orf name` = case_when( |
| | `orf name` == "TLC1" ~ "YNCB0010W", |
| | `orf name` == "CMS1" ~ "YLR003C", |
| | .default = `orf name` |
| | )) %>% |
| | filter(kemmeren_regulator != "LUG1") %>% |
| | bind_rows(tibble( |
| | kemmeren_regulator = "LUG1", |
| | gene = "YCR087C-A", |
| | `orf name` = "YCR087C-A", |
| | description = paste0("Protein of unknown function; binds zinc; phosphomutants ", |
| | "exhibit phenotypes, suggesting functionality of phosphosites; green ", |
| | "fluorescent protein (GFP)-fusion protein localizes to the nucleolus; ", |
| | "YCR087C-A is not an essential gene"), |
| | `functional category` = "unknown", |
| | `slide(s)` = "THM_00005835_S01 / THM_00005836_S01", |
| | `mating type` = "MATalpha", |
| | `source of deletion mutant(s)` = "Open Biosystems / Open Biosystems", |
| | `primary Hybset(s)` = "THM006 / THM006", |
| | `responsive/non-responsive` = "responsive mutant", |
| | chase_notes = paste0("This was originally called LUG1. However, that name ", |
| | "for this locus was removed in 2012 per SGD. The expression confirms ", |
| | "that the KO locus is YCR087C-A, not YLR352W, which is the locus ", |
| | "currently called LUG1 in 2025"))) %>% |
| | left_join( |
| | select(gene_table, locus_tag, symbol) %>% |
| | mutate(`orf name` = locus_tag) %>% |
| | dplyr::rename(regulator_locus_tag = locus_tag, |
| | regulator_symbol = symbol)) %>% |
| | replace_na(list(chase_notes = "none")) %>% |
| | mutate(regulator_locus_tag = ifelse(str_detect(kemmeren_regulator, "^WT-"), kemmeren_regulator, regulator_locus_tag), |
| | regulator_symbol = ifelse(str_detect(kemmeren_regulator, "^WT-"), kemmeren_regulator, regulator_symbol)) %>% |
| | janitor::clean_names() |
| |
|
| |
|
| | stopifnot(setequal(regulators_munging_df$kemmeren_regulator, |
| | unique(deleteome_all_mutants_controls_long$kemmeren_regulator))) |
| |
|
| | deleteome_all_mutants_svd_transforms = |
| | read_tsv(here("data/kemmeren/deleteome_all_mutants_svd_transformed.txt.xz"), |
| | name_repair = "minimal") |
| |
|
| | colnames(deleteome_all_mutants_svd_transforms)[1] = "systematicName" |
| |
|
| | colnames(deleteome_all_mutants_svd_transforms) = |
| | str_replace(colnames(deleteome_all_mutants_svd_transforms), "mf.alpha.1", "mf(alpha)1") |
| | colnames(deleteome_all_mutants_svd_transforms) = |
| | str_replace(colnames(deleteome_all_mutants_svd_transforms), "mf.alpha.2", "mf(alpha)2") |
| | colnames(deleteome_all_mutants_svd_transforms) = |
| | str_replace(colnames(deleteome_all_mutants_svd_transforms), "arg5.6", "arg56") |
| |
|
| | deleteome_all_mutants_svd_transforms_long = deleteome_all_mutants_svd_transforms %>% |
| | dplyr::rename(geneSymbol = commonName) %>% |
| | pivot_longer(-c(systematicName, geneSymbol), |
| | names_to = "condition", |
| | values_to = "Madj") %>% |
| | separate_wider_delim(condition, |
| | names = c("kemmeren_regulator", "tmp"), |
| | delim = ".", |
| | too_many = "merge") %>% |
| | mutate(kemmeren_regulator = toupper(kemmeren_regulator)) %>% |
| | mutate( |
| | |
| | kemmeren_regulator = recode(kemmeren_regulator, |
| | "YIL014C" = "YIL014C-A", |
| | "YOL086W" = "YOL086W-A", |
| | "YDR034W" = "YDR034W-B", |
| | "YAL044W" = "YAL044W-A" |
| | ), |
| | |
| | systematicName = recode(systematicName, |
| | "ANR2" = "YKL047W", |
| | "CMS1" = "YLR003C" |
| | ) |
| | ) %>% |
| | |
| | filter(systematicName != "Q0010") |
| |
|
| | stopifnot(length(setdiff(deleteome_all_mutants_svd_transforms_long$kemmeren_regulator, |
| | regulators_munging_df$kemmeren_regulator)) == 0) |
| |
|
| | stopifnot(length(setdiff(deleteome_all_mutants_svd_transforms_long$systematicName, |
| | target_df$systematicName)) == 0) |
| |
|
| | final_parsed_list = list( |
| | all = deleteome_all_mutants_controls_long %>% |
| | select(reporterId, kemmeren_regulator, M, A, pval) %>% |
| | left_join(select(target_df, reporterId, target_locus_tag, |
| | target_symbol, multiple_probes, variable_in_wt)), |
| |
|
| | slow_growth = deleteome_all_mutants_svd_transforms_long %>% |
| | select(kemmeren_regulator, systematicName, Madj) %>% |
| | |
| | left_join(distinct(select(target_df, systematicName, target_locus_tag, target_symbol))) %>% |
| | select(-systematicName) |
| | ) |
| |
|
| | final_parsed_df = Reduce(left_join, final_parsed_list) %>% |
| | group_by(kemmeren_regulator) %>% |
| | |
| | |
| | |
| | distinct(reporterId, .keep_all = TRUE) %>% |
| | ungroup() %>% |
| | left_join(select(regulators_munging_df, |
| | -c(gene, `orf_name`))) %>% |
| | dplyr::rename(nr_sign_changes = nr_sign_changes_p_0_05_fc_1_7, |
| | primary_hybsets = primary_hybset_s, |
| | source_of_deletion_mutants = source_of_deletion_mutant_s, |
| | slides = slide_s, |
| | regulator_desc = description) %>% |
| | arrange(regulator_locus_tag) |
| | |
| | |
| | |
| |
|
| | db_kemmeren_meta = read_csv("data/kemmeren/db_kemmeren_meta_20251126.csv") %>% |
| | mutate(id = ifelse(regulator_locus_tag == 'YLR352W', 0, id)) %>% |
| | select(id, regulator_locus_tag) %>% |
| | distinct() %>% |
| | mutate(id = as.integer(id)) %>% |
| | dplyr::rename(db_id = id) |
| |
|
| | final_df_parsed_with_ids = final_parsed_df %>% |
| | left_join(db_kemmeren_meta) %>% |
| | replace_na(list(db_id = 0)) %>% |
| | arrange(regulator_locus_tag) %>% |
| | group_by(regulator_locus_tag) %>% |
| | mutate(sample_id = cur_group_id()) %>% |
| | relocate(sample_id, db_id, |
| | regulator_locus_tag, regulator_symbol, |
| | reporterId, target_locus_tag, target_symbol, |
| | M, Madj, A, pval, |
| | variable_in_wt, multiple_probes) |
| |
|
| | |
| | |
| | |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|