Cell-GPS spatial topology analysis for spatial omics data.
Project description
Cell-GPS
Cell-GPS is the Python package and method name for spatial topology analysis in spatial omics data. New Python code should import cellgps; the historical sfplot import namespace is retained for backward compatibility.
This repository is being maintained as the code companion for manuscript review and future reuse.
Package Names
- Python distribution:
Cell-GPS - Python import package:
cellgps - R package/repository:
cellgpsr - Windows executable:
cellgps.exe
The Python package is hosted at https://github.com/hutaobo/cellgps. The R package is hosted separately at https://github.com/hutaobo/cellgpsr. The Windows single-file executable is distributed through Zenodo: https://zenodo.org/records/17859173.
What Cell-GPS does
- Computes searcher-findee distance matrices from spatial coordinates and cell labels.
- Builds cophenetic distance matrices and StructureMap heatmaps from
AnnDataobjects or plainpandastables. - Loads 10x Xenium outputs and prepares them for downstream spatial analysis.
- Provides Xenium loaders backed by
pyXenium.io, including standard Xenium folders and table bundles withcells.parquet, official*_cell_groups.csv, andcell_feature_matrix.h5. - Supports transcript-by-cell analysis for locating transcripts relative to cell types.
- Includes memory-optimized workflows for large datasets.
- Provides plotting utilities such as clustered heatmaps, circular dendrograms, and related summary figures.
Repository layout
src/cellgps/: recommended Python import namespace.src/sfplot/: legacy compatibility namespace and current implementation modules.tests/: package tests and smoke checks.docs/: Sphinx documentation.sfplot-manuscript/: manuscript-specific notebooks, figures, and derived outputs.benchmarking/: benchmarking-related material.segmentation_methods/: supporting segmentation workflows.
Installation
Install from PyPI:
pip install Cell-GPS
Install directly from GitHub:
pip install git+https://github.com/hutaobo/cellgps.git
For local development or reviewer inspection:
git clone https://github.com/hutaobo/cellgps.git
cd cellgps
pip install -e .
The package requires Python 3.9 or later.
Quick start from a coordinate table
The minimal input is a table with spatial coordinates and a cell-type column.
import pandas as pd
from cellgps import compute_cophenetic_distances_from_df, plot_cophenetic_heatmap
df = pd.DataFrame(
{
"x": [0, 1, 5, 6],
"y": [0, 1, 5, 6],
"celltype": ["A", "A", "B", "B"],
}
)
row_coph, col_coph = compute_cophenetic_distances_from_df(
df=df,
x_col="x",
y_col="y",
celltype_col="celltype",
)
plot_cophenetic_heatmap(
row_coph,
matrix_name="row_coph",
output_dir="output",
output_filename="StructureMap_example.pdf",
sample="Example",
)
Quick start from Xenium output
from cellgps import load_xenium_data, load_xenium_table_bundle, compute_cophenetic_distances_from_adata
# Standard Xenium folder through pyXenium.io
adata = load_xenium_data("/path/to/xenium/run", normalize=False)
# Explicit table-bundle route used for the Atera Xenium benchmark
adata = load_xenium_table_bundle("/path/to/xenium/run", normalize=False)
row_coph, col_coph = compute_cophenetic_distances_from_adata(
adata,
cluster_col="Cluster",
output_dir="output",
)
Useful public entry points
load_xenium_data: load and preprocess Xenium data.load_xenium_table_bundle: load Xenium data fromcells.parquet+*_cell_groups.csv+cell_feature_matrix.h5throughpyXenium.io.compute_cophenetic_distances_from_df: compute structure matrices from a coordinate table.compute_weighted_searcher_findee_distance_matrix_from_df: weighted searcher-findee kernel for entity, pathway, or LR analysis.compute_weighted_cophenetic_distances_from_df: weighted StructureMap wrapper over the weighted kernel.compute_cophenetic_distances_from_adata: compute structure matrices fromAnnData.compute_entity_to_cell_topology: generalizet_and_cfrom transcripts to arbitrary weighted entities.compute_entity_structuremap: build StructureMap-style topology among arbitrary weighted entities.plot_cophenetic_heatmap: generate StructureMap and related clustered heatmaps.transcript_by_cell_analysis: analyze transcript-to-cell spatial structure at scale.ligand_receptor_topology_analysis: score sender→receiver ligand-receptor candidates using topology, structure compatibility, and local contact.ligand_receptor_target_consistency: add a NicheNet-style downstream target-consistency layer.compute_pathway_activity_matrix: compute rank-based or weighted pathway activities per cell.pathway_topology_analysis: analyze pathway-to-cell and pathway-to-pathway spatial topology.compute_cophenetic_distances_from_df_memory_opt: memory-aware alternative for large tables.plot_circular_dendrogram_pycirclize: circular dendrogram visualization.
Notes for reviewers
- The recommended Python import namespace is
cellgps; the legacysfplotnamespace remains available for older scripts. - Manuscript-facing notebooks and generated figure assets are kept in
sfplot-manuscript/. - Raw experimental datasets are not bundled in this repository because of size and distribution constraints. The code expects standard spatial omics outputs such as Xenium folders or tabular coordinate inputs.
- When a
cellgps_tbc_formal_wta/results-style directory is already available, the LR and pathway topology extensions are designed to reuse itst_and_c_result_*.csvandStructureMap_table_*.csvoutputs as the preferred gene-level topology anchors before falling back to recomputation. - Xenium loading depends on
pyXenium>=0.4.3. Visium helpers remain optional through the separateCell-GPS[visium]extra. - A short repository walkthrough is available in REVIEWER_GUIDE.md.
Documentation
Sphinx documentation sources are available in docs/.
Citation
If you use this repository in connection with manuscript review, please cite the associated manuscript:
Cophenetic Spatial Topology Embedding reveals multiscale tissue architecture in spatial omics
License
This project is released under the MIT License. See LICENSE.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cell_gps-0.0.4.tar.gz.
File metadata
- Download URL: cell_gps-0.0.4.tar.gz
- Upload date:
- Size: 73.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d6a8afcbf916ec9ef51eb6e21f56f5a176bf5b7d513cfd4b91c6afbcc547bf3c
|
|
| MD5 |
3cc1d1edf2ac37c7957b85a3a3b85f09
|
|
| BLAKE2b-256 |
fbdccf56308eada7af787699f6a9ef162434cd172d3f79d27c7607d68627f1a4
|
Provenance
The following attestation bundles were made for cell_gps-0.0.4.tar.gz:
Publisher:
python-publish.yml on hutaobo/sfplot
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cell_gps-0.0.4.tar.gz -
Subject digest:
d6a8afcbf916ec9ef51eb6e21f56f5a176bf5b7d513cfd4b91c6afbcc547bf3c - Sigstore transparency entry: 1633505433
- Sigstore integration time:
-
Permalink:
hutaobo/sfplot@426b14f100250ceca0295499334b409e40bc71e1 -
Branch / Tag:
refs/tags/v0.0.4 - Owner: https://github.com/hutaobo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@426b14f100250ceca0295499334b409e40bc71e1 -
Trigger Event:
release
-
Statement type:
File details
Details for the file cell_gps-0.0.4-py3-none-any.whl.
File metadata
- Download URL: cell_gps-0.0.4-py3-none-any.whl
- Upload date:
- Size: 75.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c1665dbe859ff9ab4a168ea944182fa2ffb075d52136c6c6121722c4a736196f
|
|
| MD5 |
5f7d6f34e27d1c3fd249782052135f19
|
|
| BLAKE2b-256 |
e6139c7baccb432262f84eb80567758e7e4e3dad625eed4ab1d54141e1efe096
|
Provenance
The following attestation bundles were made for cell_gps-0.0.4-py3-none-any.whl:
Publisher:
python-publish.yml on hutaobo/sfplot
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cell_gps-0.0.4-py3-none-any.whl -
Subject digest:
c1665dbe859ff9ab4a168ea944182fa2ffb075d52136c6c6121722c4a736196f - Sigstore transparency entry: 1633505451
- Sigstore integration time:
-
Permalink:
hutaobo/sfplot@426b14f100250ceca0295499334b409e40bc71e1 -
Branch / Tag:
refs/tags/v0.0.4 - Owner: https://github.com/hutaobo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@426b14f100250ceca0295499334b409e40bc71e1 -
Trigger Event:
release
-
Statement type: