ehrapy.preprocessing.mcar_test(adata, method='little', *, layer=None)[source]#

Statistical hypothesis test for Missing Completely At Random (MCAR).

The null hypothesis of the Little’s test is that data is Missing Completely At Random (MCAR).

We advise to use Little’s MCAR test carefully. Rejecting the null hypothesis may not always mean that data is not MCAR, nor is accepting the null hypothesis a guarantee that data is MCAR. See Schouten, R. M., & Vink, G. (2021). The Dance of the Mechanisms: How Observed Information Influences the Validity of Missingness Assumptions. Sociological Methods & Research, 50(3), 1243-1258. for a thorough discussion of missingness mechanisms.

  • adata (AnnData) – Annotated data matrix.

  • method (Literal['little', 'ttest']) – Whether to perform a chi-square test on the entire dataset (“little”) or separate t-tests for every combination of variables (“ttest”).

  • layer (str) – Layer to apply the test to. Defaults to None (current X).

Return type:

float | DataFrame


A single p-value if the Little’s test was applied or a Pandas DataFrame of the p-value of t-tests for each pair of features.