delnx.tl.nb_testΒΆ
- delnx.tl.nb_test(adata, fit, contrast=None, reduced_design=None, multitest_method='fdr_bh', lfc_threshold=0.0, batch_size=512)[source]ΒΆ
Test for differential expression using quasi-likelihood F-test.
- Parameters:
adata (
AnnData) β AnnData object (same one passed tonb_fit()).fit (
NBFitResult) β Fitted model fromnb_fit().contrast (
str|int|None(default:None)) βCoefficient to test. Supports shorthand:
Level name:
"drugA"(resolved viacondition_key).Bracket shorthand:
"treatment[drugA]"(for multi-covariate models).Full patsy name:
"treatment[T.drugA]"(always works).Integer index or None (last coefficient).
None: Test last coefficient.
reduced_design (
ndarray|None(default:None)) β Reduced design matrix for likelihood ratio test. If None, automatically created by dropping the tested coefficient.multitest_method (
str(default:'fdr_bh')) β Method for multiple testing correction.lfc_threshold (
float(default:0.0)) β Threshold for log2 fold change filtering.batch_size (
int(default:512)) β Number of genes to process in each batch. Controls GPU memory usage for the reduced model refit.
- Return type:
DataFrame- Returns:
pd.DataFrame Results with columns:
feature: Gene/feature nameslog2fc: Log2 fold changecoef: Model coefficientstat: F-statisticpval: Raw p-valuepadj: Adjusted p-value
Examples
Test for treatment effect:
>>> fit = dx.tl.nb_fit(adata, condition_key="treatment") >>> results = dx.tl.nb_test(adata, fit)
Test specific contrast by name:
>>> results = dx.tl.nb_test(adata, fit, contrast="treatmentB")