py-TranspaceR
Python port of TranspaceR — Statistical analysis of Spatial transcriptomic data.
Correlation Benchmark (Python vs R)
| Function | Pearson r | Max Abs Error |
|---|---|---|
C_normalisation |
1.000000 | 4.10e-05 |
Otsu_thresholding |
— | 3.54e-05 |
colvars_sparse |
1.000000 | 4.40e-05 |
Get_variogram_map |
Deterministic match | 0 |
Get_isotropic_vario |
1.000000 | 0 |
All outputs are highly consistent with R references, with errors within floating-point precision.
Speed Benchmark (39,047 cells x 539 genes)
| Function | R Time | Python Time | Speedup |
|---|---|---|---|
C_normalisation |
1.47s | 0.157s | 9.4x |
Otsu_thresholding |
0.31s | 0.031s | 10.0x |
colvars_sparse |
1.72s | 0.011s | 156x |
Get_variogram_map |
0.02s | 0.0004s | 50x |
Get_isotropic_vario |
0.01s | 0.0004s | 25x |
| Total | 3.53s | 0.20s | 17.7x |
Why faster
- NumPy/SciPy compiled C backend vs R interpreted execution
- Direct CSC sparse matrix memory layout access
- Broadcasting replaces R's row-wise
applyloops
Installation
pip install -e ".[all]"
Quick Start
import transspacer as ts
import numpy as np
import pandas as pd
# Load data
expr = pd.read_csv("Expression_file.csv.gz", index_col=0)
meta = pd.read_csv("Meta_data.csv", index_col=0)
# Cell-size normalisation
normed = ts.c_normalisation(expr.values.astype(float), meta["Area"].values)
# Otsu thresholding
threshold = ts.otsu_thresholding(np.log10(expr.values.sum(axis=1) + 1))
# Variogram analysis
result = ts.compute_variogram(normed, meta["cell_centroid_x"].values,
meta["cell_centroid_y"].values)
# Geary's C spatial autocorrelation
gc = ts.geary_c_score(normed, coords, pvalue_threshold=0.01)
# Clustering
labels = ts.cell_clustering_function(pca_data, K=10, resolution=1.0)
Modules
| Module | Description |
|---|---|
fft_utils |
fftshift, ifftshift, pad_definitor |
normalization |
C_normalisation cell-size normalisation |
sparse_utils |
Sparse matrix column variance, group aggregation |
variogram |
FFT variogram map, variogram model fitting |
spatial_stats |
Geary's C, NB excess variance / excess zero score |
clustering |
KNN + Leiden/Louvain clustering, UMAP |
gene_selection |
log2FC, gene set union |
qc |
Otsu thresholding, QC gene filtering |
plotting |
Spatial visualization, heatmaps, UMAP plots |
Testing
pytest tests/ -q
# 29 passed
Dependencies
Core: numpy, scipy, scikit-learn, pandas, matplotlib
Optional: umap-learn (UMAP), python-igraph + leidenalg (Leiden clustering), statsmodels (FDR correction)
License
MIT
Metadata
Release files for py-TranspaceR 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| py_transpacer-0.1.0.tar.gz | 22.0 kB | Without provenance | Details for py_transpacer-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| py_transpacer-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for py_transpacer-0.1.0-py3-none-any.whl |
Total release size: 42.4 kB
Release files / py_transpacer-0.1.0.tar.gz
| Download URL | py_transpacer-0.1.0.tar.gz |
|---|---|
| Size | 22.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c4078f6224c4cef5c57f3ee5b5ae1eee4f97b8d0bdb94deb3e61d75a69e3d26f
|
|
BLAKE2b-256 checksum How to use checksums |
d96405b75deb857898b8d14f7e29a54d50333f89a761e85c6067e088e1033c8d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.13
|
Release files / py_transpacer-0.1.0-py3-none-any.whl
| Download URL | py_transpacer-0.1.0-py3-none-any.whl |
|---|---|
| Size | 20.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8689b817bb27969dba20bfc7e7d53220710cd692aea589aea25b5ae2852646af
|
|
BLAKE2b-256 checksum How to use checksums |
046ed5ccd3234923ca5a3f6118231abb7f863fce3ba1254472506c1d022b828c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.13
|
Security for py-TranspaceR 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.