Scatter plot of DEG in R
Entering edit mode
15 months ago
ATCG ▴ 370

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 • 1.2k views
Entering edit mode
15 months ago
ATpoint 64k

Basically something lime this:

#/ Create some dummy data:
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
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. 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

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!!


Login before adding your answer.

Traffic: 718 users visited in the last hour
Help About
Access RSS

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

Powered by the version 2.3.6