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.3.1 (2023-06-16)
#> Platform: aarch64-apple-darwin20 (64-bit)
#> Running under: macOS Ventura 13.6.1
#>
#> Matrix products: default
#> BLAS: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRblas.0.dylib
#> LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0
#>
#> locale:
#> [1] C/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#>
#> time zone: America/New_York
#> tzcode source: internal
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] mosbi_1.8.0 BiocStyle_2.30.0
#>
#> loaded via a namespace (and not attached):
#> [1] tidyr_1.3.0 generics_0.1.3 sass_0.4.6
#> [4] utf8_1.2.3 class_7.3-22 lattice_0.21-8
#> [7] digest_0.6.33 magrittr_2.0.3 evaluate_0.21
#> [10] grid_4.3.1 RColorBrewer_1.1-3 bookdown_0.34
#> [13] fastmap_1.1.1 jsonlite_1.8.7 BiocManager_1.30.22
#> [16] purrr_1.0.1 fansi_1.0.4 scales_1.2.1
#> [19] modeltools_0.2-23 jquerylib_0.1.4 cli_3.6.1
#> [22] isa2_0.3.6 rlang_1.1.1 Biobase_2.62.0
#> [25] munsell_0.5.0 cachem_1.0.8 yaml_2.3.7
#> [28] tools_4.3.1 parallel_4.3.1 biclust_2.0.3.1
#> [31] dplyr_1.1.2 colorspace_2.1-0 ggplot2_3.4.2
#> [34] BiocGenerics_0.48.0 vctrs_0.6.3 R6_2.5.1
#> [37] stats4_4.3.1 lifecycle_1.0.3 magick_2.7.4
#> [40] QUBIC_1.30.0 MASS_7.3-60 pkgconfig_2.0.3
#> [43] RcppParallel_5.1.7 bslib_0.5.0 pillar_1.9.0
#> [46] gtable_0.3.3 glue_1.6.2 Rcpp_1.0.11
#> [49] tidyselect_1.2.0 xfun_0.39 tibble_3.2.1
#> [52] highr_0.10 flexclust_1.4-1 knitr_1.43
#> [55] fabia_2.48.0 igraph_1.5.0 htmltools_0.5.5
#> [58] rmarkdown_2.23 BH_1.81.0-1 compiler_4.3.1
#> [61] additivityTests_1.1-4.1