jaccardIndex: Compute the pairwise Jaccard index

View source: R/compute_metrics.R

jaccardIndexR Documentation

Compute the pairwise Jaccard index

Description

The function computes the Jaccard index between all pairs of cells.

Usage

jaccardIndex(object, i, by = NULL)

Arguments

object

An object of class QFeatures.

i

The index of the assay in object. The assay must contain an identification matrix, that is a matrix where an entry is TRUE if the value is observed and FALSE is the value is missing (see examples).

by

A vector of length equal to the number of columns in assay i that defines groups for which the Jaccard index should be computed separately. If missing, the Jaccard indices are computed for all airs of cells in the dataset.

Value

A data.frame with as many rows as pairs of cells and the following column(s):

  • jaccard: the computed Jaccard index

  • by: if by is not NULL, the group of the pair of cells for which the Jaccard index is computed.

Examples


data("scp1")

## Define the identification matrix
peps <- scp1[["peptides"]]
assay(peps) <- ifelse(is.na(assay(peps)), FALSE, TRUE)
scp1 <- addAssay(scp1, peps, "id")

## Compute Jaccard indices
jaccardIndex(scp1, "id")
## Compute Jaccard indices by sample type
jaccardIndex(scp1, "id", scp1$SampleType)



UCLouvain-CBIO/scp documentation built on May 5, 2024, 1:17 a.m.