Tools: tl#

This module provides various tools for analyzing proteomics data.

Clustering#

tl.leiden_mito_sweep

Automated sweep to pick a Leiden resolution that keeps mitochondria intact.

tl.markov_clustering

Run Markov Clustering (MCL) on the neighbour graph.

tl.calculate_interfacialness_score

Quantify interfacialness of proteins across compartment boundaries.

tl.silhouette_score

Per-group silhouette scores.

tl.calinski_habarasz_score

Calinski–Harabasz score of cluster compactness vs separation.

tl.qsep_score

QSep cluster-separation metric for spatial proteomics.

tl.tagm_map_train

Train a TAGM-MAP (T-Augmented Gaussian Mixture, MAP variant) model.

tl.tagm_map_predict

Predict sub-cellular localization for unlabelled proteins using a fitted TAGM-MAP model.

tl.knn_f1_score

F1 score.

tl.class_balance

Return a balanced subset with equally sized clusters.

Cluster Merging#

Consolidate overclustered Leiden solutions using PAGA connectivity and ontology enrichment.

tl.merge_clusters_go

Iteratively merge overclustered Leiden clusters using PAGA and GO enrichment.

tl.merge_small_clusters

Iteratively merge small clusters into their most-connected neighbor.

tl.paga_dendrogram

Build a dendrogram from PAGA connectivity and store it in adata.uns.

tl.dendrogram_cherry_pairs

Return all candidate merge pairs from the dendrogram, expanding ties.

Semi-supervised Localization#

Propagate mutually exclusive labels (markers) along the k-NN graph, or train a classifier on them.

tl.competitive_propagation

Propagate categorical annotations along the k-NN graph.

tl.knn_annotation

Deprecated alias for competitive_propagation().

tl.soft_cluster_annotation

Soft, uncertainty-aware version of the cluster-annotation pipeline.

tl.resolve_soft_labels

Resolve soft propagated probabilities into single / multi / unresolved labels.

tl.svm_train

Train SVM classifier with hyperparameter tuning using marker proteins.

tl.svm_annotation

Classify proteins using SVM with marker-based training.

Ontology-aware Annotation#

Propagate overlapping / hierarchical labels (GO-CC, UniProt-SL) one-vs-rest, which yields per-term membership probabilities rather than a simplex.

tl.independent_diffusion

Annotate a map with overlapping / hierarchical labels by one-vs-rest diffusion.

tl.resolve_diffusion

(Re)resolve stored diffusion probabilities into a per-protein label, in place.

Ontology Enrichment#

tl.calculate_cluster_enrichment

Gene-set enrichment for each cluster.

tl.enrichment_to_cluster_distribution

Turn a per-cluster enrichment table into soft label distributions.

Model-based Gene Set Analysis#

MGSA explains an observed protein set with a sparse set of ontology terms, rather than testing each term independently.

tl.mgsa

Run model-based gene set analysis.

tl.calculate_mgsa

Model-based gene-set analysis (MGSA) per cluster.

tl.mgsa_to_cluster_distribution

Convert a per-cluster MGSA posterior matrix into a soft-label distribution.

tl.MgsaResult

Container for MGSA posterior summaries and diagnostics.

tl.load_gmt

Resolve a gene-set source into a {term: [gene, ...]} dict.

C-COMPASS#

Neural-network compartment prediction, provided by the optional ccompass extra (pip install grassp[ccompass]).

tl.ccompass

Predict compartment class contributions with the C-COMPASS neural network.

tl.ccompass_default_params

Return (and optionally save) the default C-COMPASS hyperparameters used by ccompass().

Integration#

tl.align_adatas

Return copies of several AnnData objects with matching index/columns.

tl.aligned_umap

Aligned UMAP embedding for matched datasets.

tl.remodeling_score

Compute per-protein remodeling score from two aligned datasets.

tl.mr_score

M/R score for detecting protein translocation.

Graph analysis#

tl.to_knn_graph

Convert the k-NN graph stored in AnnData to a networkx graph.

tl.get_n_nearest_neighbors

Return the set of closest neighbours for a node in a graph.