Skip to main content

A CLI-driven AnnData toolkit

Project description

anntools

A command line utility for working with AnnData files.

anntools provides tools to manipulate, analyze, and transform AnnData (.h5ad) files commonly used in single-cell genomics. It offers efficient operations for quality control, downsampling, concatenation, pseudobulking, and more.

Installation

anntools can be installed using uv or pip:

# Using uv (recommended)
uv tool install anntools-bio

# Using pip
pip install anntools-bio

# From source
git clone https://github.com/noamteyssier/anntools.git
cd anntools
uv tool install -U -e .

Usage

# Get help information
anntools --help

# Get help for specific commands
anntools downsample --help
anntools concat --help
anntools info --help

Commands

info

Display comprehensive information about an h5ad file including shape, sparsity, layers, and metadata.

# Basic info
anntools info input.h5ad

# Detailed info with metadata summaries
anntools info input.h5ad -v

downsample

Downsample UMIs or cells to a specified fraction.

# Downsample UMIs using binomial sampling
anntools downsample input.h5ad 0.5 -o output.h5ad

# Downsample cells
anntools downsample input.h5ad 0.8 --which cells

# Use multinomial sampling
anntools downsample input.h5ad 0.5 --method multinomial

# Set random seed for reproducibility
anntools downsample input.h5ad 0.5 --seed 42

concat

Concatenate multiple h5ad files along the observation axis.

# Concatenate with inner join (only common variables)
anntools concat output.h5ad file1.h5ad file2.h5ad file3.h5ad

# Concatenate with outer join (all variables)
anntools concat output.h5ad file1.h5ad file2.h5ad --join outer

# Add batch labels
anntools concat output.h5ad file1.h5ad file2.h5ad --batch-key batch

# Specify custom batch labels
anntools concat output.h5ad file1.h5ad file2.h5ad --batch-key batch --batch-categories "ctrl,treat"

pseudobulk

Aggregate single-cell data into pseudobulk profiles. Pseudobulking is done using adpbulk.

# Pseudobulk by cell type
anntools pseudobulk input.h5ad cell_type -o output.h5ad

# Pseudobulk by multiple grouping variables
anntools pseudobulk input.h5ad cell_type sample_id

# Use different aggregation methods
anntools pseudobulk input.h5ad cell_type --method sum
anntools pseudobulk input.h5ad cell_type --method median

# Pseudobulk a specific layer
anntools pseudobulk input.h5ad cell_type --layer counts

qc

Calculate quality control metrics.

# Add QC metrics to a new file
anntools qc input.h5ad -o output_qc.h5ad

# Replace existing file with QC metrics
anntools qc input.h5ad --replace

sparse

Convert data to CSR sparse format.

# Convert to sparse format
anntools sparse input.h5ad -o output_sparse.h5ad

# Replace existing file
anntools sparse input.h5ad --replace

view-obs / view-var

Export observation or variable metadata to TSV.

# View observation metadata
anntools view-obs input.h5ad > obs.tsv

# View variable metadata
anntools view-var input.h5ad > var.tsv

License

MIT License - see LICENSE for details.

Project details


Download files

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

Source Distribution

anntools_bio-0.1.2.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

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

anntools_bio-0.1.2-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file anntools_bio-0.1.2.tar.gz.

File metadata

  • Download URL: anntools_bio-0.1.2.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for anntools_bio-0.1.2.tar.gz
Algorithm Hash digest
SHA256 06f3436764f2e8939377662ab5640815d97669803c4955e823558a6fd6e27ac5
MD5 31b3c5cd8a23d002386f4b3c01d1e585
BLAKE2b-256 cf224632c2c44ba3d66a5dd5891b9baf491e8ec4dc1987048a8f1e2603a20352

See more details on using hashes here.

File details

Details for the file anntools_bio-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: anntools_bio-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 10.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for anntools_bio-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7e784af9db6316367c690de21b02380c0e22e223517b34568d0aa85aaa5be503
MD5 f8127892ba0beec4a04ac8e810e61c50
BLAKE2b-256 8d8091c1dffc1126e4d385f0506d1c1b8dd635a89a17edd29c0fef7e14365d0a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page