Chase Mateusiak commited on
Commit
2027954
·
1 Parent(s): 8eb634b

adding macs2 peaks for standard conditions

Browse files
README.md CHANGED
@@ -57,6 +57,7 @@ features:
57
  - chec_genome_map_meta
58
  - chec_mahendrawada_m2025_af_combined_meta
59
  - mahendrawada_chec_seq
 
60
  - rna_seq
61
  - rnaseq_reprocessed
62
  - degron_counts_meta
@@ -77,6 +78,7 @@ features:
77
  - chec_mahendrawada_m2025_af_replicates_mindel
78
  - chec_mahendrawada_m2025_af_combined_mindel
79
  - mahendrawada_chec_seq
 
80
  - rna_seq
81
  - rnaseq_reprocessed
82
  - degron_counts
@@ -811,6 +813,40 @@ configs:
811
  description: SRA (Sequence Read Archive) accession identifier for this biological replicate
812
  role: sample_id
813
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
814
  - config_name: chec_mahendrawada_m2025_af_replicates_mindel
815
  description: >-
816
  Promoter significance scores using the Mindel promoters, calculated using the mahendrawada_annotated_features.R. This is a reprocessing of the original authors'
@@ -881,7 +917,7 @@ configs:
881
  - config_name: chec_mahendrawada_m2025_af_combined_meta
882
  description: Sample-level metadata for combined ChEC-seq experiments with regulator information and experimental conditions
883
  dataset_type: metadata
884
- applies_to: ["chec_mahendrawada_m2025_af_combined","chec_mahendrawada_m2025_af_combined_mindel", "chec_mahendrawada_m2025_af_combined_start_codon_500bp", "chec_mahendrawada_m2025_af_combined_intergenic"]
885
  data_files:
886
  - split: train
887
  path: chec_mahendrawada_m2025_af_combined_meta.parquet
 
57
  - chec_genome_map_meta
58
  - chec_mahendrawada_m2025_af_combined_meta
59
  - mahendrawada_chec_seq
60
+ - macs2_standard_peaks
61
  - rna_seq
62
  - rnaseq_reprocessed
63
  - degron_counts_meta
 
78
  - chec_mahendrawada_m2025_af_replicates_mindel
79
  - chec_mahendrawada_m2025_af_combined_mindel
80
  - mahendrawada_chec_seq
81
+ - macs2_standard_peaks
82
  - rna_seq
83
  - rnaseq_reprocessed
84
  - degron_counts
 
813
  description: SRA (Sequence Read Archive) accession identifier for this biological replicate
814
  role: sample_id
815
 
816
+ - config_name: macs2_standard_peaks
817
+ description: >-
818
+ MACS2 peak calls for the Mahendrawada 2025 ChEC-seq data. This data is processed through a workflow which is described in scripts/mahendrawada_peak_analysis.R
819
+ and standardized with the Rossi data. It follows the same convention that a promoter must have a peak in at least 2 replicates to be counted as peak for that
820
+ promoter. The max, median and nearest score across peaks in a given promoter are provided when there is more than one peak either within a single replicate, or
821
+ across replicates where the same promoter is included in at least 2 replicates. Annotations of peaks to targets is performed by homer. Only peaks within
822
+ 700bp of the start codon and with `q-value < 0.1` are retained.
823
+ dataset_type: annotated_features
824
+ data_files:
825
+ - split: train
826
+ path: macs2_standard_peaks.parquet
827
+ dataset_info:
828
+ features:
829
+ - name: sample_id
830
+ dtype: int64
831
+ description: Unique identifier for a sample.
832
+ role: sample_id
833
+ - name: n_peaks
834
+ dtype: int64
835
+ description: Number of peaks called for this promoter across replicates
836
+ role: quantitative_measure
837
+ - name: nearest_score
838
+ dtype: float64
839
+ description: Score of the peak nearest to the promoter center. -log10(q-value) from MACS2 peak calling.
840
+ role: quantitative_measure
841
+ - name: median_score
842
+ dtype: float64
843
+ description: Median score of all peaks called for this promoter across replicates. -log10(q-value) from MACS2 peak calling.
844
+ role: quantitative_measure
845
+ - name: max_score
846
+ dtype: float64
847
+ description: Maximum score of all peaks called for this promoter across replicates. -log10(q-value) from MACS2 peak calling.
848
+ role: quantitative_measure
849
+
850
  - config_name: chec_mahendrawada_m2025_af_replicates_mindel
851
  description: >-
852
  Promoter significance scores using the Mindel promoters, calculated using the mahendrawada_annotated_features.R. This is a reprocessing of the original authors'
 
917
  - config_name: chec_mahendrawada_m2025_af_combined_meta
918
  description: Sample-level metadata for combined ChEC-seq experiments with regulator information and experimental conditions
919
  dataset_type: metadata
920
+ applies_to: ["chec_mahendrawada_m2025_af_combined","chec_mahendrawada_m2025_af_combined_mindel", "chec_mahendrawada_m2025_af_combined_start_codon_500bp", "chec_mahendrawada_m2025_af_combined_intergenic", "macs2_standard_peaks"]
921
  data_files:
922
  - split: train
923
  path: chec_mahendrawada_m2025_af_combined_meta.parquet
macs2_standard_peaks.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1819800bb53adb25f25c8a8d0079802cc68077df878c648179c1bc937d46f50d
3
+ size 333212
scripts/mahendrawada_peak_analysis.R ADDED
@@ -0,0 +1,224 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ library(tidyverse)
2
+ library(janitor)
3
+ library(GenomicRanges)
4
+ library(here)
5
+
6
+ read_in_annotated_peaks <- function(peak_path) {
7
+ df <- read_tsv(peak_path, show_col_types = FALSE) |>
8
+ janitor::clean_names()
9
+
10
+ # Skip empty annotations
11
+ if (nrow(df) == 0) {
12
+ warning(sprintf("Skipping empty annotation file: %s", basename(peak_path)))
13
+ return(NULL)
14
+ }
15
+
16
+ df
17
+ }
18
+
19
+ score_targets <- function(regulator, min_dist = 0, max_dist = 700) {
20
+ bind_rows(annotated_peaks$df[which(str_detect(names(annotated_peaks$df), regulator))],
21
+ .id = "tmp"
22
+ ) |>
23
+ separate_wider_delim(tmp,
24
+ delim = "_", names = c(
25
+ "regulator_symbol",
26
+ "replicate"
27
+ ),
28
+ too_few = "align_start"
29
+ ) |>
30
+ filter(
31
+ peak_score > -log10(0.1),
32
+ str_detect(nearest_promoter_id, "mRNA"),
33
+ between(distance_to_tss, min_dist, max_dist)
34
+ ) |>
35
+ group_by(entrez_id) |>
36
+ reframe(
37
+ n_peaks = n_distinct(replicate),
38
+ nearest_score = peak_score[which.min(abs(distance_to_tss))],
39
+ median_score = median(peak_score),
40
+ max_score = max(peak_score)
41
+ )
42
+ }
43
+
44
+
45
+ annotated_peaks <- list(
46
+ files = list.files(here("data/mahendrawada_macs"),
47
+ "_annotated_peaks.txt",
48
+ full.names = TRUE,
49
+ recursive = TRUE
50
+ )
51
+ )
52
+ names(annotated_peaks$files) <- str_remove(
53
+ basename(annotated_peaks$files),
54
+ "_annotated_peaks.txt"
55
+ )
56
+
57
+ annotated_peaks$df <- compact(map(annotated_peaks$files, read_in_annotated_peaks))
58
+
59
+
60
+ annotated_peaks$target_score <- map(unique(str_remove(names(annotated_peaks$df), "_(A|B|C)")), score_targets)
61
+ names(annotated_peaks$target_score) <- unique(str_remove(names(annotated_peaks$df), "_(A|B|C)"))
62
+
63
+ meta <- arrow::read_parquet("~/projects/huggingface/mahendrawada_2025/chec_genome_map_meta.parquet")
64
+
65
+ brentlab_features <- read_csv("~/projects/huggingface/yeast_genome_resources/brentlab_features.csv.gz")
66
+
67
+ peaks_df_to_hf <- bind_rows(annotated_peaks$target_score, .id = "regulator_symbol") |>
68
+ left_join(
69
+ filter(meta, condition == "standard") |>
70
+ dplyr::select(sample_id, regulator_locus_tag, regulator_symbol) |>
71
+ distinct()
72
+ ) |>
73
+ dplyr::select(sample_id, regulator_locus_tag, regulator_symbol,
74
+ target_locus_tag = entrez_id,
75
+ n_peaks, nearest_score, median_score, max_score
76
+ ) |>
77
+ left_join(dplyr::select(brentlab_features,
78
+ target_locus_tag = locus_tag,
79
+ target_symbol = symbol
80
+ )) |>
81
+ dplyr::relocate(
82
+ sample_id,
83
+ regulator_locus_tag, regulator_symbol,
84
+ target_locus_tag, target_symbol
85
+ )
86
+
87
+ # peaks_df_to_hf |>
88
+ # arrow::write_parquet("~/projects/huggingface/mahendrawada_2025/macs2_standard_peaks.parquet")
89
+
90
+ # NOTE: do not use the sample_id
91
+ authors_orig_peaks <- arrow::read_parquet("~/projects/huggingface/mahendrawada_2025/chec_mahendrawada_2025.parquet")
92
+
93
+ peaks_df_to_hf_with_athors_orig <- peaks_df_to_hf |>
94
+ # NOTE: the authors orig peaks sample_id column is deprecated. see datacard
95
+ dplyr::select(-sample_id)
96
+ left_join(
97
+ authors_orig_peaks |>
98
+ dplyr::rename(authors_score = peak_score)
99
+ )
100
+
101
+ # mcisaac_responsive <- arrow::read_parquet("~/projects/huggingface/hackett_2020/hackett_2020_analysis_set.parquet")
102
+ #
103
+ # peaks_with_mcisaac <- peaks_df |>
104
+ # dplyr::rename(target_locus_tag = entrez_id) |>
105
+ # filter(
106
+ # treatment == "Normal",
107
+ # growth_media == "YPD",
108
+ # median_score >= -log10(0.1)
109
+ # ) |>
110
+ # left_join(dplyr::select(
111
+ # mcisaac_responsive,
112
+ # regulator_locus_tag,
113
+ # target_locus_tag,
114
+ # time,
115
+ # responsive
116
+ # )) |>
117
+ # filter(!is.na(responsive))
118
+ #
119
+ # peaks_with_mcisaac |>
120
+ # filter(time == 30) |>
121
+ # group_by(regulator_locus_tag) |>
122
+ # nest() |>
123
+ # mutate(
124
+ # rr_nearest = map_dbl(data, ~ {
125
+ # .x |>
126
+ # arrange(desc(nearest_score)) |>
127
+ # slice_head(n = 25) |>
128
+ # summarise(sum(responsive) / n()) |>
129
+ # pull()
130
+ # }),
131
+ # rr_max = map_dbl(data, ~ {
132
+ # .x |>
133
+ # arrange(desc(max_score)) |>
134
+ # slice_head(n = 25) |>
135
+ # summarise(sum(responsive) / n()) |>
136
+ # pull()
137
+ # }),
138
+ # rr_median = map_dbl(data, ~ {
139
+ # .x |>
140
+ # arrange(desc(median_score)) |>
141
+ # slice_head(n = 25) |>
142
+ # summarise(sum(responsive) / n()) |>
143
+ # pull()
144
+ # })
145
+ # ) |>
146
+ # dplyr::select(-data) |>
147
+ # pivot_longer(
148
+ # cols = starts_with("rr_"),
149
+ # names_to = "score_type",
150
+ # values_to = "rr"
151
+ # ) |>
152
+ # ggplot(aes(x = score_type, y = rr)) +
153
+ # geom_boxplot()
154
+ #
155
+ # library(patchwork)
156
+ # library(gridExtra)
157
+ #
158
+ # score_summary <- peaks_with_mcisaac |>
159
+ # filter(time == 30) |>
160
+ # group_by(regulator_locus_tag) |>
161
+ # reframe(
162
+ # score_type = c("nearest", "max", "median"),
163
+ # n_targets = c(
164
+ # n_distinct(target_locus_tag),
165
+ # n_distinct(target_locus_tag),
166
+ # n_distinct(target_locus_tag)
167
+ # ),
168
+ # n_peaks = c(n(), n(), n()),
169
+ # min = c(min(nearest_score), min(max_score), min(median_score)),
170
+ # max = c(max(nearest_score), max(max_score), max(median_score)),
171
+ # median = c(median(nearest_score), median(max_score), median(median_score)),
172
+ # mean = c(mean(nearest_score), mean(max_score), mean(median_score))
173
+ # )
174
+ #
175
+ #
176
+ # p1 <- score_summary |>
177
+ # ggplot(aes(x = score_type, y = mean, fill = score_type)) +
178
+ # geom_boxplot(alpha = 0.7) +
179
+ # labs(title = "Mean Score Distribution", y = "Mean Score", x = "") +
180
+ # theme_minimal() +
181
+ # theme(legend.position = "none")
182
+ #
183
+ # p3 <- score_summary |>
184
+ # ggplot(aes(x = n_targets, y = mean, color = score_type)) +
185
+ # geom_point(alpha = 0.6) +
186
+ # facet_wrap(~score_type) +
187
+ # scale_x_log10() +
188
+ # labs(title = "Number of Targets vs Mean Score", x = "N Targets (log10)", y = "Mean") +
189
+ # theme_minimal() +
190
+ # theme(legend.position = "none")
191
+ #
192
+ # # Calculate stats for table
193
+ # n_targets_summary <- score_summary |>
194
+ # dplyr::select(n_targets) |>
195
+ # distinct() |>
196
+ # pull(n_targets) %>%
197
+ # {
198
+ # tibble(
199
+ # Min = round(quantile(., probs = 0), 2),
200
+ # Q25 = round(quantile(., probs = 0.25), 2),
201
+ # Median = round(quantile(., probs = 0.5), 2),
202
+ # Q75 = round(quantile(., probs = 0.75), 2),
203
+ # Max = round(quantile(., probs = 1), 2)
204
+ # )
205
+ # }
206
+ #
207
+ # # Vertical boxplot
208
+ # p4_plot <- score_summary |>
209
+ # dplyr::select(regulator_locus_tag, n_targets) |>
210
+ # distinct() |>
211
+ # ggplot(aes(x = "", y = n_targets)) +
212
+ # geom_boxplot(width = 0.3) +
213
+ # scale_y_log10() +
214
+ # labs(title = "Distribution of Targets per Regulator", y = "N Targets (log10)", x = "") +
215
+ # theme_minimal() +
216
+ # theme(legend.position = "none")
217
+ #
218
+ # # Summary table
219
+ # p4_table <- gridExtra::tableGrob(n_targets_summary,
220
+ # rows = NULL,
221
+ # theme = ttheme_minimal(base_size = 10)
222
+ # )
223
+ #
224
+ # (p1 + p3) / (p4_plot + p4_table)