clusterProfiler icon indicating copy to clipboard operation
clusterProfiler copied to clipboard

emapplot generate different plot using the same data

Open zofieLin opened this issue 4 years ago • 8 comments

Hi, I am using clusterProfiler v4.0.2 now and I found I could not generate the same plot (by group) using "emapplot". my code is emapplot(spf, layout="kk", group_category = T, group_legend = T, cex_label_group = 1.5, node_label = "group", nCluster = 5) then I tried to run this code several times, it will generate different plots every time, with different groups. I put a figure below generated from 4 times using the same code and same dataset.

Are there any solutions to make it more consistent? Thanks!

image

zofieLin avatar Jul 14 '21 08:07 zofieLin

You can use this code to make the results consistent every time:

# It is also correct to use other seed values
set.seed(123)

huerqiang avatar Jul 14 '21 08:07 huerqiang

Thanks. I have tried set.seed() already, but it doesn't work, still generates different group results.

zofieLin avatar Jul 14 '21 09:07 zofieLin

Use the same seed before each plot, not just before the first plot:

library(DOSE)
data(geneList)
de <- names(geneList)[1:100]
x <- enrichDO(de)
x2 <- pairwise_termsim(x)
set.seed(123)
p1 <- emapplot(x2, layout="kk", group_category = T, group_legend = T, 
    cex_label_group = 1.5, node_label = "group", nCluster = 5)
set.seed(123)
p2 <- emapplot(x2, layout="kk", group_category = T, group_legend = T, 
    cex_label_group = 1.5, node_label = "group", nCluster = 5)
set.seed(123)
p3 <- emapplot(x2, layout="kk", group_category = T, group_legend = T, 
    cex_label_group = 1.5, node_label = "group", nCluster = 5)
set.seed(123)
p4 <- emapplot(x2, layout="kk", group_category = T, group_legend = T,
    cex_label_group = 1.5, node_label = "group", nCluster = 5)
library(cowplot)
plot_grid(p1, p2, p3, p4)    

huerqiang avatar Jul 14 '21 09:07 huerqiang

Thank you. It works!

zofieLin avatar Jul 14 '21 10:07 zofieLin

Hi I was wondering how you got your GO terms to be grouped like that? I realized I have multiple GO terms with similar sets of genes and I don't want to repeat multiple of the same things.

muyusitu avatar Mar 13 '22 21:03 muyusitu

Similar(Semantic similarity or other calculation methods) GO terms are grouped together using K-means.

huerqiang avatar Mar 14 '22 02:03 huerqiang

I am not quite sure what that means? How do use the enrichGO data that is generate to get this?

muyusitu avatar Mar 15 '22 00:03 muyusitu

For more details, pls read the source codes.

huerqiang avatar Mar 15 '22 02:03 huerqiang