Skip to content

Commit 43772a1

Browse files
authored
Merge pull request #3 from cellgeni/dev
Dev
2 parents 26591bf + e3acef8 commit 43772a1

39 files changed

Lines changed: 6101 additions & 1100 deletions

‎.github/workflows/tests.yml‎

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ concurrency:
1111
cancel-in-progress: true
1212

1313
jobs:
14-
test:
14+
tests:
1515
runs-on: ubuntu-latest
1616
timeout-minutes: 20
1717

@@ -23,6 +23,21 @@ jobs:
2323
fail-fast: false
2424
matrix:
2525
python-version: ["3.12"] # add "3.13" if you want
26+
module:
27+
- name: cli
28+
tests: tests/test_cli.py
29+
- name: export
30+
tests: tests/test_export.py
31+
- name: import
32+
tests: tests/test_import.py
33+
- name: info-read
34+
tests: tests/test_info_read.py
35+
- name: subset
36+
tests: tests/test_subset.py
37+
- name: zarr
38+
tests: tests/test_zarr.py
39+
40+
name: tests (${{ matrix.module.name }})
2641

2742
steps:
2843
- uses: actions/checkout@v4
@@ -35,36 +50,36 @@ jobs:
3550
- name: Set up uv
3651
uses: astral-sh/setup-uv@v3
3752
with:
38-
enable-cache: true
53+
enable-cache: false
3954

4055
- name: Install dependencies (frozen)
4156
run: uv sync --extra dev --frozen
4257

4358
- name: Run tests with coverage
4459
run: |
45-
uv run pytest -v \
60+
uv run pytest -v -W default ${{ matrix.module.tests }} \
4661
--cov=h5ad \
4762
--cov-report=term-missing \
4863
--cov-report=xml \
4964
--cov-report=html \
50-
--junitxml=pytest-results.xml
65+
--junitxml=pytest-results-${{ matrix.module.name }}.xml
5166
5267
- name: Publish test results summary
5368
uses: EnricoMi/publish-unit-test-result-action@v2
5469
if: always()
5570
with:
56-
files: pytest-results.xml
57-
check_name: Test Results
71+
files: pytest-results-${{ matrix.module.name }}.xml
72+
check_name: Test Results (${{ matrix.module.name }})
5873

5974
- name: Upload coverage artifacts
6075
uses: actions/upload-artifact@v4
6176
if: always()
6277
with:
63-
name: coverage
78+
name: coverage-${{ matrix.module.name }}
6479
path: |
6580
coverage.xml
6681
htmlcov/
67-
pytest-results.xml
82+
pytest-results-${{ matrix.module.name }}.xml
6883
retention-days: 30
6984

7085
- name: Upload coverage to Codecov

‎README.md‎

Lines changed: 22 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
# h5ad CLI
22

3-
A command-line tool for exploring huge `.h5ad` (AnnData) files without loading them fully into memory. Streams data directly from disk for efficient inspection of structure, metadata, and matrices.
3+
A command-line tool for exploring huge AnnData stores (`.h5ad` and `.zarr`) without loading them fully into memory. Streams data directly from disk for efficient inspection of structure, metadata, and matrices.
44

55
## Features
66

7-
- **`info`** – Show file structure and dimensions (`n_obs × n_var`)
8-
- **`table`** – Export obs/var metadata to CSV with chunked streaming
9-
- **`subset`** – Filter h5ad files by cell/gene names (supports dense and sparse CSR/CSC matrices)
10-
- Memory-efficient chunked processing for large files
11-
- Rich terminal output with colors and progress bars
7+
- Streaming access to very large `.h5ad` and `.zarr` stores
8+
- Auto-detects `.h5ad` files vs `.zarr` directories
9+
- Chunked processing for dense and sparse matrices (CSR/CSC)
10+
- Rich terminal output with progress indicators
1211

1312
## Installation
1413

14+
Using [uv](https://docs.astral.sh/uv/) (recommended):
1515
```bash
16+
git clone https://github.com/cellgeni/h5ad-cli.git
17+
cd h5ad-cli
1618
uv sync
1719
```
1820

@@ -21,45 +23,27 @@ For development and testing:
2123
uv sync --extra dev
2224
```
2325

24-
See [docs/TESTING.md](docs/TESTING.md) for testing documentation.
25-
26-
## Usage
27-
Invoke any subcommand via `uv run h5ad ...`:
28-
29-
```bash
30-
uv run h5ad --help
31-
```
32-
33-
#### Examples
34-
35-
**Inspect overall structure and axis sizes:**
26+
Alternative with pip:
3627
```bash
37-
uv run h5ad info data.h5ad
28+
git clone https://github.com/cellgeni/h5ad-cli.git
29+
cd h5ad-cli
30+
pip install .
3831
```
3932

40-
**Export full obs metadata to CSV:**
33+
For development and testing with pip:
4134
```bash
42-
uv run h5ad table data.h5ad --axis obs --out obs_metadata.csv
35+
pip install -e ".[dev]"
4336
```
4437

45-
**Export selected obs columns to stdout:**
46-
```bash
47-
uv run h5ad table data.h5ad --axis obs --cols cell_type,donor
48-
```
38+
See [docs/TESTING.md](docs/TESTING.md) for testing documentation.
4939

50-
**Export var metadata with custom chunk size:**
51-
```bash
52-
uv run h5ad table data.h5ad --axis var --chunk-rows 5000 --out var_metadata.csv
53-
```
40+
## Commands (Overview)
5441

55-
**Subset by cell names:**
56-
```bash
57-
uv run h5ad subset input.h5ad output.h5ad --obs cells.txt
58-
```
42+
Run help at any level (e.g. `uv run h5ad --help`, `uv run h5ad export --help`).
5943

60-
**Subset by both cells and genes:**
61-
```bash
62-
uv run h5ad subset input.h5ad output.h5ad --obs cells.txt --var genes.txt
63-
```
44+
- `info` – read-only inspection of store layout, shapes, and type hints; supports drilling into paths like `obsm/X_pca` or `uns`.
45+
- `subset` – stream and write a filtered copy based on obs/var name lists, preserving dense and sparse matrix encodings.
46+
- `export` – extract data from a store; subcommands: `dataframe` (obs/var to CSV), `array` (dense to `.npy`), `sparse` (CSR/CSC to `.mtx`), `dict` (JSON), `image` (PNG).
47+
- `import` – write new data into a store; subcommands: `dataframe` (CSV → obs/var), `array` (`.npy`), `sparse` (`.mtx`), `dict` (JSON).
6448

65-
All commands stream from disk, so even multi-GB `.h5ad` files remain responsive.
49+
See [docs/GET_STARTED.md](docs/GET_STARTED.md) for a short tutorial.

0 commit comments

Comments
 (0)