scanpy.external.tl.wishbone

Contents

scanpy.external.tl.wishbone#

scanpy.external.tl.wishbone(adata, start_cell, *, branch=True, k=15, components=(1, 2, 3), num_waypoints=250)[source]#

Wishbone identifies bifurcating developmental trajectories from single-cell data [Setty et al., 2016].

Wishbone is an algorithm for positioning single cells along bifurcating developmental trajectories with high resolution. Wishbone uses multi-dimensional single-cell data, such as mass cytometry or RNA-Seq data, as input and orders cells according to their developmental progression, and it pinpoints bifurcation points by labeling each cell as pre-bifurcation or as one of two post-bifurcation cell fates.

Note

More information and bug reports here.

Parameters:
adata AnnData

Annotated data matrix.

start_cell str

Desired start cell from obs_names.

branch bool (default: True)

Use True for Wishbone and False for Wanderlust.

k int (default: 15)

Number of nearest neighbors for graph construction.

components Iterable[int] (default: (1, 2, 3))

Components to use for running Wishbone.

num_waypoints int | Collection (default: 250)

Number of waypoints to sample.

Returns:

Updates adata with the following fields:

trajectory_wishbone(adata.obs, dtype float64)

Computed trajectory positions.

branch_wishbone(adata.obs, dtype int64)

Assigned branches.

Example

>>> import scanpy.external as sce
>>> import scanpy as sc

Loading Data and Pre-processing

>>> adata = sc.datasets.pbmc3k()
>>> sc.pp.normalize_per_cell(adata)
>>> sc.pp.pca(adata)
>>> sc.tl.tsne(adata=adata, n_pcs=5, perplexity=30)
>>> sc.pp.neighbors(adata, n_pcs=15, n_neighbors=10)
>>> sc.tl.diffmap(adata, n_comps=10)

Running Wishbone Core Function

Usually, the start cell for a dataset should be chosen based on high expression of the gene of interest:

>>> sce.tl.wishbone(
...     adata=adata, start_cell='ACAAGAGACTTATC-1',
...     components=[2, 3], num_waypoints=150,
... )

Visualizing Wishbone results

>>> sc.pl.tsne(adata, color=['trajectory_wishbone', 'branch_wishbone'])
>>> markers = ['C1QA', 'PSAP', 'CD79A', 'CD79B', 'CST3', 'LYZ', 'MALAT1']
>>> sce.pl.wishbone_marker_trajectory(adata, markers, show=True)

For further demonstration of Wishbone methods and visualization please follow the notebooks in the package Wishbone_for_single_cell_RNAseq.ipynb.