DESeq2 MA plot label subset of genes
1
0
Entering edit mode
7 months ago
kstangline ▴ 30

Hello,

I'm new to R and I'm trying to make a MA plot from my DESeq2 results using ggplot2.

I have figured out how to make a MA plot using the following code:

plot_poly <-
all_counts.poly.results %>%
as.data.frame() %>%
ggplot(aes(log2(baseMean), log2FoldChange) +
geom_point(aes(color = pvalue < 0.05), cex = 0.1) +
labs(title = "Poly Torin Treated vs Untreated")


Inside the all_counts.poly.results are EnsGeneIDs I'm interested in labeling on the graph, but there are too many to plot, so want to filter this against an excel file with specific EnsGeneIDs.

For example, I was thinking about setting it up like this with dplyr, but I'm not sure if this is correct.

# contains EnsGeneIDs I want to be plotted

filtered_all_counts.poly.results <- all_counts.poly.results %>%
filter(all_counts.poly.results$EnsGeneIDs %in% EnsGeneIDs) # filter only specific EnsGeneIDs  Then use these filtered EnsGeneIDs as labels on the MA plot I made above? RNA-Seq deseq R • 348 views ADD COMMENT 0 Entering edit mode Have you tried running that and it didn’t work? I can’t tell what exactly you’re asking. Do you want to only plot those genes, or do you want to plot all but only label those ones? Side note: you can just put the bare column name in the filter call without the df$, although I would recommend changing the name of the EnsGeneIDs object so it differs from the column name. Also, if EnsGeneIDs reads in as a dataframe (rather than a vector) you may need to say %in% EnsGeneIDs$V1 (if that’s the column’s name) or convert it to a vector. ADD REPLY 0 Entering edit mode Thanks for the reply! I want to plot all the genes, and I only want to label a few (about 10 genes out of the thousands that ggplot2 plots), hence why I wanted to filter my all_counts.poly.results dataframe with the excel I read in. ADD REPLY 3 Entering edit mode 7 months ago loughrae ▴ 70 To label specific points, you can add a new column to all.counts.poly.results where you test whether the gene is in the list and if so the value is the gene name (whatever you want the label to be) and if not it’s empty: [convert poly to df and IDs to vector if needed]  all.counts.poly.results$mark <- ifelse(all.counts.poly.results$EnsGeneIDs %in% IDs, all.counts.poly.results$EnsGeneIDs, ‘’)
ggplot(all.counts.poly.results, aes(...) + geom_point(...) + geom_text(aes(label = mark))
`

You could also try putting NA instead of ‘’ in the ifelse().
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.20155763626098633, "perplexity": 5260.388202959005}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 20, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2021-43/segments/1634323588244.55/warc/CC-MAIN-20211027212831-20211028002831-00392.warc.gz"}