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)

Arguments

x

The first matrix

y

The second matrix

Value

Returns a matrix

Details

This will calculate the raw Jaccard index, without normalizing for the expected similarity between cells due to differences in sequencing depth.

Examples

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.0000000 0.6666667 0.0000000 0.2000000 0.5000000 #> [2,] 0.6666667 1.0000000 0.0000000 0.0000000 0.2500000 #> [3,] 0.0000000 0.0000000 1.0000000 0.3333333 0.3333333 #> [4,] 0.2000000 0.0000000 0.3333333 1.0000000 0.5000000 #> [5,] 0.5000000 0.2500000 0.3333333 0.5000000 1.0000000