scFates.tl.test_covariate

scFates.tl.test_covariate(adata, group_key, features=None, seg=None, layer=None, trend_test=False, fdr_cut=0.01, n_jobs=1, n_map=1, copy=False)

Test for branch differential gene expression between covariates on the same trajectory path.

Test of amplitude difference

The same is used as in scFates.tl.test_fork(). This uses the following model :

\(g_{i} \sim\ s(pseudotime)+s(pseudotime):Covariate+Covariate\)

Where \(s(.)\) denotes the penalized regression spline function and \(s(pseudotime):Covariate\) denotes interaction between the smoothed pseudotime and covariate terms. From this interaction term, the p-value is extracted.

Test of trend difference

Inspired from a preprint [Ji22], this test compares the following full model:

\(g_{i} \sim\ s(pseudotime)+s(pseudotime):Covariate+Covariate\)

to the following reduced one:

\(g_{i} \sim\ s(pseudotime)+s(pseudotime)+Covariate\)

Comparison is done using ANOVA

Parameters
adata : AnnData

Annotated data matrix.

group_key : str

key in .obs for the covariates to test.

features : Iterable | NoneOptional[Iterable] (default: None)

Which features to test (all significants by default).

seg : str | NoneOptional[str] (default: None)

In the case of a tree, which segment to use for such test.

layer : str | NoneOptional[str] (default: None)

layer to use for the test

trend_test : bool (default: False)

Whether to perform the trend test instead of amplitude test.

n_jobs : int (default: 1)

number of cpu processes used to perform the test.

n_map : int (default: 1)

number of cell mappings from which to do the test (not implemented yet).

copy : bool (default: False)

Return a copy instead of writing to adata.

Returns

adata – if copy=True it returns or else add fields to adata:

.var[‘cov_pval’ or ‘covtrend_pval’]

pvalues extracted from tests.

.var[‘cov_fdr’ or ‘covtrend_fdr’]

FDR extracted from the pvalues.

.var[‘cov_signi’ or ‘covtrend_signi’]

is the feature significant.

.var[‘A->B_lfc’]

logfoldchange in expression between covariate A and B.

Return type

anndata.AnnData