Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ggmaplot label specific genes #70

Closed
apastore opened this issue Feb 15, 2018 · 2 comments
Closed

ggmaplot label specific genes #70

apastore opened this issue Feb 15, 2018 · 2 comments

Comments

@apastore
Copy link

Hi I really like this package and the Nice MA plots. I was wondering if is possible to label specific genes instead of the top xx only.

Thanks a lot for this!
Alessandro

@amaurypm
Copy link

amaurypm commented May 9, 2019

Hi, @apastore
I have the same issue. For now what I am doing is setting top = 0 in the function and adding geom_label_repel or geom_text_repel function. Something like this:

ggmaplot(...) + geom_label_repel(data = subset(your_data_frame, gene %in% your_vector_of_specific_gene_names), 
                mapping = aes(label = as.vector(gene),
                             x = log2(baseMean),
                             y = log2FoldChange),
                box.padding = unit(0.35, "lines"),
                point.padding = unit(0.3, "lines"),
                force = 1, 
                fontface = "bold",
                size = 10/3)

Here I am assuming you have a gene column in your data frame with the gene names. Use the same font face and size you used inside ggmaplot (bold and 10 in this example).
I hope this could be useful for you.
Regards,
Amaury

@kassambara
Copy link
Owner

fixed now, thanks!

New argument label.select added

library(ggpubr)
data(diff_express)

# Default plot
ggmaplot(diff_express, main = expression("Group 1" %->% "Group 2"),
         fdr = 0.05, fc = 2, size = 0.4, 
         genenames = as.vector(diff_express$name),
         ggtheme = ggplot2::theme_minimal(),
         top = 15
)

# Select specific genes to show
# set top = 0, then specify genes using label.select argument
ggmaplot(diff_express, main = expression("Group 1" %->% "Group 2"),
         fdr = 0.05, fc = 2, size = 0.4, 
         genenames = as.vector(diff_express$name),
         ggtheme = ggplot2::theme_minimal(),
         top = 0, label.select = c("BUB1", "CD83")
         )

Created on 2020-05-10 by the reprex package (v0.3.0.9001)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants