<p>The <code>adjustcolor</code> function from <code>grDevices</code> can be used to generate colours with transparency. What you want is colours based on the pathway and transparency to form a colour gradient for the p-value.</p>

<p><code>adjustcolor( "red", alpha.f = 0.2)</code></p>

<p>For the ggplot example, the <code>aes</code> function has an <code>alpha</code> parameter.</p>

<pre><code>ggplot(df2, aes(x = factor(Pathway_names), y = Entities_found), alpha = Entities_pValue) + ######################################
geom_bar(aes(fill = Entities_found, alpha = Entities_pValue), stat = "identity", position = "stack") +  
coord_polar() + 
theme_minimal() + 
 guides(fill = FALSE)
</code></pre>

CC BY-SA 4.0
2018-12-12T06:23:27.910Z
it looks fine now may be i can tweak it a bit more i will see but i see my Entities_found are still 150 but highest one is 176 why am not getting till 176?
kcm
CC BY-SA 4.0
2018-12-13T07:01:40.940Z
i have a doubt the p value gradient still looks confusing ...can you help me regarding that
kcm
CC BY-SA 4.0
2018-12-13T07:39:59.333Z
Try plotting them on a log-scale?
Tom Kelly ケリー・トム
CC BY-SA 4.0
2018-12-13T09:08:14.820Z
no i haven;t given that thought may be that would help
kcm
CC BY-SA 4.0
2018-12-11T14:36:02.527Z
2018-12-11T14:36:02.527Z
Tom Kelly ケリー・トム
<p>Im trying to plot reactome pathway in for of circular bar plot using ggplot2 </p>

<p>my data</p>

<pre><code>    dput(df2)
structure(list(ID = 1:10, Pathway_names = structure(c(5L, 1L, 
7L, 6L, 2L, 3L, 9L, 8L, 10L, 4L), .Label = c("Antigen Presentation: Folding assembly and peptide loading of class I MHC", 
"Antigen processing-Cross presentation", "Class I MHC mediated antigen processing &amp; presentation", 
"Cytokine Signaling in Immune system", "Endosomal/Vacuolar pathway", 
"ER-Phagosome pathway", "Immunoregulatory interactions between a Lymphoid and a non-Lymphoid cell", 
"Interferon alpha/beta signaling", "Interferon gamma signaling", 
"Interferon Signaling"), class = "factor"), Entities_found = structure(c(1L, 
2L, 3L, 4L, 4L, 5L, 6L, 7L, 8L, 9L), .Label = c("51", "54", "55", 
"57", "75", "77", "96", "117", "176"), class = "factor"), Entities_pValue = c(1.11e-16, 
1.11e-16, 0.003908431, 2.54e-12, 2.77e-10, 0.0053068, 1.64e-13, 
1.11e-16, 1.11e-16, 3.68e-06)), row.names = c(NA, -10L), class = "data.frame")
</code></pre>

<p>my code </p>

<pre><code>ggplot(df2, aes(x = factor(Pathway_names), y = Entities_found)) + ######################################
  geom_bar(aes(fill = Entities_pValue), stat = "identity", position = "stack") + 
  #scale_fill_manual(values = c(blank = "white", dark = "black")) + 
  coord_polar() + 
  theme_minimal() + 
  guides(fill = FALSE)
</code></pre>

<p><a href="https://i.sstatic.net/ohhY1.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ohhY1.jpg" alt="my output "></a></p>

<p>So far im not sure how to include both p value and entities in the plot so that the pathway that are coming up can be labeled accordingly </p>

<p>New figure <a href="https://i.sstatic.net/pZjL9.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/pZjL9.jpg" alt="updated figure"></a></p>

CC BY-SA 4.0
2018-12-11T07:18:43.027Z
I don't understand the issue. It looks fine to me.
fridaymeetssunday
CC BY-SA 4.0
2018-12-11T08:57:00.470Z
What do you mean by entities: the third column of your `df2`? You already have the height for the entities and the color for the p-value. How is this plot not what you expected?
llrs
CC BY-SA 4.0
2018-12-11T09:39:48.163Z
yes i tried different ways but this is what i end up with  ,but can you suggest me a way to color it so that it can distinguish p value it color scale_manual ?
kcm
CC BY-SA 4.0
2018-12-11T15:20:58.913Z
@krushnachChandra Sorry I don't understand your question from the comments. You want to distinguish the p-value with the colors? Or do you want to set a manual scale of colors? If the question is the former, you can try to apply `log10`  to the variable to better distinguish the values. If the later case, I don't understand what is your problem with scale_manual
llrs
CC BY-SA 4.0
2018-12-11T17:49:44.087Z
Can I suggest using acronyms for the entity names in the figure? Like ERPP for ER-Phagosome pathway? This way the text can be placed next to its barplot component and be readable.
conchoecia
CC BY-SA 4.0
2018-12-12T06:19:16.767Z
okay let me try that
kcm
<r><visualization><ggplot2>
How to plot p-values in a circular barplot?
# How to plot p-values in a circular barplot?

(Asked by: username_0 on 2018-12-10)

Im trying to plot reactome pathway in for of circular bar plot using ggplot2 
my data
    dput(df2)
structure(list(ID = 1:10, Pathway_names = structure(c(5L, 1L, 
7L, 6L, 2L, 3L, 9L, 8L, 10L, 4L), .Label = c("Antigen Presentation: Folding assembly and peptide loading of class I MHC", 
"Antigen processing-Cross presentation", "Class I MHC mediated antigen processing & presentation", 
"Cytokine Signaling in Immune system", "Endosomal/Vacuolar pathway", 
"ER-Phagosome pathway", "Immunoregulatory interactions between a Lymphoid and a non-Lymphoid cell", 
"Interferon alpha/beta signaling", "Interferon gamma signaling", 
"Interferon Signaling"), class = "factor"), Entities_found = structure(c(1L, 
2L, 3L, 4L, 4L, 5L, 6L, 7L, 8L, 9L), .Label = c("51", "54", "55", 
"57", "75", "77", "96", "117", "176"), class = "factor"), Entities_pValue = c(1.11e-16, 
1.11e-16, 0.003908431, 2.54e-12, 2.77e-10, 0.0053068, 1.64e-13, 
1.11e-16, 1.11e-16, 3.68e-06)), row.names = c(NA, -10L), class = "data.frame")

my code 
ggplot(df2, aes(x = factor(Pathway_names), y = Entities_found)) + ######################################
  geom_bar(aes(fill = Entities_pValue), stat = "identity", position = "stack") + 
  #scale_fill_manual(values = c(blank = "white", dark = "black")) + 
  coord_polar() + 
  theme_minimal() + 
  guides(fill = FALSE)


So far im not sure how to include both p value and entities in the plot so that the pathway that are coming up can be labeled accordingly 
New figure

**Tags:** r, visualization, ggplot2
> **Comments:**
> **username_1**: I don't understand the issue. It looks fine to me.  
> **username_2**: What do you mean by entities: the third column of your `df2`? You already have the height for the entities and the color for the p-value. How is this plot not what you expected?  
> **username_0**: yes i tried different ways but this is what i end up with  ,but can you suggest me a way to color it so that it can distinguish p value it color scale_manual ?  
> **username_2**: @krushnachChandra Sorry I don't understand your question from the comments. You want to distinguish the p-value with the colors? Or do you want to set a manual scale of colors? If the question is the former, you can try to apply `log10`  to the variable to better distinguish the values. If the later case, I don't understand what is your problem with scale_manual  
> **username_3**: Can I suggest using acronyms for the entity names in the figure? Like ERPP for ER-Phagosome pathway? This way the text can be placed next to its barplot component and be readable.  
> **username_0**: okay let me try that  

---

## 1 answers

### Answer by username_4 on 2018-12-11. Score: 3 | Accepted answer

The adjustcolor function from grDevices can be used to generate colours with transparency. What you want is colours based on the pathway and transparency to form a colour gradient for the p-value.
adjustcolor( "red", alpha.f = 0.2)
For the ggplot example, the aes function has an alpha parameter.
ggplot(df2, aes(x = factor(Pathway_names), y = Entities_found), alpha = Entities_pValue) + ######################################
geom_bar(aes(fill = Entities_found, alpha = Entities_pValue), stat = "identity", position = "stack") +  
coord_polar() + 
theme_minimal() + 
 guides(fill = FALSE)

> **Comments:**
> **username_0**: it looks fine now may be i can tweak it a bit more i will see but i see my Entities_found are still 150 but highest one is 176 why am not getting till 176?  
> **username_0**: i have a doubt the p value gradient still looks confusing ...can you help me regarding that  
> **username_4**: Try plotting them on a log-scale?  
> **username_0**: no i haven;t given that thought may be that would help  

---

