Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to change `TRUE` and `FALSE` labels in ggplot2 generated by geo_col?

the data: dput(gsea)

    structure(list(ID = c("ab1", "ab2", "ab3", "ab4", "ab5", "ab6", 
"ab7", "ab8", "ab9", "ab10", "ab11", "ab12", "ab13", "ab14", 
"ab15", "ab16", "ab17", "ab18", "ab19", "ab20"), Count = c(183L, 
37L, 15L, 30L, 38L, 98L, 49L, 58L, 43L, 49L, 98L, 10L, 15L, 83L, 
14L, 5L, 129L, 69L, 32L, 19L), NES = c(3.115511918, 2.65379757, 
2.385595991, 2.310872715, 2.166809058, 2.157225827, 2.112706611, 
-1.982794655, -1.96510639, -1.890716501, -1.845158581, 1.843252451, 
-1.833650877, -1.832752633, 1.830915101, 1.827824231, -1.804884734, 
-1.79943276, -1.786694788, -1.779892361), pvalue = c(1.4e-43, 
6.72e-12, 3.55e-07, 6.6e-08, 8.33e-07, 8.16e-14, 1.31e-08, 1.01e-06, 
7.33e-06, 5.55e-05, 8.32e-06, 0.002090754, 0.0008865, 1.06e-06, 
0.003576374, 0.005822333, 7.09e-08, 3.15e-05, 0.000196647, 0.001113372
), REG = c("up", "up", "up", "up", "up", "up", "up", "down", 
"down", "down", "down", "up", "down", "down", "up", "up", "down", 
"down", "down", "down"), ABS = c(3.115511918, 2.65379757, 2.385595991, 
2.310872715, 2.166809058, 2.157225827, 2.112706611, 1.982794655, 
1.96510639, 1.890716501, 1.845158581, 1.843252451, 1.833650877, 
1.832752633, 1.830915101, 1.827824231, 1.804884734, 1.79943276, 
1.786694788, 1.779892361)), class = "data.frame", row.names = c(NA, 
-20L))

I tried to plot using the following code:

ggplot(gsea, aes(reorder(ID, NES), NES)) +
  geom_col(aes(fill=NES<0)) + 
scale_color_manual(name = 'NES', labels = c("Suppressed", "Activated"), values = c(`FALSE` = 'green', `TRUE` = 'red'))+
  coord_flip() +
  labs(x="Pathway", y="Normalized Enrichment Score",
       title="Curated pathways GSEA") + 
  theme_minimal()

Generated output:
enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I want to change the label TRUE to Activated and DOWN to Suppressed. and NES > 0 to regulation ? How do I do it?

>Solution :

You can try as:

ggplot(df, aes(reorder(ID, NES), NES)) +
geom_col(aes(fill=REG)) + 
scale_color_manual(name = 'REG')+
coord_flip() +
  labs(x="Pathway", y="Normalized Enrichment Score",
       title="Curated pathways GSEA") + 
  theme_minimal()
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading