In the mosbi
package, similarities between biclusters are
computed using different possible similarity metrics.
This vignette gives an overview about the implemented metrics.
library(mosbi)
The following similarity metrics are currently implemented:
Bray-Curtis similarity (Wikipedia)
Jaccard index (Wikipedia)
overlap coefficient (Wikipedia)
Fowlkes–Mallows index (Wikipedia)
# Bray-Curtis similarity
bray_curtis <- function(s1, s2, overlap) {
return(((2 * overlap) / (s1 + s2)))
}
# Jaccard index
jaccard <- function(s1, s2, overlap) {
return(((overlap) / (s1 + s2 - overlap)))
}
# overlap coefficient
overlap <- function(s1, s2, overlap) {
return((overlap / min(s1, s2)))
}
# Fowlkes–Mallows index
folkes_mallows <- function(s1, s2, overlap) {
tp <- choose(overlap, 2)
fp <- choose(s1 - overlap, 2)
fn <- choose(s2 - overlap, 2)
return(sqrt((tp / (tp + fp)) * (tp / (tp + fn))))
}
The behavior of the similarity metrics will be evaluated for two scenarios:
Two biclusters of the same size with an increasing overlap.
Two biclusters of different sizes (One twice as big as the other) with an increasing overlap.
# Scenario 1 - two biclusters of the same size
size1_1 <- rep(1000, 1000)
size2_1 <- rep(1000, 1000)
overlap_1 <- seq(1, 1000)
# Scenario 2 - two biclusters one of size 500, the other of size 1000
size1_2 <- rep(1000, 500)
size2_2 <- rep(500, 500)
overlap_2 <- seq(1, 500)
Two biclusters of the same size:
plot(overlap_1, bray_curtis(size1_1, size2_1, overlap_1),
col = "red", type = "l", xlab = "Overlap", ylab = "Similarity",
ylim = c(0, 1)
)
lines(overlap_1, jaccard(size1_1, size2_1, overlap_1), col = "blue")
lines(overlap_1, overlap(size1_1, size2_1, overlap_1), col = "green", lty = 2)
lines(overlap_1, folkes_mallows(size1_1, size2_1, overlap_1), col = "orange")
legend(
x = .8, legend = c("Bray-Curtis", "Jaccard", "Overlap", "Fowlkes–Mallows"),
col = c("red", "blue", "green", "orange"),
lty = 1, cex = 0.8, title = "Similarity metrics"
)
Two biclusters of different sizes:
plot(overlap_2, bray_curtis(size1_2, size2_2, overlap_2),
col = "red", type = "l", xlab = "Overlap", ylab = "Similarity",
ylim = c(0, 1)
)
lines(overlap_2, jaccard(size1_2, size2_2, overlap_2), col = "blue")
lines(overlap_2, overlap(size1_2, size2_2, overlap_2), col = "green")
lines(overlap_2, folkes_mallows(size1_2, size2_2, overlap_2), col = "orange")
legend(
x = .8, legend = c("Bray-Curtis", "Jaccard", "Overlap", "Fowlkes–Mallows"),
col = c("red", "blue", "green", "orange"),
lty = 1, cex = 0.8, title = "Similarity metrics"
)
sessionInfo()
#> R version 4.1.2 (2021-11-01)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 20.04.3 LTS
#>
#> Matrix products: default
#> BLAS: /home/biocbuild/bbs-3.14-bioc/R/lib/libRblas.so
#> LAPACK: /home/biocbuild/bbs-3.14-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] mosbi_1.0.3 BiocStyle_2.22.0
#>
#> loaded via a namespace (and not attached):
#> [1] tidyselect_1.1.1 modeltools_0.2-23 xfun_0.29
#> [4] bslib_0.3.1 purrr_0.3.4 lattice_0.20-45
#> [7] flexclust_1.4-0 generics_0.1.1 colorspace_2.0-2
#> [10] vctrs_0.3.8 htmltools_0.5.2 stats4_4.1.2
#> [13] yaml_2.2.1 utf8_1.2.2 rlang_0.4.12
#> [16] jquerylib_0.1.4 pillar_1.6.4 DBI_1.1.2
#> [19] glue_1.6.0 BiocGenerics_0.40.0 RColorBrewer_1.1-2
#> [22] QUBIC_1.22.0 lifecycle_1.0.1 stringr_1.4.0
#> [25] munsell_0.5.0 gtable_0.3.0 evaluate_0.14
#> [28] Biobase_2.54.0 knitr_1.37 fastmap_1.1.0
#> [31] parallel_4.1.2 class_7.3-19 fansi_0.5.0
#> [34] biclust_2.0.3 highr_0.9 Rcpp_1.0.7
#> [37] scales_1.1.1 BiocManager_1.30.16 additivityTests_1.1-4
#> [40] RcppParallel_5.1.5 magick_2.7.3 jsonlite_1.7.2
#> [43] fabia_2.40.0 ggplot2_3.3.5 digest_0.6.29
#> [46] stringi_1.7.6 bookdown_0.24 dplyr_1.0.7
#> [49] grid_4.1.2 BH_1.78.0-0 tools_4.1.2
#> [52] magrittr_2.0.1 sass_0.4.0 tibble_3.1.6
#> [55] tidyr_1.1.4 crayon_1.4.2 isa2_0.3.5
#> [58] pkgconfig_2.0.3 MASS_7.3-54 ellipsis_0.3.2
#> [61] assertthat_0.2.1 rmarkdown_2.11 R6_2.5.1
#> [64] igraph_1.2.11 compiler_4.1.2