Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to generate gseaplots from the result of compareCluster gseaGO or gseaKEGG functions? #673

Open
JiahuaQu opened this issue Mar 9, 2024 · 2 comments

Comments

@JiahuaQu
Copy link

JiahuaQu commented Mar 9, 2024

We have ran the compareCluster gseaGO or gseaKEGG functions and there were three groups. Now we want to generate the gseaplot2 from the result, but after we ran the codes: gseaplot2(GO_sim_readable, geneSetID = c(10,61,213),pvalue_table = TRUE,color = c("#3C234A","#70BACC","#ECDC52"),), we got the error:
Error in FUN(X[[i]], ...) : no slot of name "geneList" for this object of class "compareClusterResult"

Hope to get your help. Thank you.

@guidohooiveld
Copy link

I can reproduce your 'error'. Reason for this is that results from a compareCluster analysis can not be handled by gseaplot2; see this part of the error message: no slot of name "geneList" for this object of class "compareClusterResult".
gseaplot2 only accepts results from a single GSEA run.

Yet, since the output from a compareCluster and GSEA run are very similar (the only differences are the rownames and addition of a column labelled Cluster in the former), it might be that this can be relatively easily implemented.
@huerqiang : could you please comment on this?

I can envision that when a compareCluster-GSEA result is used for gseaplot2, first a facet should be made based on geneSetID, and that then within each of these plots the results of the different clusters for this geneSetID are plotted.

> library(clusterProfiler)
> library(enrichplot)
> 
> library(org.Hs.eg.db)
> 
> data(geneList, package="DOSE")
> inputList <- list(rankedGenes1 = geneList, rankedGenes2 = geneList)
> 
> ## compareCluster-GSEA
> xx <- compareCluster(geneClusters=inputList, fun = "gseGO",
+              OrgDb = org.Hs.eg.db, keyType = "ENTREZID",
+              ont = "BP", eps = 0, pvalueCutoff = 0.05,
+              pAdjustMethod = "none", minGSSize = 10, maxGSSize = 500)
> xx <- enrichplot::pairwise_termsim(xx) 
> xx <- setReadable(xx, 'org.Hs.eg.db', 'ENTREZID')
> 
> 
> gseaplot2(xx, geneSetID = c(1,2,3))
Error in FUN(X[[i]], ...) : 
  no slot of name "geneList" for this object of class "compareClusterResult"
> 
> 
> ## 'single' GSEA run
> yy <- gseGO(geneList, OrgDb = org.Hs.eg.db, keyType = "ENTREZID",
+             ont = "BP", eps = 0, pvalueCutoff = 0.05,
+             pAdjustMethod = "none", minGSSize = 10, maxGSSize = 500)
preparing geneSet collections...
GSEA analysis...
leading edge analysis...
done...
> yy <- enrichplot::pairwise_termsim(yy)
> yy <- setReadable(yy, 'org.Hs.eg.db', 'ENTREZID')
> 
> gseaplot2(yy, geneSetID = c(1,2,3))
> 

image

> ## check similarity output of both functions
> # compareCluster 
> head(as.data.frame(xx))
       Cluster         ID                          Description setSize
1 rankedGenes1 GO:0007059               chromosome segregation     316
2 rankedGenes1 GO:0051276              chromosome organization     470
3 rankedGenes1 GO:0098813       nuclear chromosome segregation     236
4 rankedGenes1 GO:0000819         sister chromatid segregation     184
5 rankedGenes1 GO:0000070 mitotic sister chromatid segregation     151
6 rankedGenes1 GO:0000280                     nuclear division     325
  enrichmentScore      NES       pvalue     p.adjust       qvalue rank
1       0.5880591 2.772525 5.226983e-31 5.226983e-31 2.420368e-27  449
2       0.5189587 2.547566 1.140612e-30 1.140612e-30 2.640818e-27 1374
3       0.6307606 2.869422 1.517388e-29 1.517388e-29 2.342101e-26  449
4       0.6542189 2.872470 6.351943e-26 6.351943e-26 7.353210e-23  532
5       0.6795449 2.880584 8.909573e-25 8.909573e-25 8.251203e-22  532
6       0.5411728 2.565130 2.602072e-24 2.602072e-24 2.008161e-21 1246
                    leading_edge
1  tags=20%, list=4%, signal=20%
2 tags=24%, list=11%, signal=22%
3  tags=22%, list=4%, signal=22%
4  tags=25%, list=4%, signal=24%
5  tags=28%, list=4%, signal=28%
6 tags=26%, list=10%, signal=24%
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    core_enrichment
1                                                                                                                                                                                                                                                                             CDCA8/CDC20/KIF23/CENPE/MYBL2/CCNB2/NDC80/TOP2A/NCAPH/ASPM/DLGAP5/UBE2C/HJURP/SKA1/NUSAP1/TPX2/TACC3/NEK2/CENPM/CENPN/CDK1/MAD2L1/KIF18A/CDT1/BIRC5/KIF11/TTK/NCAPG/AURKB/TRIP13/PRC1/KIFC1/KIF18B/AURKA/CCNB1/KIF4A/PTTG1/KIF14/KIF2C/CDC6/PLK1/RACGAP1/PTTG3P/BUB1B/ZWINT/CENPU/SPC25/SPAG5/ECT2/CENPI/ESPL1/CCNE1/OIP5/MKI67/HAUS6/CCNE2/GPSM2/NCAPD2/BUB1/STIL/CENPF/FBXO5/ZWILCH
2 CDC45/CDCA8/CDC20/KIF23/CENPE/MYBL2/NDC80/TOP2A/NCAPH/DLGAP5/UBE2C/HJURP/NUSAP1/TPX2/TACC3/NEK2/CENPN/CDK1/MAD2L1/GINS1/KIF18A/CDT1/BIRC5/KIF11/EZH2/TTK/NCAPG/AURKB/GINS2/TRIP13/PRC1/KIFC1/KIF18B/CCNB1/KIF4A/MCM5/PTTG1/MCM2/KIF14/KIF2C/CDC6/PLK1/RACGAP1/PTTG3P/BUB1B/EXO1/ZWINT/SPC25/SPAG5/HMGA1/DSCC1/CENPI/RAD54L/ESPL1/RAD51/CCNE1/HMGB3/OIP5/CCNE2/MCM6/MCM4/FEN1/CCT5/RFC4/NCAPD2/CENPA/GINS4/BUB1/MYC/CENPF/PCNA/GINS3/RECQL4/FBXO5/ZWILCH/BLM/DNA2/NCAPG2/H3C10/H1-1/MCM7/HMGB2/DSN1/H1-2/MSH2/RFC2/KNTC1/CCT6A/NCAPD3/RUVBL1/H1-4/SMC4/CCT2/H1-5/MCM3/NUP155/BRIP1/RAD21/CHEK2/ERCC4/PSRC1/RMDN1/TUBG1/RFC3/NASP/PRKCQ/SPDL1/SMC2/UCHL5/NBN/MIS18A
3                                                                                                                                                                                                                                                                                                                                      CDCA8/CDC20/KIF23/CENPE/MYBL2/CCNB2/NDC80/TOP2A/NCAPH/ASPM/DLGAP5/UBE2C/NUSAP1/TPX2/TACC3/NEK2/CDK1/MAD2L1/KIF18A/CDT1/BIRC5/KIF11/TTK/NCAPG/AURKB/TRIP13/PRC1/KIFC1/KIF18B/AURKA/CCNB1/KIF4A/PTTG1/KIF14/KIF2C/CDC6/PLK1/RACGAP1/PTTG3P/BUB1B/ZWINT/SPC25/SPAG5/ECT2/CENPI/ESPL1/CCNE1/CCNE2/NCAPD2/BUB1/CENPF/FBXO5/ZWILCH
4                                                                                                                                                                                                                                                                                                                                                                              CDCA8/CDC20/KIF23/CENPE/MYBL2/NDC80/TOP2A/NCAPH/DLGAP5/UBE2C/NUSAP1/TPX2/TACC3/NEK2/CDK1/MAD2L1/KIF18A/CDT1/BIRC5/KIF11/TTK/NCAPG/AURKB/TRIP13/PRC1/KIFC1/KIF18B/CCNB1/KIF4A/KIF14/KIF2C/CDC6/PLK1/RACGAP1/BUB1B/ZWINT/SPC25/SPAG5/CENPI/ESPL1/NCAPD2/BUB1/CENPF/FBXO5/ZWILCH/NCAPG2
5                                                                                                                                                                                                                                                                                                                                                                                               CDCA8/CDC20/KIF23/CENPE/MYBL2/NDC80/NCAPH/DLGAP5/UBE2C/NUSAP1/TPX2/NEK2/CDK1/MAD2L1/KIF18A/CDT1/BIRC5/KIF11/TTK/NCAPG/AURKB/TRIP13/PRC1/KIFC1/KIF18B/CCNB1/KIF4A/KIF14/KIF2C/PLK1/RACGAP1/BUB1B/ZWINT/SPC25/SPAG5/CENPI/ESPL1/NCAPD2/BUB1/CENPF/FBXO5/ZWILCH/NCAPG2
6                                                                                                                               CDCA8/CDC20/KIF23/CENPE/MYBL2/CCNB2/NDC80/TOP2A/NCAPH/ASPM/DLGAP5/UBE2C/NUSAP1/TPX2/NEK2/RAD51AP1/UBE2S/CDK1/MAD2L1/KIF18A/CDT1/BIRC5/KIF11/TTK/NCAPG/AURKB/CHEK1/TRIP13/PRC1/KIFC1/KIF18B/AURKA/CCNB1/KIF4A/PTTG1/KIF14/CKS2/KIF2C/MYBL1/PLK1/RACGAP1/PTTG3P/BUB1B/ZWINT/SPC25/SPAG5/CENPI/RAD54L/ESPL1/RAD51/CCNE1/MKI67/CCNE2/FANCA/TDRD12/CDC25B/NCAPD2/BUB1/CENPF/FBXO5/ZWILCH/NCAPG2/RANBP1/DSN1/KIF20B/KNTC1/NCAPD3/FGF8/SPHK1/PKMYT1/CDC25C/SMC4/TOP6BL/RCC1/BORA/BRIP1/RAD21/CHEK2/ERCC4/CD28/DMRT1/PSRC1/RMDN1/TUBG1/RMI1
> 
> # single GSEA run
> head(as.data.frame(yy))
                   ID                          Description setSize
GO:0051276 GO:0051276              chromosome organization     470
GO:0007059 GO:0007059               chromosome segregation     316
GO:0098813 GO:0098813       nuclear chromosome segregation     236
GO:0000819 GO:0000819         sister chromatid segregation     184
GO:0000280 GO:0000280                     nuclear division     325
GO:0000070 GO:0000070 mitotic sister chromatid segregation     151
           enrichmentScore      NES       pvalue     p.adjust       qvalue rank
GO:0051276       0.5189587 2.522024 2.379678e-31 2.379678e-31 1.085634e-27 1374
GO:0007059       0.5880591 2.784593 1.140483e-30 1.140483e-30 2.601503e-27  449
GO:0098813       0.6307606 2.893022 6.983985e-29 6.983985e-29 1.062056e-25  449
GO:0000819       0.6542189 2.916509 1.996114e-26 1.996114e-26 2.276620e-23  532
GO:0000280       0.5411728 2.580962 1.170368e-24 1.170368e-24 1.067869e-21 1246
GO:0000070       0.6795449 2.992971 2.273006e-24 2.273006e-24 1.728282e-21  532
                             leading_edge
GO:0051276 tags=24%, list=11%, signal=22%
GO:0007059  tags=20%, list=4%, signal=20%
GO:0098813  tags=22%, list=4%, signal=22%
GO:0000819  tags=25%, list=4%, signal=24%
GO:0000280 tags=26%, list=10%, signal=24%
GO:0000070  tags=28%, list=4%, signal=28%
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             core_enrichment
GO:0051276 CDC45/CDCA8/CDC20/KIF23/CENPE/MYBL2/NDC80/TOP2A/NCAPH/DLGAP5/UBE2C/HJURP/NUSAP1/TPX2/TACC3/NEK2/CENPN/CDK1/MAD2L1/GINS1/KIF18A/CDT1/BIRC5/KIF11/EZH2/TTK/NCAPG/AURKB/GINS2/TRIP13/PRC1/KIFC1/KIF18B/CCNB1/KIF4A/MCM5/PTTG1/MCM2/KIF14/KIF2C/CDC6/PLK1/RACGAP1/PTTG3P/BUB1B/EXO1/ZWINT/SPC25/SPAG5/HMGA1/DSCC1/CENPI/RAD54L/ESPL1/RAD51/CCNE1/HMGB3/OIP5/CCNE2/MCM6/MCM4/FEN1/CCT5/RFC4/NCAPD2/CENPA/GINS4/BUB1/MYC/CENPF/PCNA/GINS3/RECQL4/FBXO5/ZWILCH/BLM/DNA2/NCAPG2/H3C10/H1-1/MCM7/HMGB2/DSN1/H1-2/MSH2/RFC2/KNTC1/CCT6A/NCAPD3/RUVBL1/H1-4/SMC4/CCT2/H1-5/MCM3/NUP155/BRIP1/RAD21/CHEK2/ERCC4/PSRC1/RMDN1/TUBG1/RFC3/NASP/PRKCQ/SPDL1/SMC2/UCHL5/NBN/MIS18A
GO:0007059                                                                                                                                                                                                                                                                             CDCA8/CDC20/KIF23/CENPE/MYBL2/CCNB2/NDC80/TOP2A/NCAPH/ASPM/DLGAP5/UBE2C/HJURP/SKA1/NUSAP1/TPX2/TACC3/NEK2/CENPM/CENPN/CDK1/MAD2L1/KIF18A/CDT1/BIRC5/KIF11/TTK/NCAPG/AURKB/TRIP13/PRC1/KIFC1/KIF18B/AURKA/CCNB1/KIF4A/PTTG1/KIF14/KIF2C/CDC6/PLK1/RACGAP1/PTTG3P/BUB1B/ZWINT/CENPU/SPC25/SPAG5/ECT2/CENPI/ESPL1/CCNE1/OIP5/MKI67/HAUS6/CCNE2/GPSM2/NCAPD2/BUB1/STIL/CENPF/FBXO5/ZWILCH
GO:0098813                                                                                                                                                                                                                                                                                                                                      CDCA8/CDC20/KIF23/CENPE/MYBL2/CCNB2/NDC80/TOP2A/NCAPH/ASPM/DLGAP5/UBE2C/NUSAP1/TPX2/TACC3/NEK2/CDK1/MAD2L1/KIF18A/CDT1/BIRC5/KIF11/TTK/NCAPG/AURKB/TRIP13/PRC1/KIFC1/KIF18B/AURKA/CCNB1/KIF4A/PTTG1/KIF14/KIF2C/CDC6/PLK1/RACGAP1/PTTG3P/BUB1B/ZWINT/SPC25/SPAG5/ECT2/CENPI/ESPL1/CCNE1/CCNE2/NCAPD2/BUB1/CENPF/FBXO5/ZWILCH
GO:0000819                                                                                                                                                                                                                                                                                                                                                                              CDCA8/CDC20/KIF23/CENPE/MYBL2/NDC80/TOP2A/NCAPH/DLGAP5/UBE2C/NUSAP1/TPX2/TACC3/NEK2/CDK1/MAD2L1/KIF18A/CDT1/BIRC5/KIF11/TTK/NCAPG/AURKB/TRIP13/PRC1/KIFC1/KIF18B/CCNB1/KIF4A/KIF14/KIF2C/CDC6/PLK1/RACGAP1/BUB1B/ZWINT/SPC25/SPAG5/CENPI/ESPL1/NCAPD2/BUB1/CENPF/FBXO5/ZWILCH/NCAPG2
GO:0000280                                                                                                                               CDCA8/CDC20/KIF23/CENPE/MYBL2/CCNB2/NDC80/TOP2A/NCAPH/ASPM/DLGAP5/UBE2C/NUSAP1/TPX2/NEK2/RAD51AP1/UBE2S/CDK1/MAD2L1/KIF18A/CDT1/BIRC5/KIF11/TTK/NCAPG/AURKB/CHEK1/TRIP13/PRC1/KIFC1/KIF18B/AURKA/CCNB1/KIF4A/PTTG1/KIF14/CKS2/KIF2C/MYBL1/PLK1/RACGAP1/PTTG3P/BUB1B/ZWINT/SPC25/SPAG5/CENPI/RAD54L/ESPL1/RAD51/CCNE1/MKI67/CCNE2/FANCA/TDRD12/CDC25B/NCAPD2/BUB1/CENPF/FBXO5/ZWILCH/NCAPG2/RANBP1/DSN1/KIF20B/KNTC1/NCAPD3/FGF8/SPHK1/PKMYT1/CDC25C/SMC4/TOP6BL/RCC1/BORA/BRIP1/RAD21/CHEK2/ERCC4/CD28/DMRT1/PSRC1/RMDN1/TUBG1/RMI1
GO:0000070                                                                                                                                                                                                                                                                                                                                                                                               CDCA8/CDC20/KIF23/CENPE/MYBL2/NDC80/NCAPH/DLGAP5/UBE2C/NUSAP1/TPX2/NEK2/CDK1/MAD2L1/KIF18A/CDT1/BIRC5/KIF11/TTK/NCAPG/AURKB/TRIP13/PRC1/KIFC1/KIF18B/CCNB1/KIF4A/KIF14/KIF2C/PLK1/RACGAP1/BUB1B/ZWINT/SPC25/SPAG5/CENPI/ESPL1/NCAPD2/BUB1/CENPF/FBXO5/ZWILCH/NCAPG2
> 

@JiahuaQu
Copy link
Author

JiahuaQu commented Mar 12, 2024

Thank you for your answer. I agree with you on that. As the output formats from compreCluster and gseGO are quite similar with only the difference in the cluster column,
(1) Is it possible to split the output from compareCluster to individual gseGO so that we can plot figures as we do with gseGO output? It takes time to run gseGO again and sometimes the results are not exactly the same as that from compareCluster due to some parameter differences.
(2) Or can you add the function to plot the compareCluster output directly?
Thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants