@@ -86,8 +86,10 @@ contrast_tab$Condition2 <- gsub("\\-", ".", contrast_tab$Condition2)
86
86
meta_tab $ group <- as.factor(as.character(meta_tab $ group ))
87
87
88
88
# # order rows to match counts columns
89
- meta_tab <- meta_tab [match(colnames(counts_tab ), meta_tab $ sample ), ]
90
-
89
+ meta_tab <- meta_tab [match(
90
+ colnames(counts_tab ), make.names(meta_tab $ sample )
91
+ ), ]
92
+ rownames(meta_tab ) <- make.names(meta_tab $ sample )
91
93
92
94
# # ------------------------------------------------------------------------------
93
95
# # Differential gene expression
@@ -130,7 +132,9 @@ contrast_list <- lapply(comb_list, function(x) {
130
132
# # export tables of genes with log2FC and p-values:
131
133
lapply(seq_along(contrast_list ), function (x ) {
132
134
contrast_name <- names(contrast_list )[x ]
133
- res_df <- tibble :: rownames_to_column(as.data.frame(contrast_list [x ]), " feature_id" )
135
+ res_df <- tibble :: rownames_to_column(
136
+ as.data.frame(contrast_list [x ]), " feature_id"
137
+ )
134
138
colnames(res_df ) <- gsub(contrast_name , " " , colnames(res_df ))
135
139
colnames(res_df ) <- gsub(" \\ ." , " " , colnames(res_df ))
136
140
write.table(
@@ -171,7 +175,10 @@ set1pal <- brewer.pal(9, "Set1")
171
175
lapply(seq_along(contrast_list ), function (x ) {
172
176
ymin <- 0
173
177
ymax <- max(- log10(
174
- subset(contrast_list [[x ]], padj < p_thresh & log2FoldChange > l2fc_thresh )$ padj
178
+ subset(
179
+ contrast_list [[x ]],
180
+ padj < p_thresh & log2FoldChange > l2fc_thresh
181
+ )$ padj
175
182
))
176
183
xmin <- round_any(
177
184
min(unlist(subset(
@@ -193,18 +200,27 @@ lapply(seq_along(contrast_list), function(x) {
193
200
194
201
# # show gene labels where the log2FoldChange exceeds a certain threshold:
195
202
keepLabs <- rownames(
196
- subset(contrast_list [[x ]], padj < p_thresh & (abs(log2FoldChange ) > xmax * 0.9 ))
203
+ subset(
204
+ contrast_list [[x ]],
205
+ padj < p_thresh & (abs(log2FoldChange ) > xmax * 0.9 )
206
+ )
197
207
)
198
208
keepLabs <- c(keepLabs , rownames(
199
- subset(contrast_list [[x ]], padj < p_thresh & (abs(- log10(padj )) > ymax * 0.5 ))
209
+ subset(
210
+ contrast_list [[x ]],
211
+ padj < p_thresh & (abs(- log10(padj )) > ymax * 0.5 )
212
+ )
200
213
))
201
214
202
215
# # Custom colour scheme
203
216
keyvals <- ifelse(
204
- contrast_list [[x ]]$ log2FoldChange < (l2fc_thresh * - 1 ) & contrast_list [[x ]]$ padj < p_thresh ,
217
+ contrast_list [[x ]]$ log2FoldChange < (
218
+ l2fc_thresh * - 1 ) & contrast_list [[x ]]$ padj < p_thresh ,
205
219
set1pal [3 ],
206
220
ifelse(
207
- contrast_list [[x ]]$ log2FoldChange > l2fc_thresh & contrast_list [[x ]]$ padj < p_thresh ,
221
+ contrast_list [[x ]]$ log2FoldChange > l2fc_thresh & contrast_list [[
222
+ x
223
+ ]]$ padj < p_thresh ,
208
224
set1pal [1 ], " grey45"
209
225
)
210
226
)
@@ -246,7 +262,9 @@ lapply(seq_along(contrast_list), function(x) {
246
262
247
263
ggsave(
248
264
volcano_plot ,
249
- file = file.path(outdir , paste0(" volcano_plot_" , names(contrast_list )[x ], " .png" )),
265
+ file = file.path(outdir , paste0(" volcano_plot_" , names(
266
+ contrast_list
267
+ )[x ], " .png" )),
250
268
device = " png" , units = " in" ,
251
269
width = 8 , height = 7 , dpi = 300
252
270
)
0 commit comments