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

A unified method for differential accessibility analysis.

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

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] | NoneUnion[Sequence[int], Sequence[bool], 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] | NoneUnion[Sequence[int], Sequence[bool], 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.05)

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.

two_sided : boolbool (default: True)

Whether to perform a two-sided test, or a one-sided test.


Keyword args for scvi.model.base.DifferentialComputation.get_bayes_factors()

Return type



Differential accessibility DataFrame with the following columns: prob_da

the probability of the region being differentially accessible


whether the region passes a multiple hypothesis correction procedure with the target_fdr threshold


Bayes Factor indicating the level of significance of the analysis


the effect size, computed as (accessibility in population 2) - (accessibility in population 1)


the empirical effect, based on observed detection rates instead of the estimated accessibility scores from the PeakVI model


the estimated probability of accessibility in population 1


the estimated probability of accessibility in population 2


the empirical (observed) probability of accessibility in population 1


the empirical (observed) probability of accessibility in population 2