API#

Datasets#

datasets.Weinreb_in_vitro

Dataset from Weinreb et al. [PMID: 31974159] with in vitro hematopoiesis.

datasets.Erickson_murine_development

Dataset from [PMID: 40502176] with clonal atlas of murine development.

datasets.Liu_NSCLC_CD8

Dataset from Liu et al. [PMID: 35121991] with CD8 T cells from NSCLC.

Preprocessing#

pp.clones_adata

Creates a clone-level AnnData object from a cell-level AnnData object.

pp.make_unique_clones

Prepares a clone2vec-friendly AnnData object by handling multiple clonal labels per cell.

pp.recalc_composition

Create a new annotated data matrix at the clone level with updated cell type proportions.

pp.transfer_annotation

Transfer clonal labels from a clones AnnData object to a adata AnnData object, or otherwise.

pp.transfer_expression

Summarize gene expression at the clone level using a specified strategy (sum or average).

Tools#

tl.clonal_nn

Computes and adds a clone-to-clone adjacency graph to a clones object.

tl.clonocluster

Performing ClonoCluster [PMID: 36819662] algorithm for lineage-informed gene expression clustering.

tl.smooth

Performing kNN smoothing on adata.X, adata.layers[layer], adata.obs[name], or adata.obsm[name] for n_steps iterations using adata.obsp[graph_key].

tl.group_connectivity

Computes connectivities (number of observed over the number of expected edges) of groups based on the graph.

Embeddings#

tl.clone2vec

Learn a clonal embedding using Skip-Gram and store the embeddings.

tl.clone2vec_Poi

Learn a clonal embedding using fastglmpca [PMID: 39110511] Python implementation and store the embeddings.

tl.project_clone2vec

Fitting of new clones to the reference clone2vec embeddings using kNN between query and reference datasets.

tl.project_clone2vec_Poi

Fitting of new clones to the reference clone2vec Poisson embeddings using kNN between query and reference datasets.

tl.find_mnn

Find anchors between batches in clones.obs[batch_key] using MNNs using clones.obsm[use_rep].

tl.align

Align clones.obsm[use_rep] using MNNs found in clones.uns[uns_key] via procrustes alignment (PA).

Associations#

tl.associations

Calculate correlation between features in adata and a response variable.

tl.graph_associations

Computes the supervised principal components analysis (sPCA) of the data [10.1016/j.patcog.2010.12.015].

tl.eigenvalue_test

Performs Johnstone’s Spiked Covariance Test to identify if the embedding is random.

tl.catboost

Performs CatBoost regression or classification on the data aiming to identify associations between the features and the response variable.

Utils#

utils.stack_layers

Function stacks layers of an AnnData object into a single layer in adata.X.

utils.correct_shap

Correct SHAP values by dividing by the maximum absolute value of SHAP values for each feature.

utils.connect_clones

Creates a graph of connected clones based on a grouping variable.

utils.get_connectivity_matrix

Get group connectivity matrix from adata.uns[uns_key].

utils.regress_categories

Performs expression regression on categorical variables in obs_key.

utils.impute

Impute missing values in an observation column using k-nearest neighbors.

utils.gs

Function to perform geometric sketching on an AnnData object.

utils.laplacian_eigenmaps

Compute Laplacian eigenmaps from a sparse graph stored in adata.obsp.

Plotting#

pl.group_scatter

Plots the spatial distribution of a single clone on a 2D embedding.

pl.group_kde

Plots kernel density estimates (KDE) of cells from one or multiple groups on a 2D embedding.

pl.loss_history

Plot the mean loss per epoch and its change across epochs during clone2vec training.

pl.clone_size

Plot basic statistics of clone size distribution.

pl.nesting_clones

Plot ternary composition of clones labeled by two different injections.

pl.volcano

Draw a volcano using provided p-values and logFCs.

pl.shap_volcano

Draws volcano-like plot showing the result of the associations analysis with CatBoost and SHAP.

pl.barplot

Draws barplot colored by the value in each bar.

pl.heatmap

Draws pretty heatmap.

pl.predictors_comparison

Draws barplot of SHAP values for two groups.

pl.catboost_perfomance

Compares predicted by CatBoost and observed values.

pl.clones2cells

Draws two interactive sctterplots with gene expression (left) and clonal (right) embeddings.

pl.graph

Draws graph on top of the embedding.

pl.group_connectivity

Plot group connectivity on top of the embedding.

pl.pca_loadings

Plot PCA loadings for a given component.

pl.scaled_dotplot

Function plots dotplot colored by scaled expression values.

pl.scatter2vars

Plots embedding colored by two continious variables.

pl.embedding_axis

Adds two perpendicular arrows (L-shape) to the bottom-left corner of the plot to mimic standard single-cell embedding visualizations (Seurat/Scanpy).

pl.small_cbar

Adds small colorbars to the right of the specified axes.

pl.fancy_legend

Adds a legend to the plot with cluster labels aligned to the cluster centers.

Seurat#

seurat.read

Reads .rds-file or .qsave-file with Seurat object and returns AnnData or MuData object.

seurat.integrate_data

Performs single-cell data integration via Seurat's CCA or RPCA approach.