Scatter plot of DEG in R
1
0
Entering edit mode
3.7 years ago
ATCG ▴ 400

Hello, I apologize for the basic question. How can I generate a scatter plot of DEG in R, as shown in this example? Specifically, if you can suggest a line of code I can use to label up=red and down=blue.

Thanks in advance for your help!enter image description here

R RNA-seq Bioconductor DEG • 3.3k views
ADD COMMENT
2
Entering edit mode
3.7 years ago
ATpoint 86k

Basically something lime this:

#/ Create some dummy data:
library(DESeq2)
Counts  <- log10(assay(makeExampleDESeqDataSet(n=5000, m = 2), "counts")+1)
df <- data.frame(Counts=Counts)
colnames(df) <- c("sample1", "sample2")
df$status <- "NS"
classify <- (df$sample1+1) - (df$sample2+1)
df$status[classify > 0.5] <- "up"
df$status[classify < (-0.5)] <- "down"

#/ Make the basic plot
library(ggplot2)
df %>%
  ggplot(aes(x=sample1, y=sample2, color=status)) + 
  geom_point() +
  scale_color_manual(labels=c("down", "NS", "up"), values=c("firebrick", "grey", "dodgerblue"))

You will probably want to read on the basics of ggplot2 to understand the code as simply copy/pasting it will not have much of a learning benefit. There are plenty of tutorials out there for this, it is an excellent investment of time to understand ggplot2.

Maybe check out Volcano plots, or MA-plots as an alternative to present your results, e.g. https://bioconductor.org/packages/release/bioc/vignettes/EnhancedVolcano/inst/doc/EnhancedVolcano.html which is relatively intuitive to use and it does all the ggplot-ing under the hood for you. Once you get the grasp of ggplot2 you can write custom code if you do not like the look of the plots this package (or any other) produces.

enter image description here

ADD COMMENT
0
Entering edit mode

I am familiar with volcano plots and MA-plots and agree that these are probably better plots for presenting DEG. This is wonderful!! Thank you so much, you are the best!!

ADD REPLY

Login before adding your answer.

Traffic: 1945 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6