Skip to main content

scTenifoldpy

CI codecov PyPI Python License DOI

scTenifoldpy is a Python implementation of the scTenifold suite: scTenifoldNet (cross-condition GRN comparison), scTenifoldKnk (virtual knockout), and scTenifoldXct (cell-cell interaction prediction, provided via the separately maintained scTenifoldXct package).

Local Web UI

Run scTenifoldNet, scTenifoldKnk, or plain GRN construction from a browser instead of code:

pip install "scTenifoldpy[ui]"
sctenifold-ui

sctenifold-ui defaults to port 8001 (not the more commonly used 8000, to lower the odds of colliding with another local server) and opens http://127.0.0.1:8001 in your browser. Use --port to pick a different one.

scTenifoldpy local web UI: workflow picker (Net / Knk / GRN-only) and dataset step

This opens a local page (http://127.0.0.1:8001) where you can try a bundled synthetic dataset or the real 10x PBMC3k dataset (the one behind the Seurat/Scanpy tutorials), or upload your own data as a genes-by-cells CSV or an AnnData .h5ad file. Pick a workflow, run it, and download the ranked-gene or ranked-edge results as CSV. Everything runs locally; no data leaves your machine. See the UI guide for details.

Installation

uv venv
uv add scTenifoldpy

or:

pip install scTenifoldpy

Optional extras:

# use uv
uv venv
uv add "scTenifoldpy[scanpy]"
uv add "scTenifoldpy[parallel-ray]"
uv add "scTenifoldpy[ui]"

# or use pip
pip install "scTenifoldpy[scanpy]"
pip install "scTenifoldpy[parallel-ray]"
pip install "scTenifoldpy[ui]"

The scTenifoldXct cell-cell interaction workflow is shipped as a separately maintained dependency behind the xct extra (pulls PyTorch and scanpy; requires Python >= 3.10):

pip install "scTenifoldpy[xct]"

Docker

Build the default runtime image:

docker build -t sctenifoldpy .

Run the CLI from the container, mounting the current directory as the working directory:

docker run --rm -v "$PWD:/workspace" sctenifoldpy scTenifold --help

PowerShell:

docker run --rm -v "${PWD}:/workspace" sctenifoldpy scTenifold --help

Optional extras can be included at build time:

docker build --build-arg EXTRAS=scanpy -t sctenifoldpy:scanpy .
docker build --build-arg EXTRAS=parallel-ray -t sctenifoldpy:ray .

Class API

from scTenifold.data import get_test_df
from scTenifold import scTenifoldNet

df_1 = get_test_df(n_cells=1000)
df_2 = get_test_df(n_cells=1000)

sc = scTenifoldNet(
    df_1,
    df_2,
    "X",
    "Y",
    qc_kws={"min_lib_size": 10},
    nc_kws={"backend": "serial", "n_jobs": 1},
)
result = sc.build()

High-Level API

from scTenifold import compare_networks, virtual_knockout

result = compare_networks(
    df_1,
    df_2,
    qc_kws={"min_lib_size": 10, "plot": False},
    network_kws={"n_nets": 3, "n_samp_cells": 100},
    backend="joblib-threading",
    n_jobs=4,
)

knockout = virtual_knockout(
    df_1,
    ko_genes=["NG-1"],
    qc_kws={"min_lib_size": 10, "min_percent": 0.001},
)

Cell-Cell Interaction (scTenifoldXct)

scTenifoldXct is maintained separately (cailab-tamu/scTenifoldXct) and re-exported here for convenience — from scTenifold import scTenifoldXct returns the exact same class and results:

import scanpy as sc
from scTenifold import scTenifoldXct

adata = sc.read_h5ad("log_normalised.h5ad")
xct = scTenifoldXct(
    data=adata,
    source_celltype="cell_A",
    target_celltype="cell_B",
    obs_label="ident",
    rebuild_GRN=True,
    GRN_file_dir="./xct_results",
)
xct.get_embeds(train=True)
enriched = xct.chi2_test()

See the scTenifoldXct guide for the CLI and differential (two-sample) analysis. Requires scTenifoldpy[xct].

Parallel Backends

Network construction defaults to deterministic serial execution:

from scTenifold import make_networks

networks = make_networks(df_1, backend="serial", n_jobs=1)
networks = make_networks(df_1, backend="joblib-loky", n_jobs=4)

Supported backends are serial, joblib-loky, joblib-threading, and ray. Ray is optional and requires scTenifoldpy[parallel-ray].

CLI

scTenifold config -t 1 -p ./net_config.yml
scTenifold net -c ./net_config.yml -o ./output_folder
scTenifold knk -c ./knk_config.yml -o ./output_folder
scTenifold xct data.h5ad -s cell_A -r cell_B -l ident   # needs [xct]

Citation

If you use scTenifoldpy in scientific work, please cite this software using the metadata in CITATION.cff, and cite the underlying method paper that matches your analysis:

scTenifoldNet

Osorio, D., Zhong, Y., Li, G., Huang, J. Z., & Cai, J. J. (2020). scTenifoldNet: A machine learning workflow for constructing and comparing transcriptome-wide gene regulatory networks from single-cell data. Patterns, 1(9), Article 100139. https://doi.org/10.1016/j.patter.2020.100139

scTenifoldKnk

Osorio, D., Zhong, Y., Li, G., Xu, Q., Yang, Y., Tian, Y., Chapkin, R. S., Huang, J. Z., & Cai, J. J. (2022). scTenifoldKnk: An efficient virtual knockout tool for gene function predictions via single-cell gene regulatory network perturbation. Patterns, 3(3), Article 100434. https://doi.org/10.1016/j.patter.2022.100434

scTenifoldXct

Yang, Y., Osorio, D., Long, W., Bai, M., Wang, F., Yan, X., Yang, S., Chen, A., Zhang, P., Cai, J. J. (2023). scTenifoldXct: A semi-supervised method for predicting cell-cell interactions and mapping cellular communication graphs. Cell Systems, 14(4), 302-311. https://doi.org/10.1016/j.cels.2023.01.004

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sctenifoldpy-0.4.0.tar.gz (71.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sctenifoldpy-0.4.0-py3-none-any.whl (63.3 kB view details)

Uploaded Python 3

File details

Details for the file sctenifoldpy-0.4.0.tar.gz.

File metadata

  • Download URL: sctenifoldpy-0.4.0.tar.gz
  • Upload date:
  • Size: 71.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for sctenifoldpy-0.4.0.tar.gz
Algorithm Hash digest
SHA256 a76c2d369f0a1587b2971c2ea7c7bff1d43fa9b19021a7c46283c81145db3480
MD5 5f32bf068e7e752bfc958b2510ec0229
BLAKE2b-256 944af445cf84b0bdf689ce54aca7a4d550916c60ba5e7c5c0bd20d1575e2fb19

See more details on using hashes here.

Provenance

The following attestation bundles were made for sctenifoldpy-0.4.0.tar.gz:

Publisher: pypi_pub.yml on qwerty239qwe/scTenifoldpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sctenifoldpy-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: sctenifoldpy-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 63.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for sctenifoldpy-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 431cedc38c5f149fc851cd9cf12f956a1b81c22b8b72c568e24665f461c3395f
MD5 9b123a283d2246989857155c9e871ac4
BLAKE2b-256 4b176a44f63c6781baa02dbaaa22b68d51c79fbcd5e8876e865a735227d87684

See more details on using hashes here.

Provenance

The following attestation bundles were made for sctenifoldpy-0.4.0-py3-none-any.whl:

Publisher: pypi_pub.yml on qwerty239qwe/scTenifoldpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 files

0.3.0

2 files

0.2.0

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

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