Co-expressed gene-set enrichment analysis, cogena, is a workflow for gene set enrichment analysis of co-expressed genes. The cogena worklow (Figure 1) proceeds from co-expression analysis using a range of clustering methods, through to gene set enrichment analysis based on a range of pre-defined gene sets. Cogena can be applied to a number of different analytical scenarios dependent on the gene set used. Currently cogena is pre-built with gene sets from Msigdb and Connectivity Map, allowing pathway analysis and drug repositioning analysis respectively, the user can also add custom genes sets to expand analytical functionality further.
The following sections outline a typical example of the cogena workflow, describing the input data and typical analysis steps required for pathway analysis and drug repositioning analysis.
See examples using the ?cogena
command in R.
Note: all the gene names should be gene SYMBOLs since they are used in
the gene set files. Other kinds of gene identifiers can be used
according to the identifiers used in the user-defined gene-set files.
The cogena
package has an example dataset, from the NCBI GEO database GSE13355. The samples are derived from lesional and non-lesional skin of psoriasis patients. There are two objects in the Psoriasis dataset. See ?Psoriasis
for more details.
# library(cogena)
devtools::load_all("./")
## Warning: replacing previous import 'class::somgrid' by 'kohonen::somgrid' when
## loading 'cogena'
data(Psoriasis)
# objects in the Psoriasis dataset.
# Note: label of interest should follow the control label as this
# will affect the direction of gene regulation.
# For instance use factor (c("Normal", "Cancer", "Normal"),
# levels=c("Normal", "Cancer")), instead of factor(c("Normal",
# "Cancer","Normal")) since "Cancer" is the label of interest.
ls()
## [1] "DEexprs" "sampleLabel"
The gene set used determines the type of analysis.
There are a variety of gene sets in the cogena
package, partly collected from MSigDB and CMap. Gene sets are summarized in Table 2.
Table 2. Cogena Gene Sets
Gene Set | Description |
---|---|
c2.cp.kegg.v7.1.symbols.gmt.xz | KEGG gene sets |
c2.cp.reactome.v7.1.symbols.gmt.xz | Reactome gene sets |
c2.cp.v7.0.symbols.gmt.xz | all canonical pathways |
c5.bp.v7.0.symbols.gmt.xz | GO biological processes |
c5.mf.v7.0.symbols.gmt.xz | GO molecular functions |
CmapDn100.gmt.xz | Connectivity map gene sets: top 100 down regulated per drug |
CmapUp100.gmt.xz | Connectivity map gene sets: top 100 up regulated per drug |
User-defined gene-sets must be formatted gmt and/or compressed by xz, (such as c2.cp.kegg.v7.01.symbols.gmt or c2.cp.kegg.v7.01.symbols.gmt.xz). Gene sets should be copied to the extdata directory in the installation directory of cogena, such as ~/R/x86_64-pc-linux-gnu- library/3.2/cogena/extdata in Linux), or kindly send to the author of cogena to share with others.
Firstly, KEGG Pathway Analysis, will be demonstrated to show the utility of cogena. The other analyses based on cogena are similar to the process of pathway analysis. Here we used the KEGG pathway gene set (c2.cp.kegg.v7.01.symbols.gmt.xz), hierarchical and Pam clustering methods, 10 clusters, 2 CPU cores and “correlation” distance metric to set up the pathway analysis.
# KEGG Pathway gene set
annoGMT <- "c2.cp.kegg.v7.01.symbols.gmt.xz"
# GO biological process gene set
# annoGMT <- "c5.bp.v7.0.symbols.gmt.xz"
annofile <- system.file("extdata", annoGMT, package="cogena")
# the number of clusters. It can be a vector.
# nClust <- 2:20
nClust <- 10
# Making factor "Psoriasis" behind factor "ct" means Psoriasis Vs Control
# is up-regualted
sampleLabel <- factor(sampleLabel, levels=c("ct", "Psoriasis"))
# the number of cores.
# ncore <- 8
ncore <- 2
# the clustering methods
# clMethods <- c("hierarchical","kmeans","diana","fanny","som","model",
# "sota","pam","clara","agnes") # All the methods can be used together.
clMethods <- c("hierarchical","pam")
# the distance metric
metric <- "correlation"
# the agglomeration method used for hierarchical clustering
# (hierarchical and agnes)
method <- "complete"
There are two steps for cogena analysis, co-expression analysis and then gene set enrichment analysis (here is pathway anlysis).
# Co-expression Analysis
genecl_result <- coExp(DEexprs, nClust=nClust, clMethods=clMethods,
metric=metric, method=method, ncore=ncore)
# Enrichment (Pathway) analysis for the co-expressed genes
clen_res <- clEnrich(genecl_result, annofile=annofile, sampleLabel=sampleLabel)
## Note: 671 out of 706 exist in the genes population.
summary(clen_res)
##
## Clustering Methods:
## hierarchical pam
##
## The Number of Clusters:
## 10
##
## Metric of Distance Matrix:
## correlation
##
## Agglomeration method for hierarchical clustering (hclust and agnes):
## complete
##
## Gene set:
## c2.cp.kegg.v7.01.symbols.gmt.xz
After completing the cogena analysis, the user can use summary
to see the summary of the result of cogena. And enrichment
caculates the enrichment score of certain clustering methods and certain numbers of cluster.
Cogena does not automatically set the clustering method or the number of clusters. Here we show some principles to guide the user towards optimal selection of method and number of clusters:
summary(clen_res)
##
## Clustering Methods:
## hierarchical pam
##
## The Number of Clusters:
## 10
##
## Metric of Distance Matrix:
## correlation
##
## Agglomeration method for hierarchical clustering (hclust and agnes):
## complete
##
## Gene set:
## c2.cp.kegg.v7.01.symbols.gmt.xz
# Here we consider the "pam" method and 10 clusters.
# Always make the number as character, please!
enrichment.table <- enrichment(clen_res, "pam", "10")
heatmapCluster
is developed to show the co-expression of differentially expressed genes. Figure 2 produced by heatmapCluster
is an enhanced heatmap with co-expression information. Moreover, it is obvious to know which cluster contains up-regulated or down-regulated genes based on the colour.
# Always make the number as character, please!
heatmapCluster(clen_res, "pam", "10", maintitle="Psoriasis")
## The number of genes in each cluster:
## upDownGene
## 1 2
## 468 238
## cluster_size
## 1 2 3 4 5 6 7 8 9 10
## 158 65 38 92 50 67 63 94 61 18
heatmapPEI
can be used to show the enrichment graph. See Figure 3. See ?heatmapPEI
for more details. Many parameters are configurable, while generally the default will be fine.
# The enrichment score for 10 clusters, together with Down-regulated,
# Up-regulated and All DE genes. The values shown in Figure 2 is the -log2(FDR).
#
# Always make the number as character, please!
heatmapPEI(clen_res, "pam", "10", printGS=FALSE, maintitle="Pathway analysis for Psoriasis")
## Joining, by = "rowname"
## Joining, by = c("clusterNumGene", "GS")
## Warning: Vectorized input to `element_text()` is not officially supported.
## Results may be unexpected or may change in future versions of ggplot2.
Figure 3A shows the pathway enrichment for each cluster as well as up-regulated, down-regulated and all the differentially expressed genes. The enrichment scores can be ranked by a certain cluster or the max or average scores of all the scores for each pathway.
heatmapPEI(clen_res, "pam", "10", printGS=FALSE, maintitle="Pathway analysis for Psoriasis", geom="circle")
## Joining, by = "rowname"
## Joining, by = c("clusterNumGene", "GS")
## Warning: Vectorized input to `element_text()` is not officially supported.
## Results may be unexpected or may change in future versions of ggplot2.
Figure 3B shows the pathway enrichment using circle plotting.
Pathway analysis demonstrates that specific disease pathways are often represented by a single cluster. Accordingly, we recommend that drug repositioning is performed based on co-expressed gene clusters instead of all the differentially expressed genes. If the input of cogena is disease related data, the drugs enriched should recover the gene expression changed by the disease (the drug should induce an opposite direction in expression to the disease), while if the input is drug related, the enriched drugs should show similar gene expression changes caused by the drug studied. Here we show drugs for treating psoriasis, an autoimmune disease.
The drug repositioning gene set choice of CmapDn100.gmt.xz or CmapUp100.gmt.xz should be made based on the regulation direction of clusters. For example, as the 7th cluster contains up-regulated genes for psoriasis, the CmapDn100.gmt.xz is chosen for drug repositioning of psoriasis to recover the gene expression changes caused by the disease.
# A comprehensive way
# cmapDn100_cogena_result <- clEnrich(genecl_result,
# annofile=system.file("extdata", "CmapDn100.gmt.xz", package="cogena"),
# sampleLabel=sampleLabel)
# A quick way
# Based on the pathway analysis results
cmapDn100_cogena_result <- clEnrich_one(genecl_result, "pam", "10",
annofile=system.file("extdata", "CmapDn100.gmt.xz", package="cogena"),
sampleLabel=sampleLabel)
Showing the results ordered by the 7th cluster in Figure 5. The parameter orderMethod
is used to order the results.
heatmapPEI(cmapDn100_cogena_result, "pam", "10", printGS=FALSE,
orderMethod = "7", maintitle="Drug repositioning for Psoriasis")
## Joining, by = "rowname"
## Joining, by = c("clusterNumGene", "GS")
## Warning: Vectorized input to `element_text()` is not officially supported.
## Results may be unexpected or may change in future versions of ggplot2.
# Results based on cluster 5.
# heatmapPEI(cmapDn100_cogena_result, "pam", "10", printGS=FALSE,
# orderMethod = "5", maintitle="Drug repositioning for Psoriasis")
# Results based on cluster 9, containing down-regulated genes.
# heatmapPEI(cmapUp100_cogena_result, "pam", "10", printGS=FALSE,
# orderMethod = "9", maintitle="Drug repositioning for Psoriasis")
Usually there is more than one instance for a drug with different doses or time-points in the Cmap gene set. heatmapCmap
can merge the multi-instance results based on parameter mergeMethod (“mean” or “max”). Figure 6 shows the multi-instance merged results ordered by the 7th cluster.
heatmapCmap(cmapDn100_cogena_result, "pam", "10", printGS=FALSE,
orderMethod = "7", maintitle="Drug repositioning for Psoriasis")
## Warning: `funs()` was deprecated in dplyr 0.8.0.
## ℹ Please use a list of either functions or lambdas:
##
## # Simple named list: list(mean = mean, median = median)
##
## # Auto named with `tibble::lst()`: tibble::lst(mean, median)
##
## # Using lambdas list(~ mean(., trim = .2), ~ median(., na.rm = TRUE))
## ℹ The deprecated feature was likely used in the cogena package.
## Please report the issue at <https://github.com/zhilongjia/cogena/issues>.
## Warning: Vectorized input to `element_text()` is not officially supported.
## Results may be unexpected or may change in future versions of ggplot2.
The user can obtain the genes in a certain cluster via geneInCluster
, enabling other analyses, such as drug target identification.
# Always make the number as character, please!
geneC <- geneInCluster(clen_res, "pam", "10", "4")
head(geneC)
## [1] "CD47" "SERPINB13" "PNP" "MPZL2" "KCNJ15" "SOX7"
It can be obtained by geneExpInCluster
. There are two items, clusterGeneExp
and label
, in the returned object of geneExpInCluster
. It can be used for other application.
# Always make the number as character, please!
gec <- geneExpInCluster(clen_res, "pam", "10")
gec$clusterGeneExp[1:3, 1:4]
## cluster_id GSM337261 GSM337262 GSM337263
## PI3 1 6.556556 6.040479 7.033708
## S100A7A 1 4.989918 4.971686 5.677227
## S100A12 1 4.873823 5.168421 5.255036
gec$label[1:4]
## GSM337261 GSM337262 GSM337263 GSM337264
## ct ct ct ct
## Levels: ct Psoriasis
The correlation among a cluster can be checked and visulised by corInCluster
. See Figure 4.
# Always make the number as character, please!
corInCluster(clen_res, "pam", "10", "10")
System info
## R version 4.2.1 (2022-06-23)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 20.04.5 LTS
##
## Matrix products: default
## BLAS: /home/biocbuild/bbs-3.16-bioc/R/lib/libRblas.so
## LAPACK: /home/biocbuild/bbs-3.16-bioc/R/lib/libRlapack.so
##
## locale:
## [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=en_GB LC_COLLATE=C
## [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
## [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] cogena_1.32.0 kohonen_3.0.11 ggplot2_3.3.6 cluster_2.1.4
##
## loaded via a namespace (and not attached):
## [1] bitops_1.0-7 fs_1.5.2 usethis_2.1.6
## [4] devtools_2.4.5 doParallel_1.0.17 rprojroot_2.0.3
## [7] tools_4.2.1 profvis_0.3.7 bslib_0.4.0
## [10] utf8_1.2.2 R6_2.5.1 KernSmooth_2.23-20
## [13] DBI_1.1.3 BiocGenerics_0.44.0 colorspace_2.0-3
## [16] urlchecker_1.0.1 withr_2.5.0 tidyselect_1.2.0
## [19] prettyunits_1.1.1 processx_3.8.0 compiler_4.2.1
## [22] biwt_1.0.1 cli_3.4.1 Biobase_2.58.0
## [25] desc_1.4.2 labeling_0.4.2 sass_0.4.2
## [28] caTools_1.18.2 scales_1.2.1 DEoptimR_1.0-11
## [31] robustbase_0.95-0 callr_3.7.2 stringr_1.4.1
## [34] apcluster_1.4.10 digest_0.6.30 rmarkdown_2.17
## [37] pkgconfig_2.0.3 htmltools_0.5.3 sessioninfo_1.2.2
## [40] highr_0.9 fastmap_1.1.0 htmlwidgets_1.5.4
## [43] rlang_1.0.6 rstudioapi_0.14 shiny_1.7.3
## [46] farver_2.1.1 jquerylib_0.1.4 generics_0.1.3
## [49] jsonlite_1.8.3 mclust_6.0.0 gtools_3.9.3
## [52] dplyr_1.0.10 magrittr_2.0.3 Matrix_1.5-1
## [55] Rcpp_1.0.9 munsell_0.5.0 fansi_1.0.3
## [58] lifecycle_1.0.3 stringi_1.7.8 yaml_2.3.6
## [61] MASS_7.3-58.1 plyr_1.8.7 pkgbuild_1.3.1
## [64] gplots_3.1.3 grid_4.2.1 parallel_4.2.1
## [67] promises_1.2.0.1 crayon_1.5.2 miniUI_0.1.1.1
## [70] lattice_0.20-45 knitr_1.40 ps_1.7.2
## [73] pillar_1.8.1 fastcluster_1.2.3 reshape2_1.4.4
## [76] codetools_0.2-18 pkgload_1.3.1 glue_1.6.2
## [79] evaluate_0.17 remotes_2.4.2 vctrs_0.5.0
## [82] httpuv_1.6.6 foreach_1.5.2 tidyr_1.2.1
## [85] gtable_0.3.1 purrr_0.3.5 amap_0.8-19
## [88] assertthat_0.2.1 cachem_1.0.6 xfun_0.34
## [91] mime_0.12 xtable_1.8-4 later_1.3.0
## [94] class_7.3-20 tibble_3.1.8 iterators_1.0.14
## [97] memoise_2.0.1 corrplot_0.92 ellipsis_0.3.2