Trajectory — TSCAN (unsupervised)¶
When you do not have a supervising phenotype, TSCAN infers a trajectory from the embedding alone: cluster samples with a Gaussian mixture (BIC-selected if n_clusters=None), build a minimum spanning tree on cluster centroids, pick the longest path through the tree, and order samples along that path.
Call¶
from sampledisco.sample_trajectory.TSCAN import TSCAN
tscan_results = TSCAN(
AnnData_sample=pseudo_adata,
column="X_DR_sample",
n_clusters=None,
output_dir="sampledisco_demo_output/rna",
grouping_columns=["sev.level"],
origin=None,
pseudotime_mode="rank",
)
TSCAN now runs on the single sample embedding uns['X_DR_sample'] — the two-key
X_DR_expression / X_DR_proportion split is gone, so there is only one trajectory to compute.
TSCAN returns a results dict (clusters, MST, principal path, ordering, and pseudotime); it also
writes tscan_pseudotime_main and tscan_cluster columns back into AnnData_sample.obs.
Output¶
Writes → sampledisco_demo_output/rna/TSCAN/ ({column} is the embedding key, here X_DR_sample):
clusters_by_cluster_{column}.png— points colored by GMM cluster.clusters_by_grouping_{column}.png— points colored by each entry ingrouping_columns.{column}_pseudotime.csv— per-sample pseudotime (withtrajectory_type,branch_id, andclustercolumns for the main path and any branches).
See the API page for the full parameter list.