Skip to main content

pysimspec

Python implementation of simspec (for RSS/CSS). The paper about the method detailed is published in Genome Biology in 2020. The original R implementation is available at GitHub.

Installation

First, clone the codebase to your local environment

git clone https://github.com/quadbio/pysimspec.git

Next, install the package with pip

cd pysimspec
pip install .

Just to mention, this project uses uv for fast Python package management.

uv venv
uv pip install -e '.[dev]'

Quick example

import scanpy as sc
import anndata
from pysimspec import Simspec, set_log_level, load

# Set up logging
set_log_level("INFO")

# Load and concatenate data
adata_DS1 = sc.read_h5ad('DS1_raw.h5ad')
adata_DS2 = sc.read_h5ad('DS2_raw.h5ad')
adata_DS1.obs['batch'] = 'DS1'
adata_DS2.obs['batch'] = 'DS2'
adata = anndata.concat([adata_DS1, adata_DS2], join='inner', keys=['DS1','DS2'], index_unique="_")

# Data preprocessing
adata.layers['counts'] = adata.X.copy()
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)
sc.pp.highly_variable_genes(adata, flavor='seurat_v3', layer='counts', n_top_genes=3000, batch_key='batch')
sc.pp.pca(adata, n_comps=20, mask_var='highly_variable')

# Run CSS
simspec = Simspec()
simspec.compute_references(adata, batch = 'batch', use_rep = 'X_pca')
simspec.compute_simspec(adata)
simspec.compute_PCA(n_pcs = 10)
adata.obsm['X_css'] = simspec.get_result()
adata.obsm['X_csspca'] = simspec.get_transformed_result()

# Use CSS representation for followup analysis
sc.pp.neighbors(adata, use_rep='X_css')
sc.tl.umap(adata)
sc.pl.umap(adata, color='batch')

# Save the Simspec object
simspec.save('simspec.pkl')

# Calculate projected CSS representation for the new data
adata_DS3 = sc.read_h5ad('DS3_raw.h5ad')
adata_DS3.layers['counts'] = adata_DS3.X.copy()
sc.pp.normalize_total(adata_DS3, target_sum=1e4)
sc.pp.log1p(adata_DS3)

simspec = load('simspec.pkl') # load the saved Simspec object
simspec.compute_simspec(adata_DS3)
adata_DS3.obsm['X_css_proj'] = simspec.get_result()
adata_DS3.obsm['X_csspca_proj'] = simspec.get_transformed_result()

License

MIT

Metadata

Release files for pysimspec 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pysimspec 0.1.0
File Size Uploaded Provenance Actions
pysimspec-0.1.0.tar.gz 9.8 kB Without provenance Details for pysimspec-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pysimspec 0.1.0
File Interpreter ABI Platform Actions
pysimspec-0.1.0-py3-none-any.whl Python 3 none any Details for pysimspec-0.1.0-py3-none-any.whl

Total release size: 18.5 kB

Release files / pysimspec-0.1.0.tar.gz

Download URL pysimspec-0.1.0.tar.gz
Size 9.8 kB
Tags Source
SHA-256 checksum
How to use checksums
0740b99fae0b23223128646c4bf0896418e4b0d1b8831accc587b10e0697cd9d
BLAKE2b-256 checksum
How to use checksums
58090d4fe674772ccb3f0976f9e0444c9ac1b3f4da824036943e9e6bda9acdae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / pysimspec-0.1.0-py3-none-any.whl

Download URL pysimspec-0.1.0-py3-none-any.whl
Size 8.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3408cf9f2c27c4264ec3640f0356137136f8c83e91cd953dfeafca1f017108e2
BLAKE2b-256 checksum
How to use checksums
4d829bd9f73f154e142210d2c933107aea5bf7d285b9bc8e6da4a4a276181c3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Security for pysimspec 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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page