scib.metrics.cell_cycle
- scib.metrics.cell_cycle(adata_pre, adata_post, batch_key, embed=None, agg_func=<function mean>, organism='mouse', n_comps=50, recompute_cc=True, precompute_pcr_key=None, verbose=False)
Cell cycle conservation score
Compare the variance contribution of S-phase and G2/M-phase cell cycle scores before and after integration. Cell cycle scores are computed per batch on the unintegrated data set, eliminating the batch effect confounded by the
batch_key
variable.\[CC \, conservation = 1 - \frac { |Var_{after} - Var_{before}| } {Var_{before}}\]Variance contribution is obtained through principal component regression using
pc_regression()
.- Parameters:
adata_pre – adata before integration
adata_post – adata after integration
batch_key – Batch key in
adata_post.obs
embed – Name of embedding in
adata_post.obsm
. Ifembed=None
, use the full expression matrix (adata_post.X
), otherwise use the embedding provided inadata_post.obsm[embed]
agg_func – any function that takes a list of numbers and aggregates them into a single value. If
agg_func=None
, all results will be returnedorganism – ‘mouse’ or ‘human’ for choosing cell cycle genes
n_comps – number of principle components
recompute_cc – If True, force recompute cell cycle score, otherwise use precomputed scores if available as ‘S_score’ and ‘G2M_score’ in
adata_post.obs
precompute_pcr_key – Key in adata_pre for precomputed PCR values for cell cycle scores. Ignores cell cycle scores in adata_pre if present.
- Returns:
A score between 1 and 0. The larger the score, the stronger the cell cycle variance is conserved.
The function can be computed on full corrected feature spaces and latent embeddings for both integrated and unintegrated
anndata.Anndata
objects. No preprocessing is needed, as the function will perform PCA directly on the feature or embedding space.Examples
# full feature output scib.me.cell_cycle(adata_unintegrated, adata, batch_key="batch") # embedding output scib.me.cell_cycle(adata_unintegrated, adata, batch_key="batch", embed="X_emb")