Function to calculate pair-wise semantic similarity between genes based on a direct acyclic graph (DAG) with annotated data

Description

dDAGgeneSim is supposed to calculate pair-wise semantic similarity between genes based on a direct acyclic graph (DAG) with annotated data. It first calculates semantic similarity between terms and then derives semantic similarity between genes from terms-term semantic similarity. Parallel computing is also supported for Linux or Mac operating systems.

Usage

dDAGgeneSim(g, genes = NULL, method.gene = c("BM.average", "BM.max", "BM.complete", 
  "average", "max"), method.term = c("Resnik", "Lin", "Schlicker", "Jiang", "Pesquita"), 
      force = TRUE, fast = TRUE, parallel = TRUE, multicores = NULL, verbose = TRUE)

Arguments

g
an object of class "igraph" or "graphNEL". It must contain a vertex attribute called 'annotations' for storing annotation data (see example for howto)
genes
the genes between which pair-wise semantic similarity is calculated. If NULL, all genes annotatable in the input dag will be used for calculation, which is very prohibitively expensive!
method.gene
the method used for how to derive semantic similarity between genes from semantic similarity between terms. It can be "average" for average similarity between any two terms (one from gene 1, the other from gene 2), "max" for the maximum similarity between any two terms, "BM.average" for best-matching (BM) based average similarity (i.e. for each term of either gene, first calculate maximum similarity to any term in the other gene, then take average of maximum similarity; the final BM-based average similiary is the pre-calculated average between two genes in pair), "BM.max" for BM based maximum similarity (i.e. the same as "BM.average", but the final BM-based maximum similiary is the maximum of the pre-calculated average between two genes in pair), "BM.complete" for BM-based complete-linkage similarity (inspired by complete-linkage concept: the least of any maximum similarity between a term of one gene and a term of the other gene). When comparing BM-based similarity between genes, "BM.average" and "BM.max" are sensitive to the number of terms invovled; instead, "BM.complete" is much robust in this aspect. By default, it uses "BM.average".
method.term
the method used to measure semantic similarity between terms. It can be "Resnik" for information content (IC) of most informative common ancestor (MICA) (see http://arxiv.org/pdf/cmp-lg/9511007.pdf), "Lin" for 2*IC at MICA divided by the sum of IC at pairs of terms (see https://www.cse.iitb.ac.in/~cs626-449/Papers/WordSimilarity/3.pdf), "Schlicker" for weighted version of 'Lin' by the 1-prob(MICA) (see http://www.ncbi.nlm.nih.gov/pubmed/16776819), "Jiang" for 1 - difference between the sum of IC at pairs of terms and 2*IC at MICA (see http://arxiv.org/pdf/cmp-lg/9709008.pdf), "Pesquita" for graph information content similarity related to Tanimoto-Jacard index (ie. summed information content of common ancestors divided by summed information content of all ancestors of term1 and term2 (see http://www.ncbi.nlm.nih.gov/pubmed/18460186))
force
logical to indicate whether the only most specific terms (for each gene) will be used. By default, it sets to true. It is always advisable to use this since it is computationally fast but without compromising accuracy (considering the fact that true-path-rule has been applied when running dDAGannotate)
fast
logical to indicate whether a vectorised fast computation is used. By default, it sets to true. It is always advisable to use this vectorised fast computation; since the conventional computation is just used for understanding scripts
parallel
logical to indicate whether parallel computation with multicores is used. By default, it sets to true, but not necessarily does so. It will depend on whether these two packages "foreach" and "doParallel" have been installed. It can be installed via: source("http://bioconductor.org/biocLite.R"); biocLite(c("foreach","doParallel")). If not yet installed, this option will be disabled
multicores
an integer to specify how many cores will be registered as the multicore parallel backend to the 'foreach' package. If NULL, it will use a half of cores available in a user's computer. This option only works when parallel computation is enabled
verbose
logical to indicate whether the messages will be displayed in the screen. By default, it sets to true for display

Value

It returns a sparse matrix containing pair-wise semantic similarity between input genes. This sparse matrix can be converted to the full matrix via the function as.matrix

Note

For the mode "shortest_paths", the induced subgraph is the most concise, and thus informative for visualisation when there are many nodes in query, while the mode "all_paths" results in the complete subgraph.

Examples

# 1) load HPPA as igraph object ig.HPPA <-dRDataLoader(RData='ig.HPPA')
'ig.HPPA' (from package 'dnet' version 1.0.11) has been loaded into the working environment (at 2017-03-27 19:53:41)
g <- ig.HPPA # 2) load human genes annotated by HPPA org.Hs.egHPPA <- dRDataLoader(RData='org.Hs.egHPPA')
'org.Hs.egHPPA' (from package 'dnet' version 1.0.11) has been loaded into the working environment (at 2017-03-27 19:53:41)
# 3) prepare for ontology and its annotation information dag <- dDAGannotate(g, annotations=org.Hs.egHPPA, path.mode="all_paths", verbose=TRUE)
At level 13, there are 5 nodes, and 12 incoming neighbors. At level 12, there are 17 nodes, and 27 incoming neighbors. At level 11, there are 50 nodes, and 65 incoming neighbors. At level 10, there are 144 nodes, and 145 incoming neighbors. At level 9, there are 332 nodes, and 282 incoming neighbors. At level 8, there are 518 nodes, and 374 incoming neighbors. At level 7, there are 625 nodes, and 389 incoming neighbors. At level 6, there are 710 nodes, and 382 incoming neighbors. At level 5, there are 587 nodes, and 232 incoming neighbors. At level 4, there are 297 nodes, and 91 incoming neighbors. At level 3, there are 105 nodes, and 23 incoming neighbors. At level 2, there are 23 nodes, and 1 incoming neighbors. At level 1, there are 1 nodes, and 0 incoming neighbors.
# 4) calculate pair-wise semantic similarity between 5 randomly chosen genes allgenes <- unique(unlist(V(dag)$annotations)) genes <- sample(allgenes,5) sim <- dDAGgeneSim(g=dag, genes=genes, method.gene="BM.average", method.term="Resnik", parallel=FALSE, verbose=TRUE)
Start at 2017-03-27 19:54:00 First, extract all annotatable genes (2017-03-27 19:54:00)... there are 5 input genes amongst 3226 annotatable genes Second, pre-compute semantic similarity between 120 terms (forced to be the most specific for each gene) using Resnik method (2017-03-27 19:54:02)... Last, calculate pair-wise semantic similarity between 5 genes using BM.average method (2017-03-27 19:54:04)... 1 out of 5 (2017-03-27 19:54:04) 2 out of 5 (2017-03-27 19:54:04) 3 out of 5 (2017-03-27 19:54:04) 4 out of 5 (2017-03-27 19:54:04) Finish at 2017-03-27 19:54:04 Runtime in total is: 4 secs
sim
5 x 5 sparse Matrix of class "dgCMatrix" 10484 6521 128674 124454 4308 10484 . 0.24999002 0.7144068 0.3097743 0.29595544 6521 0.2499900 . 0.3258604 0.4471606 0.08989818 128674 0.7144068 0.32586044 . 0.4661203 0.41865267 124454 0.3097743 0.44716055 0.4661203 . 0.24577978 4308 0.2959554 0.08989818 0.4186527 0.2457798 .