Search
Question: Labeling points with hgnc symbols on the MA plot in DESeq2
0
gravatar for spark27
15 months ago by
spark270
spark270 wrote:

 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

 

ADD COMMENTlink modified 15 months ago by phil.chapman120 • written 15 months ago by spark270
2
gravatar for phil.chapman
15 months ago by
phil.chapman120
United Kingdom
phil.chapman120 wrote:

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 COMMENTlink modified 15 months ago • written 15 months ago by phil.chapman120

Thank you, Phil.

ADD REPLYlink written 15 months ago by spark270
1
gravatar for snamjoshi87
15 months ago by
snamjoshi8710
snamjoshi8710 wrote:

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 COMMENTlink modified 15 months ago • written 15 months ago by snamjoshi8710

Thank you. I really appreciate it.

ADD REPLYlink written 15 months ago by spark270
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.2.0
Traffic: 202 users visited in the last hour