Skip to content

Added parser for AIT files - #90

Open
puja-trivedi wants to merge 4 commits into
mainfrom
parse_AIT_files
Open

Added parser for AIT files#90
puja-trivedi wants to merge 4 commits into
mainfrom
parse_AIT_files

Conversation

@puja-trivedi

Copy link
Copy Markdown
Collaborator

Parsing Allen Institute Taxonomy (AIT) .h5ad files

What these are: The BICAN/HMBA basal-ganglia taxonomies (Human, Macaque, Marmoset) are released as AIT files in .h5ad (AnnData) format — the same format scrattch produces. Each file is an HDF5 container holding a cell×gene expression matrix plus the cell-type taxonomy.

The key insight: These files are huge (Human 105 GB, Macaque 32 GB, Marmoset 30 GB), but almost all of that is the expression matrix (X). The taxonomy itself is tiny and lives in the uns group:

  • uns/hierarchy — the level order: Neighborhood → Class → Subclass → Group → cluster_id
  • uns/cluster_info — one row per leaf cluster, with its full ancestor path + per-level accessions, CL ontology IDs, and hex colors

Because .h5ad is HDF5, we can open a file and read only those small groups using HTTP range requests — so we never download the full file and never load the expression matrix. Reading a 30 GB remote file takes seconds.

The tool: bkbit/data_translators/ait_taxonomy_parser.py (an AITTaxonomy class). It's read-only, works on local paths or https:///s3:// URLs, and returns pandas DataFrames or writes CSV.

Usage:

summary, no download:

python -m bkbit.data_translators.ait_taxonomy_parser --no-obs

export taxonomy table to CSV:

python -m bkbit.data_translators.ait_taxonomy_parser --no-obs --out out.csv
Dependencies: anndata, h5py, fsspec, aiohttp.

Output so far: CSVs of the per-cluster taxonomy table for all three species:

File Leaf clusters Levels (nodes)
Human 453 Neighborhood 4 · Class 12 · Subclass 36 · Group 60
Macaque 388 Neighborhood 4 · Class 12 · Subclass 35 · Group 58
Marmoset 594 Neighborhood 4 · Class 12 · Subclass 34 · Group 56

Next steps:

Align columns across species into one schema, and/or emit BICAN taxonomy JSON-LD objects (like the existing translators).

@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant