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).

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]"

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

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.3.0.tar.gz (44.4 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.3.0-py3-none-any.whl (40.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for sctenifoldpy-0.3.0.tar.gz
Algorithm Hash digest
SHA256 fe83fa7cd8315cd84c5ec8e59e93cead92166cc20e4a51ad10a262a54f0c8946
MD5 4529700a62a737bd515da28583ef7a2b
BLAKE2b-256 85d8408e7deb66472a803eb227bbf94b87bd98f9741ae9dce183a3775bd56567

See more details on using hashes here.

Provenance

The following attestation bundles were made for sctenifoldpy-0.3.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.3.0-py3-none-any.whl.

File metadata

  • Download URL: sctenifoldpy-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 40.9 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f9d0b6e14d45ac31ffbeeed5f17c201a81ebe0c1c772adf2fb2cf48464516618
MD5 97f9c0ab1eff834e48d909dddffa17f8
BLAKE2b-256 cb9573a2938eb0ae335185713f2c3f11087723c29d1175f4512258fc5bfc1185

See more details on using hashes here.

Provenance

The following attestation bundles were made for sctenifoldpy-0.3.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

0.4.0

2 files

This release

0.3.0 This release

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