Skip to contents

Calculates k-Nearest Neighbor conditional Density Resampled Estimate of Mutual Information as defined in van Dijk et al, 2018.

Usage

knnDREMI(
  x,
  y,
  k = 10,
  n_bins = 20,
  n_mesh = 3,
  n_jobs = 1,
  plot = FALSE,
  return_drevi = FALSE,
  ...
)

Arguments

x

Numeric vector. Independent variable (gene X).

y

Numeric vector. Dependent variable (gene Y).

k

Integer. Number of nearest neighbors. Default is 10.

n_bins

Integer. Number of bins for density resampling. Default is 20.

n_mesh

Integer. Mesh density within bins. Default is 3.

n_jobs

Integer. Number of parallel workers (not used in R). Default is 1.

plot

Logical. Create diagnostic plots. Default is FALSE.

return_drevi

Logical. Also return DREVI density matrix. Default is FALSE.

...

Additional arguments passed to plot function.

Value

If return_drevi is FALSE, returns the DREMI value (numeric). If return_drevi is TRUE, returns a list with dremi and drevi (density matrix).

Details

kNN-DREMI is an adaptation of DREMI (Krishnaswamy et al. 2014) for single cell RNA-sequencing data. DREMI captures the functional relationship between two genes across their entire dynamic range. The key change to kNN-DREMI is the replacement of the heat diffusion-based kernel-density estimator by a k-nearest neighbor-based density estimator.

Note: kNN-DREMI, like Mutual Information and DREMI, is not symmetric. Here we are estimating I(Y|X).

This implementation follows exactly the scprep Python implementation.

References

van Dijk, D., et al. (2018). Recovering gene interactions from single-cell data using data diffusion. Cell, 174(3), 716-729. doi:10.1016/j.cell.2018.05.061

Krishnaswamy, S., et al. (2014). Conditional density-based analysis of T cell signaling in single-cell data. Science, 346(6213), 1250689.

Examples

if (FALSE) { # \dontrun{
# After running MAGIC
result <- magic(data, t = 3)
imputed <- as.matrix(result)

# Compute kNN-DREMI between two genes
dremi <- knnDREMI(imputed[, "GeneA"], imputed[, "GeneB"])

# With diagnostic plot
dremi <- knnDREMI(imputed[, "GeneA"], imputed[, "GeneB"], plot = TRUE)
} # }