Skip to contents

Computes 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.

Usage

EntropyScore(mat, meta, covariates = NULL)

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 if covariates is provided.

covariates

Optional character vector of column names in meta specifying 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 by log2(n_states).

  • entropy_corrected (if covariates given): residual entropy score with covariates regressed out.

Details

For each cell:

  1. Convert counts to per-cell fractions with pseudocount.

  2. Compute Shannon entropy of the fraction vector (entropy::entropy(p, unit="log2")).

  3. 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.