Upload folder using huggingface_hub
Browse files- scripts/parse_hughes_2006.R +56 -18
scripts/parse_hughes_2006.R
CHANGED
@@ -4,12 +4,12 @@ library(arrow)
|
|
4 |
library(readxl)
|
5 |
|
6 |
# Constants ----
|
7 |
-
|
8 |
HUGHES_DATA_DIR <- here("data/hughes_2006")
|
9 |
|
10 |
# Load genomic features harmonization table ----
|
11 |
# See https://huggingface.co/datasets/BrentLab/yeast_genome_resources
|
12 |
-
genomicfeatures <- arrow::open_dataset(
|
13 |
as_tibble()
|
14 |
|
15 |
#' Read and process Hughes normalized data
|
@@ -140,13 +140,13 @@ validate_data_consistency <- function() {
|
|
140 |
tests <- list(
|
141 |
# Check regulator locus tags match genomic features
|
142 |
regulator_locus_consistency = setequal(
|
143 |
-
intersect(
|
144 |
hughes_2006_meta$regulator_locus_tag
|
145 |
),
|
146 |
|
147 |
# Check regulator symbols match genomic features
|
148 |
regulator_symbol_consistency = setequal(
|
149 |
-
intersect(
|
150 |
hughes_2006_meta$regulator_symbol
|
151 |
),
|
152 |
|
@@ -171,7 +171,7 @@ validate_data_consistency <- function() {
|
|
171 |
# Check targets match genomic features
|
172 |
target_genomic_consistency = setequal(
|
173 |
unique(df_oe$hughes_target),
|
174 |
-
intersect(unique(df_oe$hughes_target),
|
175 |
)
|
176 |
)
|
177 |
|
@@ -205,16 +205,16 @@ if (missing_targets_count > 0) {
|
|
205 |
|
206 |
missing_locus_tags <- setdiff(
|
207 |
unique(df_oe$hughes_target),
|
208 |
-
intersect(unique(df_oe$hughes_target),
|
209 |
)
|
210 |
|
211 |
genome_map = tibble(
|
212 |
locus_tag = intersect(unique(df_oe$hughes_target),
|
213 |
-
|
214 |
left_join(genomicfeatures %>% select(locus_tag, symbol)) %>%
|
215 |
mutate(hughes_target = locus_tag) %>%
|
216 |
bind_rows(
|
217 |
-
|
218 |
filter(str_detect(alias, paste(missing_locus_tags, collapse = "|"))) %>%
|
219 |
mutate(alias_match = str_extract(alias, paste(missing_locus_tags, collapse = "|"))) %>%
|
220 |
dplyr::rename(hughes_target = alias_match) %>%
|
@@ -224,21 +224,59 @@ genome_map = tibble(
|
|
224 |
|
225 |
stopifnot(setequal(genome_map$hughes_target, unique(df_oe$hughes_target)))
|
226 |
|
227 |
-
df_oe_harmonized =
|
228 |
-
df_oe %>%
|
229 |
-
select(-c(sample, regulator_symbol)) %>%
|
230 |
-
pivot_wider(id_cols = c(regulator_symbol, hughes_target),
|
231 |
-
names_from = dye_orientation,
|
232 |
-
values_from = norm_log2fc) %>%
|
233 |
-
dplyr::rename(dye_plus = `+`, dye_minus = `-`) %>%
|
234 |
-
left_join(df_oe)
|
235 |
left_join(
|
236 |
select(hughes_2006_meta,
|
237 |
regulator_locus_tag,
|
238 |
-
regulator_symbol) %>%
|
239 |
left_join(genome_map) %>%
|
240 |
select(regulator_locus_tag, regulator_symbol,
|
241 |
target_locus_tag, target_symbol,
|
242 |
-
|
243 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
244 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
library(readxl)
|
5 |
|
6 |
# Constants ----
|
7 |
+
genomicfeatures_PATH <- here("data/genome_files/hf/features")
|
8 |
HUGHES_DATA_DIR <- here("data/hughes_2006")
|
9 |
|
10 |
# Load genomic features harmonization table ----
|
11 |
# See https://huggingface.co/datasets/BrentLab/yeast_genome_resources
|
12 |
+
genomicfeatures <- arrow::open_dataset(genomicfeatures_PATH) %>%
|
13 |
as_tibble()
|
14 |
|
15 |
#' Read and process Hughes normalized data
|
|
|
140 |
tests <- list(
|
141 |
# Check regulator locus tags match genomic features
|
142 |
regulator_locus_consistency = setequal(
|
143 |
+
intersect(genomicfeatures$locus_tag, hughes_2006_meta$regulator_locus_tag),
|
144 |
hughes_2006_meta$regulator_locus_tag
|
145 |
),
|
146 |
|
147 |
# Check regulator symbols match genomic features
|
148 |
regulator_symbol_consistency = setequal(
|
149 |
+
intersect(genomicfeatures$symbol, hughes_2006_meta$regulator_symbol),
|
150 |
hughes_2006_meta$regulator_symbol
|
151 |
),
|
152 |
|
|
|
171 |
# Check targets match genomic features
|
172 |
target_genomic_consistency = setequal(
|
173 |
unique(df_oe$hughes_target),
|
174 |
+
intersect(unique(df_oe$hughes_target), genomicfeatures$locus_tag)
|
175 |
)
|
176 |
)
|
177 |
|
|
|
205 |
|
206 |
missing_locus_tags <- setdiff(
|
207 |
unique(df_oe$hughes_target),
|
208 |
+
intersect(unique(df_oe$hughes_target), genomicfeatures$locus_tag)
|
209 |
)
|
210 |
|
211 |
genome_map = tibble(
|
212 |
locus_tag = intersect(unique(df_oe$hughes_target),
|
213 |
+
genomicfeatures$locus_tag)) %>%
|
214 |
left_join(genomicfeatures %>% select(locus_tag, symbol)) %>%
|
215 |
mutate(hughes_target = locus_tag) %>%
|
216 |
bind_rows(
|
217 |
+
genomicfeatures %>%
|
218 |
filter(str_detect(alias, paste(missing_locus_tags, collapse = "|"))) %>%
|
219 |
mutate(alias_match = str_extract(alias, paste(missing_locus_tags, collapse = "|"))) %>%
|
220 |
dplyr::rename(hughes_target = alias_match) %>%
|
|
|
224 |
|
225 |
stopifnot(setequal(genome_map$hughes_target, unique(df_oe$hughes_target)))
|
226 |
|
227 |
+
df_oe_harmonized = df_oe %>%
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
left_join(
|
229 |
select(hughes_2006_meta,
|
230 |
regulator_locus_tag,
|
231 |
+
regulator_symbol)) %>%
|
232 |
left_join(genome_map) %>%
|
233 |
select(regulator_locus_tag, regulator_symbol,
|
234 |
target_locus_tag, target_symbol,
|
235 |
+
dye_plus, dye_minus, mean_norm_log2fc)
|
236 |
|
237 |
+
df_oe_harmonized %>%
|
238 |
+
write_parquet("~/code/hf/hughes_2006/overexpression.parquet",
|
239 |
+
compression = "zstd",
|
240 |
+
write_statistics = TRUE,
|
241 |
+
use_dictionary = c(
|
242 |
+
regulator_locus_tag = TRUE,
|
243 |
+
regulator_symbol = TRUE,
|
244 |
+
target_locus_tag = TRUE,
|
245 |
+
target_symbol = TRUE
|
246 |
+
)
|
247 |
+
)
|
248 |
|
249 |
+
df_ko_harmonized = df_ko %>%
|
250 |
+
left_join(
|
251 |
+
select(hughes_2006_meta,
|
252 |
+
regulator_locus_tag,
|
253 |
+
regulator_symbol)) %>%
|
254 |
+
left_join(genome_map) %>%
|
255 |
+
select(regulator_locus_tag, regulator_symbol,
|
256 |
+
target_locus_tag, target_symbol,
|
257 |
+
dye_plus, dye_minus, mean_norm_log2fc)
|
258 |
+
|
259 |
+
df_ko_harmonized %>%
|
260 |
+
write_parquet("~/code/hf/hughes_2006/knockout.parquet",
|
261 |
+
compression = "zstd",
|
262 |
+
write_statistics = TRUE,
|
263 |
+
use_dictionary = c(
|
264 |
+
regulator_locus_tag = TRUE,
|
265 |
+
regulator_symbol = TRUE,
|
266 |
+
target_locus_tag = TRUE,
|
267 |
+
target_symbol = TRUE
|
268 |
+
)
|
269 |
+
)
|
270 |
+
|
271 |
+
hughes_2006_meta %>%
|
272 |
+
janitor::clean_names() %>%
|
273 |
+
write_parquet("~/code/hf/hughes_2006/metadata.parquet",
|
274 |
+
compression = "zstd",
|
275 |
+
write_statistics = TRUE,
|
276 |
+
use_dictionary = c(
|
277 |
+
regulator_locus_tag = TRUE,
|
278 |
+
regulator_symbol = TRUE,
|
279 |
+
oe_passed_qc = TRUE,
|
280 |
+
del_passed_qc = TRUE
|
281 |
+
)
|
282 |
+
)
|