Citation
If you use GOSemSim in published research, please cite:
- Yu G. Gene Ontology Semantic Similarity Analysis Using GOSemSim. In: Kidder B. (eds) Stem Cell Transcriptional Networks. Methods in Molecular Biology, 2020, 2117:207-215. Humana, New York, NY.
- Yu G#, Li F#, Qin Y, Bo X*, Wu Y and Wang S*. GOSemSim: an R package for measuring semantic similarity among GO terms and gene products. Bioinformatics. 2010, 26(7):976-978.
Introduction
Functional similarity of gene products can be estimated by controlled biological vocabularies, such as Gene Ontology (GO) and Disease Ontology (DO). GO comprises of three orthogonal ontologies, i.e. molecular function (MF), biological process (BP), and cellular component (CC).
Four methods including Resnik(Philip 1999), Jiang(Jiang and Conrath 1997), Lin(Lin 1998) and Schlicker(Schlicker et al. 2006) have been presented to determine the semantic similarity of two GO terms based on the annotation statistics of their common ancestor terms. Wang(Wang et al. 2007) proposed a method to measure the similarity based on the graph structure of GO. Each of these methods has its own advantages and weaknesses.
GOSemSim package(Yu et al. 2010) is developed to compute semantic similarity among GO terms, sets of GO terms, gene products, and gene clusters, providing five methods mentioned above. We have developed another package, DOSE(Yu et al. 2015), for measuring semantic similarity among Disease Ontology (DO) terms and gene products at disease perspective.
Semantic Similarity Measurement Based on GO
Information content-based methods
Four methods proposed by Resnik(Philip 1999), Jiang(Jiang and Conrath 1997), Lin(Lin 1998) and Schlicker(Schlicker et al. 2006) are information content (IC) based, which depend on the frequencies of two GO terms involved and that of their closest common ancestor term in a specific corpus of GO annotations. The information content of a GO term is computed by the negative log probability of the term occurring in GO corpus. A rarely used term contains a greater amount of information.
The frequency of a term t is defined as: \(p(t) = \frac{n_{t'}}{N} | t' \in \left\{t, \; children\: of\: t \right\}\)
where \(n_{t'}\) is the number of term \(t'\), and \(N\) is the total number of terms in GO corpus.
Thus the information content is defined as: \(IC(t) = -\log(p(t))\)
As GO allow multiple parents for each concept, two terms can share parents by multiple paths. IC-based methods calculate similarity of two GO terms based on the information content of their closest common ancestor term, which was also called most informative common ancestor (MICA).
Resnik method
The Resnik method is defined as: \(sim_{Resnik}(t_1,t_2) = IC(MICA)\)
Lin method
The Lin method is defined as: \(sim_{Lin}(t_1,t_2) = \frac{2IC(MICA)}{IC(t_1)+IC(t_2)}\)
Rel method
The Relevance method, which was proposed by Schlicker, combine Resnik’s and Lin’s method and is defined as: \(sim_{Rel}(t_1,t_2) = \frac{2IC(MICA)(1-p(MICA))}{IC(t_1)+IC(t_2)}\)
Jiang method
The Jiang and Conrath’s method is defined as: \(sim_{Jiang}(t_1,t_2) = 1-\min(1, IC(t_1) + IC(t_2) - 2IC(MICA))\)
Graph-based method
Graph-based methods using the topology of GO graph structure to compute semantic similarity. Formally, a GO term A can be represented as \(DAG_{A}=(A,T_{A},E_{A})\) where \(T_{A}\) is the set of GO terms in \(DAG_{A}\), including term A and all of its ancestor terms in the GO graph, and \(E_{A}\) is the set of edges connecting the GO terms in \(DAG_{A}\).
Wang method
To encode the semantic of a GO term in a measurable format to enable a quantitative comparison, Wang(Wang et al. 2007) firstly defined the semantic value of term A as the aggregate contribution of all terms in \(DAG_{A}\) to the semantics of term A, terms closer to term A in \(DAG_{A}\) contribute more to its semantics. Thus, defined the contribution of a GO term \(t\) to the semantic of GO term \(A\) as the S-value of GO term \(t\) related to term \(A\). For any of term \(t\) in \(DAG_{A}\), its S-value related to term \(A\), \(S_{A}(\textit{t})\) is defined as:
\(\left\{\begin{array}{l} S_{A}(A)=1 \\ S_{A}(\textit{t})=\max\{w_{e} \times S_{A}(\textit{t}') | \textit{t}' \in children \: of(\textit{t}) \} \; if \: \textit{t} \ne A \end{array} \right.\)
where \(w_{e}\) is the semantic contribution factor for edge \(e \in E_{A}\) linking term \(t\) with its child term \(t'\). Term \(A\) contributes to its own is defined as 1. After obtaining the S-values for all terms in \(DAG_{A}\), the semantic value of DO term A, \(SV(A)\), is calculated as:
\(SV(A)=\displaystyle\sum_{t \in T_{A}} S_{A}(t)\)
Thus given two GO terms A and B, the semantic similarity between these two terms is defined as:
\(sim_{Wang}(A, B) = \frac{\displaystyle\sum_{t \in T_{A} \cap T_{B}}{S_{A}(t) + S_{B}(t)}}{SV(A) + SV(B)}\)
where \(S_{A}(\textit{t})\) is the S-value of GO term \(t\) related to term \(A\) and \(S_{B}(\textit{t})\) is the S-value of GO term \(t\) related to term \(B\).
This method proposed by Wang(Wang et al. 2007) determines the semantic similarity of two GO terms based on both the locations of these terms in the GO graph and their relations with their ancestor terms.
Supported organisms
For IC-based methods, information of GO term is species specific. We need to calculate IC
for all GO terms of a species before we measure semantic similarity. GOSemSim support all organisms that have an OrgDb
object available.
Bioconductor have already provided OrgDb
for about 20 species, see http://bioconductor.org/packages/release/BiocViews.html#___OrgDb.
We can build query OrgDb
online via AnnotationHub. For example:
library(AnnotationHub)
hub <- AnnotationHub()
q <- query(hub, "Cricetulus")
id <- q$ah_id[length(q)]
Cgriseus <- hub[[id]]
If organism is not supported by AnnotationHub, user can use AnnotationForge to build OrgDb
.
Once we have OrgDb
, we can build annotation data needed by GOSemSim via godata
function.
User can set computeIC=FALSE
if they only want to use Wang’s method.
goSim and mgoSim function
In GOSemSim, we implemented all these IC-based and graph-based methods. goSim function calculates semantic similarity between two GO terms, while mgoSim function calculates semantic similarity between two sets of GO terms.
## [1] 0.159
## [1] 0.116
go1 = c("GO:0004022","GO:0004024","GO:0004174")
go2 = c("GO:0009055","GO:0005515")
mgoSim(go1, go2, semData=hsGO, measure="Wang", combine=NULL)
## GO:0009055 GO:0005515
## GO:0004022 0.368 0.116
## GO:0004024 0.335 0.107
## GO:0004174 0.663 0.119
## [1] 0.43
Gene Semantic Similarity Measurement
On the basis of semantic similarity between GO terms, GOSemSim can also compute semantic similarity among sets of GO terms, gene products, and gene clusters.
Suppose we have gene \(g_1\) annotated by GO terms sets \(GO_{1}=\{go_{11},go_{12} \cdots go_{1m}\}\) and \(g_2\) annotated by \(GO_{2}=\{go_{21},go_{22} \cdots go_{2n}\}\), GOSemSim implemented four methods which called max, avg, rcmax, and BMA to combine semantic similarity scores of multiple GO terms. The similarities among gene products and gene clusters which annotated by multiple GO terms were also calculated by the same combine methods mentioned above.
Combine methods
max
The max method calculates the maximum semantic similarity score over all pairs of GO terms between these two GO term sets.
\(sim_{max}(g_1, g_2) = \displaystyle\max_{1 \le i \le m, 1 \le j \le n} sim(go_{1i}, go_{2j})\)
avg
The avg calculates the average semantic similarity score over all pairs of GO terms.
\(sim_{avg}(g_1, g_2) = \frac{\displaystyle\sum_{i=1}^m\sum_{j=1}^nsim(go_{1i}, go_{2j})}{m \times n}\)
rcmax
Similarities among two sets of GO terms form a matrix, the rcmax method uses the maximum of RowScore and ColumnScore, where RowScore (or ColumnScore) is the average of maximum similarity on each row (or column).
\(sim_{rcmax}(g_1, g_2) = \max(\frac{\displaystyle\sum_{i=1}^m \max_{1 \le j \le n} sim(go_{1i}, go_{2j})}{m},\frac{\displaystyle\sum_{j=1}^n \max_{1 \le i \le m} sim(go_{1i},go_{2j})}{n})\)
BMA
The BMA method, used the Best-Match Average strategy, calculates the average of all maximum similarities on each row and column, and is defined as:
\(sim_{BMA}(g_1, g_2) = \frac{\displaystyle\sum_{1=i}^m \max_{1 \le j \le n}sim(go_{1i}, go_{2j}) + \displaystyle\sum_{1=j}^n \max_{1 \le i \le m}sim(go_{1i}, go_{2j})} {m+n}\)
geneSim and mgeneSim
In GOSemSim, we implemented geneSim to calculate semantic similarity between two gene products, and mgeneSim to calculate semantic similarity among multiple gene products.
## $geneSim
## [1] 0.149
##
## $GO1
## [1] "GO:0004364" "GO:0004464" "GO:0004602" "GO:0005515" "GO:0047485"
## [6] "GO:0050544"
##
## $GO2
## [1] "GO:0004035"
## 835 5261 241 994
## 835 1.000 0.517 0.503 0.620
## 5261 0.517 1.000 0.447 0.505
## 241 0.503 0.447 1.000 0.452
## 994 0.620 0.505 0.452 1.000
## 835 5261 241 994
## 835 0.928 0.398 0.276 0.507
## 5261 0.398 0.939 0.322 0.438
## 241 0.276 0.322 0.941 0.277
## 994 0.507 0.438 0.277 0.908
By default, godata
function use ENTREZID
as keytype, and the input ID type is ENTREZID
. User can use other ID types such as ENSEMBL
, UNIPROT
, REFSEQ
, ACCNUM
, SYMBOL
et al.
Here as an example, we use SYMBOL
as keytype
and calculate semantic similarities among several genes by using their gene symbol as input.
hsGO2 <- godata('org.Hs.eg.db', keytype = "SYMBOL", ont="MF", computeIC=FALSE)
genes <- c("CDC45", "MCM10", "CDC20", "NMU", "MMP1")
mgeneSim(genes, semData=hsGO2, measure="Wang", combine="BMA", verbose=FALSE)
## CDC45 MCM10 CDC20 NMU MMP1
## CDC45 1.000 0.813 0.594 0.544 0.116
## MCM10 0.813 1.000 0.647 0.587 0.081
## CDC20 0.594 0.647 1.000 0.730 0.100
## NMU 0.544 0.587 0.730 1.000 0.079
## MMP1 0.116 0.081 0.100 0.079 1.000
Users can also use clusterProfiler::bitr
to translate biological IDs.
clusterSim and mclusterSim
We also implemented clusterSim for calculating semantic similarity between two gene clusters and mclusterSim for calculating semantic similarities among multiple gene clusters.
gs1 <- c("835", "5261","241", "994", "514", "533")
gs2 <- c("578","582", "400", "409", "411")
clusterSim(gs1, gs2, semData=hsGO, measure="Wang", combine="BMA")
## [1] 0.611
library(org.Hs.eg.db)
x <- org.Hs.egGO
hsEG <- mappedkeys(x)
set.seed <- 123
clusters <- list(a=sample(hsEG, 20), b=sample(hsEG, 20), c=sample(hsEG, 20))
mclusterSim(clusters, semData=hsGO, measure="Wang", combine="BMA")
## a b c
## a 1.000 0.655 0.696
## b 0.655 1.000 0.640
## c 0.696 0.640 1.000
Applications
GOSemSim was cited by more than 200 papers and had been applied to many research domains, including:
- Disease or Drug analysis
- Gene/Protein functional analysis
- Protein-Protein interaction
- miRNA-mRNA interaction
- sRNA regulation
- Evolution
Find out more on https://guangchuangyu.github.io/software/GOSemSim/featuredArticles/.
GO enrichment analysis
GO enrichment analysis can be supported by our package clusterProfiler(Yu et al. 2012), which supports hypergeometric test and Gene Set Enrichment Analysis (GSEA). Enrichment results across different gene clusters can be compared using compareCluster function.
Disease Ontology Semantic and Enrichment analysis
Disease Ontology (DO) annotates human genes in the context of disease. DO is an important annotation in translating molecular findings from high-throughput data to clinical relevance. DOSE(Yu et al. 2015) supports semantic similarity computation among DO terms and genes. Enrichment analysis including hypergeometric model and GSEA are also implemented to support discovering disease associations of high-throughput biological data.
MeSH enrichment and semantic analyses
MeSH (Medical Subject Headings) is the NLM controlled vocabulary used to manually index articles for MEDLINE/PubMed. meshes supports enrichment (hypergeometric test and GSEA) and semantic similarity analyses for more than 70 species.
Need helps?
If you have questions/issues, please visit GOSemSim homepage first. Your problems are mostly documented. If you think you found a bug, please follow the guide and provide a reproducible example to be posted on github issue tracker. For questions, please post to Bioconductor support site and tag your post with GOSemSim.
For Chinese user, you can follow me on WeChat (微信).
Session Information
Here is the output of sessionInfo()
on the system on which this document was compiled:
## R version 4.0.2 (2020-06-22)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 18.04.4 LTS
##
## Matrix products: default
## BLAS: /home/biocbuild/bbs-3.11-bioc/R/lib/libRblas.so
## LAPACK: /home/biocbuild/bbs-3.11-bioc/R/lib/libRlapack.so
##
## locale:
## [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=en_US.UTF-8 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] parallel stats4 stats graphics grDevices utils datasets
## [8] methods base
##
## other attached packages:
## [1] GOSemSim_2.14.2 GO.db_3.11.4 org.Hs.eg.db_3.11.4
## [4] AnnotationDbi_1.50.3 IRanges_2.22.2 S4Vectors_0.26.1
## [7] Biobase_2.48.0 BiocGenerics_0.34.0
##
## loaded via a namespace (and not attached):
## [1] Rcpp_1.0.5 knitr_1.29 magrittr_1.5 bit_4.0.4
## [5] rlang_0.4.7 stringr_1.4.0 blob_1.2.1 tools_4.0.2
## [9] xfun_0.16 DBI_1.1.0 htmltools_0.5.0 yaml_2.2.1
## [13] bit64_4.0.5 digest_0.6.25 prettydoc_0.4.0 vctrs_0.3.4
## [17] memoise_1.1.0 evaluate_0.14 RSQLite_2.2.0 rmarkdown_2.3
## [21] stringi_1.4.6 compiler_4.0.2 pkgconfig_2.0.3
References
Jiang, Jay J., and David W. Conrath. 1997. “Semantic Similarity Based on Corpus Statistics and Lexical Taxonomy.” Proceedings of 10th International Conference on Research in Computational Linguistics. http://www.citebase.org/abstract?id=oai:arXiv.org:cmp-lg/9709008.
Lin, Dekang. 1998. “An Information-Theoretic Definition of Similarity.” In Proceedings of the 15th International Conference on Machine Learning, 296—304. https://doi.org/10.1.1.55.1832.
Philip, Resnik. 1999. “Semantic Similarity in a Taxonomy: An Information-Based Measure and Its Application to Problems of Ambiguity in Natural Language.” Journal of Artificial Intelligence Research 11:95–130.
Schlicker, Andreas, Francisco S Domingues, Jörg Rahnenführer, and Thomas Lengauer. 2006. “A New Measure for Functional Similarity of Gene Products Based on Gene Ontology.” BMC Bioinformatics 7:302. https://doi.org/1471-2105-7-302.
Wang, James Z, Zhidian Du, Rapeeporn Payattakool, Philip S Yu, and Chin-Fu Chen. 2007. “A New Method to Measure the Semantic Similarity of Go Terms.” Bioinformatics (Oxford, England) 23 (May):1274–81. https://doi.org/btm087.
Yu, Guangchuang, Fei Li, Yide Qin, Xiaochen Bo, Yibo Wu, and Shengqi Wang. 2010. “GOSemSim: An R Package for Measuring Semantic Similarity Among Go Terms and Gene Products.” Bioinformatics 26 (april):976–78. https://doi.org/10.1093/bioinformatics/btq064.
Yu, Guangchuang, Li-Gen Wang, Yanyan Han, and Qing-Yu He. 2012. “clusterProfiler: an R Package for Comparing Biological Themes Among Gene Clusters.” OMICS: A Journal of Integrative Biology 16 (5):284–87. https://doi.org/10.1089/omi.2011.0118.
Yu, Guangchuang, Li-Gen Wang, Guang-Rong Yan, and Qing-Yu He. 2015. “DOSE: An R/Bioconductor Package for Disease Ontology Semantic and Enrichment Analysis.” Bioinformatics 31 (4):608–9. https://doi.org/10.1093/bioinformatics/btu684.