Is there a way to mark up specific genes in MA-plot?
1
0
Entering edit mode
2.8 years ago
Riku ▴ 80

Dear, everyone,

I have this table, and created MAplot using the following steps. In this plot, I would like to mark up only the genes that I specify:for example, I would like to display the gene name in a different color.

What is the best way to do this? Thank you for reading.

                gene      logFC    logCPM       PValue          FDR
1    Ab_DN4787_c0_g1   8.701543  6.481583 8.718089e-95 1.898277e-90
2    Ab_DN9125_c0_g3  -8.575896  6.311612 5.984297e-77 6.515104e-73
3    Ab_DN4518_c0_g2  -3.880269  8.601647 1.125398e-68 8.168139e-65
4   Ab_DN11435_c0_g1  13.802492  6.566147 2.599560e-64 1.415071e-60
5   Ab_DN18643_c0_g1  13.949692  6.713022 1.070026e-62 4.659751e-59

enter image description here

> res <- read.table("input", sep="\t", header=T, quote = "\"", fill = T)
> A <- res$logCPM
> M <- res$logFC
> plot(A, M, xlab="Average log CPM", ylab="log-fold-change", pch=16, cex=0.4)
edgeR ggplot plot MA R • 2.4k views
ADD COMMENT
1
Entering edit mode

For OP issue, I would suggest you to use "enhancedvolcano" library from Bioconductor or use of ggplot (for plotting) and ggrepel (for labeling genes of interest)

with basic plotting and example data:

genes=c("Ab_DN4787_c0_g1","Ab_DN9125_c0_g3") # genes of interest
subres = subset(res, gene %in% genes)
a = subres$logCPM
m = subres$logFC
A <- res$logCPM
M <- res$logFC
plot(A, M, xlab="Average log CPM", ylab="log-fold-change", pch=16, cex=0.4)
text(a,m,col="steelblue",subres$gene, pos = 4,pch=16) # For labeling of genes of interest
points(a,m,col="steelblue", pch=16) # For highlighting genes of interest

highlight_genes

ADD REPLY
0
Entering edit mode

Thank you very much for your advice. I can make the same figure in ggplot2 with the following command, what options do I need in this case?

g <- ggplot(res, aes(x=logCPM, y=logFC)) +
geom_point(size=1) +
scale_colour_manual(values = c("black", "red")) +
scale_fill_manual(values = c("black", "red"), breaks=c("0", "1"), labels=c("non DEG", "DEG")) +
theme(legend.title=element_blank()) +
ggtitle("title")
print(g)
ADD REPLY
1
Entering edit mode
library(ggplot2)
library(ggrepel)

genes=c("Ab_DN4787_c0_g1","Ab_DN9125_c0_g3")

ggplot(res, aes(logCPM, logFC)) +
    geom_point() +
    theme_bw() +
    theme(legend.position = "none") +
    geom_point(
        data = subset(res, gene %in% genes),
        aes(logCPM, logFC),
        size = 2,
        color = 'red'
    ) +
    geom_text_repel(
        data = subset(res, gene %in% genes),
        aes(logCPM, logFC, label = gene),
        size = 4,
        color = "steelblue"
    )

highlight_genes

ADD REPLY
0
Entering edit mode

Thank you very much! I have been able to create beautiful graph thanks to you.

ADD REPLY
0
Entering edit mode

Please star ggplot devs here: https://github.com/tidyverse/ggplot2

ADD REPLY
1
Entering edit mode
2.8 years ago
kashiff007 ★ 1.9k

Add text from plot

> plot(A, M, xlab="Average log CPM", ylab="log-fold-change", pch=16, cex=0.4) 
> text(labels= c("gene A", "gene B"), pos=2)

I prefer using ggplot.

ADD COMMENT
1
Entering edit mode
> text(labels= c("gene A", "gene B"), pos=2)

One needs to supply x and y coordinates of genes of interest for correct highlighting/labeling.

ADD REPLY
0
Entering edit mode

Thank you very much for your advice. I can make the same figure in ggplot2 with the following command, what options do I need in this case?

g <- ggplot(res, aes(x=logCPM, y=logFC)) +
geom_point(size=1) +
scale_colour_manual(values = c("black", "red")) +
scale_fill_manual(values = c("black", "red"), breaks=c("0", "1"), labels=c("non DEG", "DEG")) +
theme(legend.title=element_blank()) +
ggtitle("title")
print(g)
ADD REPLY

Login before adding your answer.

Traffic: 2542 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