cmatkhan commited on
Commit
84b2161
·
verified ·
1 Parent(s): 56b3d55

Upload parse_mcisaac_data.R

Browse files
Files changed (1) hide show
  1. scripts/parse_mcisaac_data.R +93 -0
scripts/parse_mcisaac_data.R ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## NOTE: gene_table and genomicfeature_tbl are confirmed identical
2
+
3
+ library(tidyverse)
4
+ library(here)
5
+ library(arrow)
6
+
7
+ # genomic feature harmonization table ----
8
+ # see https://huggingface.co/datasets/BrentLab/yeast_genome_resources
9
+ gene_table = arrow::open_dataset(here("data/genome_files/hf/features")) %>%
10
+ as_tibble()
11
+
12
+ # see the README in the mcisaac data directory
13
+ df = read_tsv(here("data/mcisaac/idea_tall_expression_data/idea_tall_expression_data.tsv")) %>%
14
+ # filter(!TF %in% c("GEV","Z3EV")) %>%
15
+ mutate(GeneName = str_remove(GeneName,',')) %>%
16
+ mutate(GeneName = str_remove(GeneName, '\''))
17
+
18
+ tf_table = df %>%
19
+ select(TF) %>%
20
+ distinct() %>%
21
+ filter(TF != 'YLL054C') %>%
22
+ left_join(gene_table, by = c('TF' = 'symbol')) %>%
23
+ select(TF, locus_tag) %>%
24
+ bind_rows(tibble(TF='YLL054C', locus_tag="YLL054C")) %>%
25
+ dplyr::rename(regulator_locus_tag = locus_tag) %>%
26
+ mutate(regulator_symbol = TF) %>%
27
+ mutate(regulator_locus_tag = ifelse(TF %in% c("GEV", "Z3EV"), TF, regulator_locus_tag))
28
+
29
+ stopifnot(setequal(tf_table$TF, unique(df$TF)))
30
+
31
+ mcisaac_gene_table_incomplete = df %>%
32
+ select(GeneName) %>%
33
+ distinct() %>%
34
+ left_join(gene_table, by = c('GeneName' = 'symbol')) %>%
35
+ filter(complete.cases(.)) %>%
36
+ mutate(symbol = GeneName) %>%
37
+ select(GeneName, locus_tag, symbol) %>%
38
+ bind_rows(df %>%
39
+ select(GeneName) %>%
40
+ distinct() %>%
41
+ left_join(gene_table,
42
+ by = c('GeneName' = 'locus_tag')) %>%
43
+ filter(complete.cases(.)) %>%
44
+ mutate(locus_tag = GeneName) %>%
45
+ select(GeneName, locus_tag, symbol)) %>%
46
+ distinct() %>%
47
+ dplyr::rename(target_locus_tag = locus_tag, target_symbol = symbol)
48
+
49
+ # df %>%
50
+ # select(GeneName) %>%
51
+ # distinct(GeneName) %>%
52
+ # filter(!GeneName %in% tmp$GeneName) %>%
53
+ # mutate(id=NA) %>%
54
+ # select(GeneName, id) %>%
55
+ # dplyr::rename(gene_id=id) %>%
56
+ # write_csv("data/mcisaac/mcisaac_gene_lookup.txt")
57
+
58
+ # This is sort of an interesting aside. I'm looking back at how I parsed the mcisaac dataset as I add it to huggingface. As I do this, I am reminded of little details like the fact that in their probe set, they have a prob for AAD6 and AAD16 . In the current annotation set, it is noted that AAD16 is a -1 frameshift of AAD6 and it is removed. AAD6 itself is labeled a pseudogene.
59
+ # that made me think that what would be interesting is how correlated they are (plotted, generally correlated).
60
+ # I looked at the absolute of the differences wondering which genes showed the greatest difference -- possibly these two loci are differentially regulated, who knows.
61
+ # More interesting, I looked at regulators where the signs differed for AAD6 and AAD16. Possibly this is due to differential regulation. But it is also possible that this might give insight into what the minimum reliable threshold of the effect is.
62
+ # The maximum unshrunken effect of a pair with different signs was 0.54. For DTO we set a threshold of 0.6, so this isn't really useful in any way. But I thought I'd share anyway
63
+ mcisaac_gene_aliases = read_csv("data/mcisaac/mcisaac_gene_lookup.txt") %>%
64
+ # this is a -1 frameshift to AAD6 (also in mcisaac) and is not in 3-1. Added
65
+ # by hand -- this * might * be an interesting locus to look at for variance?
66
+ bind_rows(tibble(GeneName="AAD16", locus_tag="YFL056C")) %>%
67
+ dplyr::rename(target_locus_tag=locus_tag) %>%
68
+ mutate(target_symbol=GeneName)
69
+
70
+
71
+ mcisaac_gene_table = mcisaac_gene_table_incomplete %>%
72
+ bind_rows(mcisaac_gene_aliases)
73
+
74
+ stopifnot(setequal(mcisaac_gene_table$GeneName, unique(df$GeneName)))
75
+
76
+ mcisaac_for_parquet = df %>%
77
+ mutate(date=str_remove_all(as.Date(date, format='%m/%d/%Y'),'-')) %>%
78
+ left_join(tf_table) %>%
79
+ left_join(mcisaac_gene_table)
80
+
81
+ mcisaac_tf_to_regulator_locus_tag = mcisaac_for_parquet %>%
82
+ select(TF, regulator_locus_tag) %>%
83
+ distinct()
84
+
85
+ mcisaac_GeneName_to_target_locus_tag = mcisaac_for_parquet %>%
86
+ select(GeneName, target_locus_tag) %>%
87
+ distinct()
88
+
89
+ # mcisaac_for_parquet %>%
90
+ # select(regulator_locus_tag, time, mechanism, restriction, date, strain,
91
+ # target_locus_tag, ends_with("median"), starts_with("log2")) %>%
92
+ # group_by(regulator_locus_tag, time, mechanism, restriction, date, strain) %>%
93
+ # write_dataset(path = here("data/mcisaac/hf/data"), format = "parquet")