Calculate Cell-Level Chromatin State Entropy (Plasticity) Scores
Source:R/scoring.R
EntropyScore.RdComputes per-cell entropy scores from a chromatin state count matrix. This function normalizes counts to fractions and then calculates Shannon entropy for each cell to quantify the diversity of chromatin states (a proxy for epigenomic plasticity). Optionally, it can regress out covariates (e.g. sequencing depth, TSS enrichment) to return a covariate-corrected entropy score.
Arguments
- mat
A numeric matrix of chromatin state counts (rows = cells, columns = states). Typically generated by
CalculateStateMatrix().- meta
A data frame of cell-level metadata (e.g.
seurat_obj@meta.data). Required ifcovariatesis provided.- covariates
Optional character vector of column names in
metaspecifying covariates to regress out of the entropy score. Default =NULL.
Value
A data frame with:
entropy: raw Shannon entropy score per cell (in bits).entropy_norm: entropy normalized to 0–1 range by dividing bylog2(n_states).entropy_corrected(ifcovariatesgiven): residual entropy score with covariates regressed out.
Details
For each cell:
Convert counts to per-cell fractions with pseudocount.
Compute Shannon entropy of the fraction vector (
entropy::entropy(p, unit="log2")).Normalize the entropy score by dividing by
log2(n_states)(maximum possible entropy) to scale it between 0 and 1.
If covariates is supplied, a linear model is fit with the specified
covariates as predictors of the raw entropy score. The residuals from this model
are returned as the covariate-corrected entropy score.