pylimma.treat
- pylimma.treat(data, fc=1.2, lfc=None, trend=False, robust=False, winsor_tail_p=(0.05, 0.1), legacy=None, upshot=False, *, span=None, key='pylimma')[source]
Moderated t-statistics relative to a log fold-change threshold.
TREAT (t-tests relative to a threshold) tests for evidence that the true log fold-change is greater than a minimum value, rather than simply testing for non-zero effect.
- Parameters:
data (AnnData or dict) – Either an AnnData object with fit results in adata.uns[key], or a dict returned by lm_fit() or contrasts_fit().
fc (float, default 1.2) – Fold-change threshold. Used if lfc is None.
lfc (float, optional) – Log2 fold-change threshold. If provided, overrides fc.
trend (bool, default False) – If True, allow prior variance to depend on mean expression.
span (float, optional) – Span for lowess smoothing when fitting the mean-variance trend. Only used when trend is True.
robust (bool, default False) – If True, use robust estimation of hyperparameters.
winsor_tail_p (tuple, default (0.05, 0.1)) – Winsorization proportions for robust estimation.
legacy (bool, optional) – If True, use the original limma hyperparameter estimation method. If False, use the newer method which handles unequal residual df better. If None (default), auto-detect.
upshot (bool, default False) – If True, use Gaussian quadrature to compute more accurate p-values when the log fold-change threshold is small. This averages the p-value over the interval [-lfc, lfc] rather than testing at the boundary.
key (str, default "pylimma") – Key for fit results in adata.uns (AnnData input only).
- Returns:
If input is dict, returns updated dict with TREAT statistics. If input is AnnData, updates adata.uns[key] in place and returns None.
- Return type:
dict or None
Notes
The key difference from e_bayes() is that TREAT computes p-values for the hypothesis |logFC| > lfc, rather than logFC != 0. This is useful when you want to find genes with biologically meaningful effect sizes.
The returned fit contains: - t: moderated t-statistics (for display, not for p-values) - p_value: p-values from TREAT test - treat_lfc: the log fold-change threshold used
Note that B-statistics (lods) are not computed by TREAT.
References
McCarthy, D. J. and Smyth, G. K. (2009). Testing significance relative to a fold-change threshold is a TREAT. Bioinformatics, 25(6), 765-771.