imbalance_score.Rd
Compute an imbalance score to show whether nearby cells have the same condition of not
imbalance_score(rd, cl, k = 10, smooth = k)
rd | The reduced dimension matrix of the cells |
---|---|
cl | the vector of conditions |
k | The number of neighbours to consider when computing the score. Default to 10. |
smooth | The smoothing parameter. Default to k. Lower values mean that we smooth more. |
A list with two components:
scores
is the raw score, a vector with one value per cell.
scaled_scores
is the score after local smoothing. A vector with one value per cell.
The score is computed in two steps. First, a score is computed for
each cell. The distribution of labels among the k
-nearest- neighbours
is computed to the overall distribution for all cells. This yields a p-value
based on the multinomial distribution, which is squared to return the scores.
Then, splines are used to smooth the scores along the reduced dimension space,
with smooth
nodes. This yields the scaled_scores.