Calculate kBET scores
calculate_kbet_sc.RdThis function calculates the k-nearest neighbour batch-effect test (kBET). Briefly, the function leverages a Chi-Square statistic to calculate the differences in batch proportions observed in the neighbourhood of a given cell with the overall batch proportions. If the test is significant for that cell it indicates poor mixing for that cell specifically. Large number of positive tests indicate bad mixing overall. For more details, please see Büttner et al.
Value
A KbetScores object with the following elements
kbet_score - Proportion of significant tests over all cells. 0 indicates perfect mixing, 1 indicates no mixing between batches.
significant_tests - Logical vector indicating for which cells the test was below the threshold.
p_values - The p-values from the Chi-Square test.
chi_square_stats - Per-cell Chi-Square statistics.
mean_chi_square - Mean Chi-Square statistic across all cells.
median_chi_square - Median Chi-Square statistic across all cells.
threshold - The significance threshold used.
n_batches - Number of batches in the data.