Im trying to decide how to visualise Deseq2 results. I want to plot the relationship between Log2 Fold change in expression against Base mean and/or gene length. I have the data for these parameters. Is there a cool graph type on ggplot that is purpose built for this kind of thing?
If thats what you want to plot just put Log2 fold change on one axis and your other variable on the other axis and use geom_point() to visualize the correlation.
Loosely related, I usually try to show the degree of overlap of the datapoints. A solution is a heatmap-like colour scheme with red meaning higher density of points. If any useful this is an example of code to do that:
library(ggplot2)
# Some simulated data
dge <- data.frame(
logFC= rnorm(20000),
logCPM= rnorm(20000)
)
# Assign colour to points according to density
dge$coldens <- densCols(dge$logCPM, dge$logFC, colramp = colorRampPalette(rev(rainbow(10, end = 4/6))))
# Then plot as usual with base R. With ggplot set scale_color_identity
gg<- ggplot(data= dge, aes(x= logCPM, y= logFC)) +
geom_point(aes(logCPM, logFC, col = coldens), size = 0.5, shape= 20, stroke= 0, alpha= 1) +
scale_color_identity() +
theme_light()
Are you looking for something like MAplot (log2fold vs normalized counts)?
And, I can't figure out why are you interested in plotting log2fold vs gene length, but probably are you looking for a corplot?
Note that EnhancedVolcano can make both the mentioned MA plots and volcano plots.
If thats what you want to plot just put Log2 fold change on one axis and your other variable on the other axis and use
geom_point()
to visualize the correlation.