@@ -134,6 +134,16 @@ df.final <- dplyr::distinct(df.final, celltype, gene_motif, .keep_all = TRUE)
134
134
df.sig <- dplyr :: filter(df.final , pval < 0.05 ) %> %
135
135
arrange(- num_celltypes , - corr )
136
136
137
+ df.final $ celltype <- as.factor(df.final $ celltype )
138
+ levels(df.final $ celltype ) <- c(" PT" ," PTVCAM1" ," PEC" ," TAL" ," DCT1" ," DCT2" ," CNT" ," PC" ," ICA" ," ICB" ,
139
+ " MES" ," FIB" ," ENDO" ," PODO" ," LEUK" )
140
+
141
+
142
+ df.sig $ celltype <- as.factor(df.sig $ celltype )
143
+ levels(df.sig $ celltype ) <- c(" PT" ," PTVCAM1" ," PEC" ," TAL" ," DCT1" ," DCT2" ," CNT" ," PC" ," ICA" ," ICB" ,
144
+ " MES" ," FIB" ," ENDO" ," PODO" ," LEUK" )
145
+
146
+
137
147
# calculate pearson r2 for all tf-gene combos
138
148
pearson <- cor.test(df.sig $ chromvar , df.sig $ rna , method = " pearson" , conf.level = 0.95 )
139
149
max_chrom <- max(abs(df.sig $ max_chrom )) + 1
@@ -164,7 +174,7 @@ pearson <- cor.test(df.pos$chromvar, df.pos$rna, method="pearson", conf.level=0.
164
174
max_chrom <- max(abs(df.pos $ max_chrom )) + 1
165
175
max_exp <- max(abs(df.pos $ max_exp )) + 1
166
176
167
- p1 <- ggplot(df.pos , aes(x = chromvar , y = rna )) +
177
+ p2 <- ggplot(df.pos , aes(x = chromvar , y = rna )) +
168
178
geom_smooth(method = " lm" , color = " darkgray" ) +
169
179
geom_point(aes(color = celltype )) +
170
180
xlab(" chromVAR activity (avg_logFC)" ) +
@@ -176,7 +186,7 @@ p1 <- ggplot(df.pos, aes(x=chromvar, y=rna)) +
176
186
theme_minimal() +
177
187
geom_hline(yintercept = 0 ) +
178
188
geom_vline(xintercept = 0 )
179
- p1
189
+ p2
180
190
181
191
182
192
@@ -186,7 +196,7 @@ pearson <- cor.test(df.neg$chromvar, df.neg$rna, method="pearson", conf.level=0.
186
196
max_chrom <- max(abs(df.neg $ max_chrom )) + 1
187
197
max_exp <- max(abs(df.neg $ max_exp )) + 1
188
198
189
- p2 <- ggplot(df.neg , aes(x = chromvar , y = rna )) +
199
+ p3 <- ggplot(df.neg , aes(x = chromvar , y = rna )) +
190
200
geom_smooth(method = " lm" , color = " darkgray" ) +
191
201
geom_point(aes(color = celltype )) +
192
202
xlab(" chromVAR activity (avg_logFC)" ) +
@@ -198,13 +208,31 @@ p2 <- ggplot(df.neg, aes(x=chromvar, y=rna)) +
198
208
theme_minimal() +
199
209
geom_hline(yintercept = 0 ) +
200
210
geom_vline(xintercept = 0 )
201
- p2
211
+ p3
202
212
213
+ gene_motif <- df.final $ gene_motif [grepl(" NR3C1" , df.final $ gene_motif )]
214
+ toplot <- dplyr :: filter(df.final , motif == " MA0113.3" )
215
+ max_chrom <- unique(toplot $ max_chrom )
216
+ max_exp <- unique(toplot $ max_exp )
217
+ p4 <- ggplot(toplot , aes(x = chromvar , y = rna )) +
218
+ geom_smooth(method = " lm" , color = " darkgray" ) +
219
+ geom_point(aes(color = celltype )) +
220
+ geom_text_repel(aes(label = celltype )) +
221
+ xlab(" chromVAR activity (avg_logFC)" ) +
222
+ ylab(" Gene expression (avg_logFC)" ) +
223
+ ggtitle(unique(toplot $ gene ), subtitle = paste0(" Pearson r^2=" ,unique(toplot $ cor )," pval=" ,unique(toplot $ pval ))) +
224
+ xlim(c(- max_chrom ,max_chrom )) +
225
+ ylim(c(- max_exp ,max_exp )) +
226
+ theme_minimal() +
227
+ geom_hline(yintercept = 0 ) +
228
+ geom_vline(xintercept = 0 )
229
+ p4
203
230
204
- toplot <- dplyr :: filter(df.final , gene_motif == " ZEB1_MA0103.3" )
231
+ gene_motif <- df.final $ gene_motif [grepl(" NR3C2" , df.final $ gene_motif )]
232
+ toplot <- dplyr :: filter(df.final , motif == " MA0727.1" )
205
233
max_chrom <- unique(toplot $ max_chrom )
206
234
max_exp <- unique(toplot $ max_exp )
207
- p1 <- ggplot(toplot , aes(x = chromvar , y = rna )) +
235
+ p5 <- ggplot(toplot , aes(x = chromvar , y = rna )) +
208
236
geom_smooth(method = " lm" , color = " darkgray" ) +
209
237
geom_point(aes(color = celltype )) +
210
238
geom_text_repel(aes(label = celltype )) +
@@ -216,5 +244,5 @@ p1 <- ggplot(toplot, aes(x=chromvar, y=rna)) +
216
244
theme_minimal() +
217
245
geom_hline(yintercept = 0 ) +
218
246
geom_vline(xintercept = 0 )
219
- p1
247
+ p5
220
248
0 commit comments