YuLab-SMU / clusterProfiler

:bar_chart: A universal enrichment tool for interpreting omics data
https://yulab-smu.top/biomedical-knowledge-mining-book/
1k stars 253 forks source link

facet compareCluster result #32

Closed GuangchuangYu closed 8 years ago

GuangchuangYu commented 8 years ago

This is an idea from @dalloliogm

it would be better if compareCluster would return a dataframe with multiple columns, instead of merging them into a single column called Cluster. This would be make it possible to plot the results using facets or something more fancy.

see http://bioinfoblog.it/2015/02/a-formula-interface-for-geneontology-analysis/.

data(geneList, package="DOSE")
mydf <- data.frame(Entrez=names(geneList), FC=geneList)
mydf <- mydf[abs(mydf$FC) > 1,]
mydf$group <- "upregulated"
mydf$group[mydf$FC < 0] <- "downregulated"
mydf$othergroup <- "A"
mydf$othergroup[abs(mydf$FC) > 2] <- "B"

require(clusterProfiler)
xx <- compareCluster(Entrez~group+othergroup, data=mydf, fun="enrichGO")
require(ggplot2)
## plot(xx), since the parameter x was already taken as input object, 
## we can't use `x` to specify x variable.
## now we prefer using `dotplot` function to produce the same figure.
dotplot(xx)

screenshot 2015-11-03 19 13 06

## we can specify other x variable instead of the default `Cluster` variable.
dotplot(xx,x=~group) + facet_grid(~othergroup)

screenshot 2015-11-03 19 08 31

GuangchuangYu commented 8 years ago

see https://github.com/GuangchuangYu/clusterProfiler/commit/a8fe7b9c40f78482e18f51e58ff632a86aa5f50a.

dalloliogm commented 8 years ago

I think it is much better now, thank you for implementing it :-)

huerqiang commented 3 years ago

@Psequencer

dotplot(ComGO)
huerqiang commented 3 years ago

@Psequencer What(which column of your compareCluster result) do you want to use for the facet? In your example, you may not be able to find the suitable column.