Skip to main content

ARBOLpy

python implementation of the R package ARBOL, scRNAseq iterative tiered clustering

Iteratively cluster single cell datasets using a scanpy anndata object as input. Identifies and uses optimum clustering parameters at each tier of clustering. Current build includes SCtransform normalization. Outputs QC and visualization plots for each clustering event.

Install

By github:

pip install git+https://github.com/jo-m-lab/ARBOLpy.git

from PyPI

pip install arbolpy

import ARBOLpy

or clone the repository and source the functions directly from the script

git clone https://github.com/jo-m-lab/ARBOLpy.git

import "path/to/cloned/git/repo/ARBOLpy/ARBOL"

there is a docker image available with ARBOL and dependencies preinstalled https://hub.docker.com/r/kkimler/arbolpy

Recommended Usage

ARBOL was developed and used in the paper, "A treatment-naïve cellular atlas of pediatric Crohn’s disease predicts disease severity and therapeutic response" Currently, a tutorial is only available for the R version, where the FGID atlas figure is reproduced: https://jo-m-lab.github.io/ARBOL/ARBOLtutorial.html

ARBOLpy is a stripped down version of ARBOL meant to perform iterative clustering with little overhead. Currently it does not include the two stop conditions that the R version uses to heuristically join similar clusters. This results in the Python version overclustering data. Methods for merging the end clusters of the tree are available on the develop branch of the R version of ARBOL.

This package is meant as a starting point for the way that we approached clustering and and is meant to be edited/customized through community feedback through users such as yourself!

The main function of ARBOLpy is ARBOL() - here is an example call.

import scanpy as sc
import ARBOLpy

adata = sc.datasets.pbmc3k()

tree = ARBOL.ARBOL(adata)

ARBOL.write_ARBOL_output(tree,output_csv='endclusts.csv')

The helper function write_ARBOL_output writes the anytree object's endclusters to a csv file.

Note This script can take a long time to run. Running on 20K cells could take >30 minutes. Running on 100k+ cells could take >3 hours.

Note It has been tested up to 200k cells, and beyond 10k cells, maintains a linear relationship between resource usage and number of cells

Python ARBOL resource usage:
Pearson residuals normalization:
- 1.2 GB RAM per 1000 cells
- 2 minutes per 1000 cells
TPM normalization:
- 1.2 GB RAM per 1000 cells
- 1:55 min per 1000 cells

R ARBOL resource usage:
Pearson residuals normalization (SCTransform):
- 1.2 GB RAM per 1000 cells
- 4 minutes per 1000 cells

The current RAM/time bottleneck is the silhouette analysis, which runs 30 rounds of clustering at different resolutions.

ARBOL() Parameters

  • adata scanpy anndata object
  • normalize_method normalization method, defaults to "Pearson", scanpy's experimental implementation of SCTransform. Also available: "TPM": as implemented in scanpy normalize_total()
  • tier starting tier, defaults to 0
  • cluster starting cluster, defaults to 0
  • min_cluster_size minimum number of cells to allow further clustering
  • tree anytree object to attach arbol to. Shouldn't be changed unless building onto a pre-existing tree.
  • parent parent node of current clustering event, defaults to None. As with tree, shouldn't be changed unless building onto a pre-existing anytree object
  • max_tiers maximum number of tiers to allow further clustering
  • min_silhouette_res lower bound of silhouette analysis leiden clustering resolution parameter scan
  • max_silhouette_res upper bound
  • silhouette_subsampling_n number of cells to subsample anndata for silhouette analysis (cluster resolution choice)
  • h5dir where to save h5 objects for each tier and cluster, if None, does not save
  • figdir where to save QC and viz figures for each tier and cluster, if None does not save

Returns

  • anytree object based on iterative tiered clustering

Metadata

Release files for ARBOLpy 0.0.9

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

Source distribution (sdist)

Source distribution for ARBOLpy 0.0.9
File Size Uploaded Provenance
ARBOLpy-0.0.9.tar.gz 10.3 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 20.8 kB

Release files / ARBOLpy-0.0.9.tar.gz

Download URL ARBOLpy-0.0.9.tar.gz
Size 10.3 kB
Tags Source
SHA-256 checksum
How to use checksums
15491b10b096de19d16e49ff810d6662b3a453b873db7862ba94e4e296265ad0
BLAKE2b-256 checksum
How to use checksums
a90617118387f7d7c29a159e401adfe158c14087f83a46a810a0ccb2f79b9e0a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / ARBOLpy-0.0.9-py3-none-any.whl

Download URL ARBOLpy-0.0.9-py3-none-any.whl
Size 10.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8536552e00e01a4b14e0782fbf629525f1e152334a5081d05552387e427f9439
BLAKE2b-256 checksum
How to use checksums
3e28084fefe477d29de8d238215b86d9e8aeb1ea5aca38fa92affdead926aa4c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Security for ARBOLpy 0.0.9

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.

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