scib.metrics.trajectory_conservation
- scib.metrics.trajectory_conservation(adata_pre, adata_post, label_key, pseudotime_key='dpt_pseudotime', batch_key=None)
Trajectory conservation score
Trajectory conservation is measured by spearman’s rank correlation coefficient \(s\), between the pseudotime values before and after integration. The final score was scaled to a value between 0 and 1 using the equation
\[trajectory \, conservation = \frac {s + 1} {2}\]- Parameters:
adata_pre – unintegrated adata
adata_post – integrated adata
label_key – column in
adata_pre.obs
of the groups used to precompute the trajectorypseudotime_key – column in
adata_pre.obs
in which the pseudotime is saved in. Column can contain empty entries, the dataset will be subset to the cells with scores.batch_key – set to batch key if you want to compute the trajectory metric by batch. By default the batch information will be ignored (
batch_key=None
)
This function requires pseudotime values in
.obs
of the unintegrated object (adata_pre
) computed per batch and can be applied to all integration output types. The input trajectories should be curated manually as the quality of the metric depends on the quality of the metric depends on the quality of the annotation. The integrated object (adata_post
) needs to have a kNN graph based on the integration output. See User Guide for more information on preprocessing.Examples
# feature output scib.pp.reduce_data( adata, n_top_genes=2000, batch_key="batch", pca=True, neighbors=True ) scib.me.trajectory_conservation(adata_unintegrated, adata, label_key="cell_type") # embedding output sc.pp.neighbors(adata, use_rep="X_emb") scib.me.trajectory_conservation(adata_unintegrated, adata, label_key="celltype") # knn output scib.me.trajectory_conservation(adata_unintegrated, adata, label_key="celltype")