Skip to content

Commit 7d948c9

Browse files
Update New_DEseq2_emrichment_analysis.R
Changes the valcano plot method based on p-adjusted threshold rather than p-value
1 parent b218d8b commit 7d948c9

1 file changed

Lines changed: 19 additions & 9 deletions

File tree

New_DEseq2_emrichment_analysis.R

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -157,16 +157,26 @@ res <- results(dds, contrast=contrast) ## extract result dataframe
157157
View(as.data.frame(res))
158158

159159
### Valcono plot
160-
library(EnhancedVolcano)
160+
# add a column for labels of DE genes
161+
res$diffexpressed <- "NO"
162+
# if log2Foldchange > 1 and p-adjusted value <= 0.05, set as "UP"
163+
res$diffexpressed[res$logFC >= 1 & adj.P.Val <= 0.05] <- "UP"
164+
# if log2Foldchange < - 1 and adj.P.Val <= 0.05, set as "DOWN"
165+
res$diffexpressed[res$logFC <= -1 & res$adj.P.Val <= 0.05] <- "UP"
166+
# Create a new column "delabel" to de, that will contain the name of genes differentially expressed (NA in case they are not)
167+
res$delabel <- NA
168+
res$delabel[res$diffexpressed != "NO"] <- res$gene[res$diffexpressed != "NO"]
169+
170+
library(ggrepel)
171+
# plot adding up all layers we have seen so far
172+
ggplot(data=res, aes(x=logFC, y=-log10(adj.P.Val), col=diffexpressed, label=delabel)) +
173+
geom_point() +
174+
theme_minimal() +
175+
geom_text_repel() +
176+
scale_color_manual(values=c("blue", "black", "red")) +
177+
geom_vline(xintercept=c(-1, 1), col="red") +
178+
geom_hline(yintercept=-log10(0.05), col="red")
161179

162-
EnhancedVolcano(res,
163-
lab = rownames(res),
164-
x = 'log2FoldChange',
165-
#pCutoff = 1e-05,
166-
#FCcutoff = 1,
167-
y = 'pvalue') ## Default cut-off for log2FC is >|2| and for P value is 10e-6. USE pCutoff = 10e-6, FCcutoff = 2.0
168-
169-
#?EnhancedVolcano
170180

171181

172182
res$threshold <- as.logical(res$padj < p.threshold) #Threshold defined earlier#creating col with logic

0 commit comments

Comments
 (0)