Compute a imbalance score to show whether nearby cells have the same condition of not

imbalance_score(Object, ...)

# S4 method for matrix
imbalance_score(Object, conditions, k = 10, smooth = 10)

# S4 method for SingleCellExperiment
imbalance_score(Object, dimred = 1, conditions, k = 10, smooth = 10)

Arguments

Object

A SingleCellExperiment object or a matrix representing the reduced dimension matrix of the cells.

...

parameters including:

conditions

Either the vector of conditions, or a character indicating which column of the metadata contains this vector

k

The number of neighbors to consider when computing the score. Default to 10.

smooth

The smoothing parameter. Default to k. Lower values mean that we smooth more.

dimred

A string or integer scalar indicating the reduced dimension result in reducedDims(sce) to plot. Default to 1.

Value

Either a list with the scaled_scores and the scores for each cell, if input is a matrix, or the SingleCellExperiment object, wit this list in the colData.

Examples

data("toy_dataset") scores <- imbalance_score(as.matrix(toy_dataset$sd[,1:2]), toy_dataset$sd$conditions, k = 4) cols <- as.numeric(cut(scores$scaled_scores, 8)) plot(as.matrix(toy_dataset$sd[, 1:2]), xlab = "Dim1", ylab = "Dim2", pch = 16, col = RColorBrewer::brewer.pal(8, "Blues")[cols])