scvi.model.base.RNASeqMixin.differential_expression

RNASeqMixin.differential_expression(adata=None, groupby=None, group1=None, group2=None, idx1=None, idx2=None, mode='change', delta=0.25, batch_size=None, all_stats=True, batch_correction=False, batchid1=None, batchid2=None, fdr_target=0.05, silent=False, **kwargs)[source]

A unified method for differential expression analysis.

Implements “vanilla” DE [Lopez18] and “change” mode DE [Boyeau19].

Parameters
adata : AnnData | NoneOptional[AnnData] (default: None)

AnnData object with equivalent structure to initial AnnData. If None, defaults to the AnnData object used to initialize the model.

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

The key of the observations grouping to consider.

group1 : Iterable[str] | NoneOptional[Iterable[str]] (default: None)

Subset of groups, e.g. [‘g1’, ‘g2’, ‘g3’], to which comparison shall be restricted, or all groups in groupby (default).

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

If None, compare each group in group1 to the union of the rest of the groups in groupby. If a group identifier, compare with respect to this group.

idx1 : Sequence[int] | Sequence[bool] | str | NoneUnion[Sequence[int], Sequence[bool], str, None] (default: None)

idx1 and idx2 can be used as an alternative to the AnnData keys. Custom identifier for group1 that can be of three sorts: (1) a boolean mask, (2) indices, or (3) a string. If it is a string, then it will query indices that verifies conditions on adata.obs, as described in pandas.DataFrame.query() If idx1 is not None, this option overrides group1 and group2.

idx2 : Sequence[int] | Sequence[bool] | str | NoneUnion[Sequence[int], Sequence[bool], str, None] (default: None)

Custom identifier for group2 that has the same properties as idx1. By default, includes all cells not specified in idx1.

mode : {‘vanilla’, ‘change’}Literal[‘vanilla’, ‘change’] (default: 'change')

Method for differential expression. See user guide for full explanation.

delta : floatfloat (default: 0.25)

specific case of region inducing differential expression. In this case, we suppose that \(R \setminus [-\delta, \delta]\) does not induce differential expression (change model default case).

batch_size : int | NoneOptional[int] (default: None)

Minibatch size for data loading into model. Defaults to scvi.settings.batch_size.

all_stats : boolbool (default: True)

Concatenate count statistics (e.g., mean expression group 1) to DE results.

batch_correction : boolbool (default: False)

Whether to correct for batch effects in DE inference.

batchid1 : Iterable[str] | NoneOptional[Iterable[str]] (default: None)

Subset of categories from batch_key registered in setup_anndata(), e.g. [‘batch1’, ‘batch2’, ‘batch3’], for group1. Only used if batch_correction is True, and by default all categories are used.

batchid2 : Iterable[str] | NoneOptional[Iterable[str]] (default: None)

Same as batchid1 for group2. batchid2 must either have null intersection with batchid1, or be exactly equal to batchid1. When the two sets are exactly equal, cells are compared by decoding on the same batch. When sets have null intersection, cells from group1 and group2 are decoded on each group in group1 and group2, respectively.

fdr_target : floatfloat (default: 0.05)

Tag features as DE based on posterior expected false discovery rate.

silent : boolbool (default: False)

If True, disables the progress bar. Default: False.

**kwargs

Keyword args for scvi.utils.DifferentialComputation.get_bayes_factors()

Return type

DataFrameDataFrame

Returns

Differential expression DataFrame.