bbknn.ridge_regression

bbknn.ridge_regression(adata, batch_key, confounder_key=[], chunksize=100000000.0, copy=False, **kwargs)

Perform ridge regression on scaled expression data, accepting both technical and biological categorical variables. The effect of the technical variables is removed while the effect of the biological variables is retained. This is a preprocessing step that can aid BBKNN integration (Park, 2020).

Alters the object’s .X to be the regression residuals, and creates .layers['X_explained'] with the expression explained by the technical effect.

Input

adataAnnData

Needs scaled data in .X.

batch_keylist

A list of categorical .obs columns to regress out as technical effects.

confounder_keylist, optional (default: [])

A list of categorical .obs columns to retain as biological effects.

chunksizeint, optional (default: 1e8)

How many elements of the expression matrix to process at a time. Potentially useful to manage memory use for larger datasets.

copybool, optional (default: False)

If True, return a copy instead of writing to the supplied adata.

kwargs

Any arguments to pass to Ridge.