Labeling points with hgnc symbols on the MA plot in DESeq2
2
0
Entering edit mode
spark27 • 0
@spark27-11195
Last seen 8.3 years ago

 Dear all,

I created a new column for hgnc_symbols in the result object of DESeq, but I don't know how to label individual point(s) in MA-plot for a specific gene or genes with hgnc_symbols instead of ensemble gene ids.

Any help will be appreciated.

spark

 

deseq MA • 5.4k views
ADD COMMENT
2
Entering edit mode
phil.chapman ▴ 150
@philchapman-8324
Last seen 8.2 years ago
United Kingdom

Or if you fancy a visit to the tidyverse then this is the equivalent:

library(DESeq2)
library(ggplot2)
library(dplyr)
library(ggrepel)
set.seed(25)
dds <- makeExampleDESeqDataSet()
dds <- DESeq(dds)
res <- results(dds, tidy=TRUE)
res$Symbol <- paste0("Symbol", 1:1000)

res_df <- res %>%
    as.data.frame() %>%
    dplyr::mutate(significant = padj < 0.5)

res_labelled <- res_df %>%
    dplyr::filter(significant)

ggplot(res_df, aes(x=log2(baseMean), y=log2FoldChange, colour=significant)) +
    geom_point() +
    ggrepel::geom_label_repel(data=res_labelled, aes(label=Symbol)) +
    theme_bw()

ADD COMMENT
0
Entering edit mode

Thank you, Phil.

ADD REPLY
1
Entering edit mode
snamjoshi87 ▴ 40
@snamjoshi87-11184
Last seen 7.7 years ago

The code for the MA plot was adapted from: https://www.bioconductor.org/help/course-materials/2015/BioC2015/bioc2015rnaseq.html

Assuming your results are assigned to res, your gene of interest is "Gene", and the column of the data frame mapped to the hgnc_symbols is labelled as symbol:

plotMA(res, ylim = c(-5,5))
with(subset(res, symbol == "Gene"), {
  points(baseMean, log2FoldChange, col = "dodgerblue", cex = 2, lwd = 2)
  text(baseMean, log2FoldChange, "Gene", pos = 2, col = "dodgerblue")
})

For multiple genes you can do:

plotMA(res, ylim = c(-5,5))
with(subset(res, symbol %in% c("Gene1", "Gene2")), {
  points(baseMean, log2FoldChange, col = "dodgerblue", cex = 2, lwd = 2)
  text(baseMean, log2FoldChange, c("Gene1", "Gene2"), pos = 2, col = "dodgerblue")
})
ADD COMMENT
0
Entering edit mode

Thank you. I really appreciate it.

ADD REPLY
0
Entering edit mode

I'm getting issues with "with". The specific error is:

Error: unexpected symbol in "plot(MA) with"

I thought that with is apart of the default R, so I'm lost on what to do. (I do have the DESeq2 package)

*edit Fixed the problem

ADD REPLY

Login before adding your answer.

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