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

# Using pip
pip install anntools

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

# 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.0.tar.gz (10.1 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.0-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: anntools_bio-0.1.0.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.21

File hashes

Hashes for anntools_bio-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7aff9e494f6d527f2dee29a537bcfdb99b3f972b52e4a9650a0ecee95877cec5
MD5 9a337168b8b361f3820d75c92b4f6a8d
BLAKE2b-256 b87cc4309164615ede298738158129cccc1605afaa5b5291459a7d0b639920d4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for anntools_bio-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 246ce49da40148c9678e2211455dcad5117fd40bfc0122b8336c7c89987384c1
MD5 5bab4ac3b7562855ab527affcd311eda
BLAKE2b-256 8f386b90b656ceae3428946a026fdb05984bf8fead4f14b0d5cdf7c58b5c2594

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