View source: R/utility_functions.R
getJaccard | R Documentation |
Computes Jaccard Similarity between two sets, x1 and x2.
getJaccard(x1, x2, assert.unique = T)
x1 |
set 1 |
x2 |
set 2 |
assert.unique |
Logical flag specifying whether to ensure that x1 and x2 are unique. Default is TRUE. |
Jaccard similarity score (numeric)
pheatmap
# compute jaccard similarity matrix for (named) list of genesets.
n.sets <- length(gene.sets)
j.mat <- matrix(nrow = n.sets, ncol = n.sets)
for (i in 1:n.sets){
for (j in 1:n.sets){
i.name <- names(gene.sets)[i]
j.name <- names(gene.sets)[j]
j.mat[i, j] <- getJaccard(gene.sets[[i.name]], gene.sets[[j.name]])
}
}
# assign row and col names
rownames(j.mat) <- names(gene.sets)
colnames(j.mat) <- names(gene.sets)
# generate heatmap
pheatmap::pheatmap(j.mat, show_colnames = F, main = "Jaccard Similarity")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.