dim_dist: Calculate the distance between a subset of cells in a...

Description Usage Arguments Value Examples

View source: R/dim_dist.R

Description

Calculate the distance between a subset of cells in a high-dimensional embedding

Usage

1
2
3
4
5
6
7
8
dim_dist(
  embed_mat_x,
  embed_mat_y,
  dims_use = 1:10,
  num_cells_sample = 100,
  distance_metric = "bhatt_dist",
  random_sample = FALSE
)

Arguments

embed_mat_x

A matrix or data.frame containing high-dimensional embeddings for each cell (e.g. PCs) in condition x. Assumes cells are in rows and embedding dimensions are in columns.

embed_mat_y

A matrix or data.frame containing high-dimensional embeddings for each cell (e.g. PCs) in condition y. Assumes cells are in rows and embedding dimensions are in columns.

dims_use

Dimensions of the high-dimensional embeddings to use for calculating the distance. Defaults to 10 dimensions.

num_cells_sample

Number of cells to subset from the overall embedding matrices. Defaults to 100 cells.

distance_metric

Distance metric to calculate distances between cells. Defaults to "bhatt_dist", that is the Bhattacharyya, which is currently the only high dimensional distance metric implemented.

random_sample

Whether to sample cells from each condition or to sample cells irrespective of condition to calculate a background distribution. Defaults to random_sample=FALSE to calculate a background distribution.

Value

A numeric distance value.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# Generate two matrices of 1000 cells each with different distributions
set.seed("0222")

mat1 <- matrix(data=rnorm(100000,mean=1,sd=1),nrow=2000,ncol=50)
mat2 <- matrix(data=rnorm(100000,mean=2,sd=1),nrow=2000,ncol=50)
mat3 <- matrix(data=rnorm(100000,mean=3,sd=1),nrow=2000,ncol=50)
dim_dist(embed_mat_x=mat1,embed_mat_y=mat2,dims_use=1:10,num_cells_sample=100,random_sample=FALSE)
dim_dist(embed_mat_x=mat1,embed_mat_y=mat2,dims_use=1:10,num_cells_sample=100,random_sample=TRUE)
dim_dist(embed_mat_x=mat1,embed_mat_y=mat3,dims_use=1:10,num_cells_sample=100,random_sample=FALSE)
dim_dist(embed_mat_x=mat1,embed_mat_y=mat3,dims_use=1:10,num_cells_sample=100,random_sample=TRUE)

arc85/distdimscr documentation built on Dec. 19, 2021, 4:36 a.m.