Hello everyone,
By using the online tool David (https://david.ncifcrf.gov) for GO enrichment analysis and the R package GOplot (https://wencke.github.io) I was able to associate a z-score to my gene ontology results. I run the analysis for 3 different conditions (Cond1, Cond2, Cond3) and selected the most interesting GO terms. Now I have a data frame like this:
GO ID term Cond1_PADJ Cond1_Zscore Cond2_PADJ Cond2_Zscore Cond3_PADJ Cond3_Zscore
BP GO:0030198 extracellular matrix organization 3.89101E-05 -2.683281573 5.06412E-12 3.713069518 2.14344E-07 -5.099019514
BP GO:0030154 cell differentiation 0.000553172 -0.239045722 0.002762293 0.784464541 4.07139E-06 -8.373983252
At this point I would like to generate a dot plot pretty similar to the one discussed here (A: Dotplot for filtered pathways result) using ggplot2, but with some adjustments: 1) The size of the dots should be relative to the -log of the PADJ (instead of the Gene Ratio) 2) The colour of the dots should be relative to the Z-score (instead of the p-value) 3) I would like to separate the lanes of my samples like this (relevel the clusterProfiler object)
I know there are some tools out there like Cluster profiler, Pathfindr, etc that can generate this graph, but I just need to plot my results.
Thank you : )
You can follow this tutorial: https://jkzorz.github.io/2019/06/05/Bubble-plots.html
Thank you very much for the tutorial. I am trying to follow it but I am stuck at the plot step because what ggplot expects is basically this format:
Identifier Variable1 Variable2_Cond1 Variable2_Cond2 Variable3_Cond3
Which in tutorial words would be:
My problem is that I have 2 variables relative to each conditions. So It's like I have:
Wich in my dataframe is:
How can I plot both variables?
I actually think the problem is in the melt step, because I have 2 variables and not 1, for this reason I guess I should do something like in this post (https://stackoverflow.com/questions/1544907/melt-to-two-variable-columns).
My long dataset should be something like this:
But instead I get this:
Any help?
You can try
pivot_longer()
to convert from "wide" to "long": https://tidyr.tidyverse.org/reference/pivot_longer.htmlThen use
separate()
to split your columns: https://tidyr.tidyverse.org/reference/separate.htmlThank you very much for all the suggestions, in the end I was able to have what I wanted. Now I have another problem: the order of my go terms in within the groups is the other way around! For example: Real order:
by using:
I can see that the order stays the same in the data frame, but when plotting:
The order whiten the groups goes in the opposite direction:
Ideas?
Solved:
this solved the problem!
Instead of
unique(pcm$term)
, trysort(unique(pcm$term))