Finds the Jaccard similarity between rows of the two matrices. Note that the matrices must be binary, and any rows with zero total counts will result in an NaN entry that could cause problems in downstream analyses.
Jaccard(x, y)
The first matrix
The second matrix
Returns a matrix
This will calculate the raw Jaccard index, without normalizing for the expected similarity between cells due to differences in sequencing depth.
x <- matrix(data = sample(c(0, 1), size = 25, replace = TRUE), ncol = 5)
Jaccard(x = x, y = x)
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 1.0 0.6000000 0.8 0.4000000 0.4
#> [2,] 0.6 1.0000000 0.4 0.6666667 0.0
#> [3,] 0.8 0.4000000 1.0 0.5000000 0.5
#> [4,] 0.4 0.6666667 0.5 1.0000000 0.0
#> [5,] 0.4 0.0000000 0.5 0.0000000 1.0