File size: 5,416 Bytes
0d9e3c5 a20355d 0d9e3c5 a20355d 0d9e3c5 a20355d 0d9e3c5 a20355d 0d9e3c5 a20355d 0d9e3c5 a20355d 0d9e3c5 a20355d 0d9e3c5 a20355d 0d9e3c5 a20355d 0d9e3c5 a20355d 0d9e3c5 a20355d 0d9e3c5 a20355d 0d9e3c5 a20355d 0d9e3c5 a20355d 0d9e3c5 a20355d 0d9e3c5 a20355d 0d9e3c5 a20355d 0d9e3c5 a20355d 0d9e3c5 a20355d 0d9e3c5 a20355d 0d9e3c5 a20355d 0d9e3c5 a20355d 0d9e3c5 a20355d 0d9e3c5 a20355d 0d9e3c5 a20355d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | ---
license: mit
pretty_name: Single-Cell Brain Zarr Collection
tags:
- biology
- bioinformatics
- single-cell
- scrna-seq
- zarr
- scanpy
- anndata
- cellxgene
---
# Single-Cell Brain Zarr Collection
Production-ready brain single-cell RNA-seq data exported from the CellxGene Census into native Zarr stores for chunked, on-demand access on the Hugging Face Hub.
## Why Zarr
Single-cell expression matrices get impractical fast if you treat them like ordinary dense files. Zarr is the point of this repo: it makes large atlas-scale data usable without forcing users to download or materialize the whole matrix before they can do anything useful.
| View | Matrix shape | Dense float32 equivalent | Zarr size on Hub | Why it matters |
|---|---:|---:|---:|---|
| Quickstart sample `brain.zarr` | `150,000 x 61,497` | `36.90 GB` | `52.52 MB` | Small tutorial-sized store you can open immediately. |
| Full sharded collection `brain_00000.zarr` ... `brain_00028.zarr` | `28,967,109 x 61,497` | `7.13 TB` | `38.14 GB` | Full dataset stays practical because access is chunked and row-sharded. |
- Compression vs dense float32:
- Quickstart sample: about `703x` smaller.
- Full collection: about `187x` smaller.
- Sample benchmark recorded during build:
- Open Zarr group: `0.0014 s`
- Read one `1000 x 1000` chunk: `0.0175 s`
- Practical speed difference:
- Before Zarr: users are pushed toward full-file or full-matrix workflows.
- After Zarr: users can open the store, inspect metadata, and read only the chunks they need.
## What Is In This Repo
- `brain.zarr`
- Quickstart sample with `150,000` cells.
- Good for tutorials, schema inspection, and lightweight tests.
- `brain_00000.zarr` ... `brain_00028.zarr`
- Full production collection.
- `29` row-sharded stores.
- Most shards contain `1,000,000` cells; the final shard contains `967,109`.
- `dataset_summary.json`
- Summary statistics for the sample export.
## Source And Provenance
- Upstream source: CellxGene Census API
- Census version: `2025-11-08`
- Organism: `Homo sapiens`
- Filter used for export: `tissue_general == 'brain' and is_primary_data == True`
- Source label in store metadata: `cellxgene-census`
- Random seed recorded in store metadata: `42`
This repo is a Zarr packaging of the upstream Census data to make browser-friendly, programmatic, chunked access practical on the Hub.
## Data Layout
### Expression matrix
- Key: `X`
- Dtype: `float32`
- Compression: Blosc `zstd` with bitshuffle
- Sample chunks: `(1000, 1000)`
- Full-store chunks: `(256, 61497)`
### Observation metadata in full stores
- `obs/_index`
- `obs/assay`
- `obs/cell_type`
- `obs/dataset_id`
- `obs/disease`
- `obs/donor_id`
- `obs/n_counts`
- `obs/n_genes`
- `obs/pct_mito`
- `obs/sex`
- `obs/tissue`
### Variable metadata in full stores
- `var/_index`
- `var/feature_id`
- `var/feature_name`
- `var/feature_type`
## Recommended Usage
- Use `brain.zarr` if you want a fast, self-contained sample for development or demos.
- Use the `brain_000xx.zarr` stores for full-scale work.
- Process the full collection shard by shard unless you explicitly have the memory budget to combine everything.
- Treat `X` as lazily loaded. Avoid converting the full dataset to one in-memory dense array.
## Quick Start
### Open the sample store directly from Hugging Face
```python
import fsspec
import zarr
mapper = fsspec.get_mapper(
"hf://datasets/KokosDev/single-cell-brain-zarr@main/brain.zarr"
)
root = zarr.open_group(mapper, mode="r")
print(root["X"].shape)
print(root["obs/_index"][:5])
```
### Open one full shard
```python
import fsspec
import zarr
shard = "brain_00000.zarr"
mapper = fsspec.get_mapper(
f"hf://datasets/KokosDev/single-cell-brain-zarr@main/{shard}"
)
root = zarr.open_group(mapper, mode="r")
print(shard, root["X"].shape)
print(root["obs/cell_type"][:5])
print(root["obs/n_counts"][:5])
```
### Iterate over all full shards
```python
import fsspec
import zarr
for i in range(29):
shard = f"brain_{i:05d}.zarr"
mapper = fsspec.get_mapper(
f"hf://datasets/KokosDev/single-cell-brain-zarr@main/{shard}"
)
root = zarr.open_group(mapper, mode="r")
print(shard, root["X"].shape)
```
## Scanpy / AnnData Notes
- `brain.zarr` is the safer starting point if you want to materialize an `AnnData` object locally.
- The full `29`-shard collection is intended for shard-wise workflows, streaming, preprocessing, and atlas-scale analysis.
- QC-style columns are already included in full stores:
- `n_counts`
- `n_genes`
- `pct_mito`
## Intended Use
- Single-cell analysis and preprocessing
- Training and evaluation pipelines for biology ML workloads
- Large-scale feature extraction or embedding jobs
- Benchmarking chunked I/O and Hub-based data access
- Scanpy / AnnData workflows that need a small sample plus a scalable full dataset path
## Important Notes
- This repo contains native Zarr stores, not Parquet or CSV exports.
- The quickstart sample and the full sharded collection serve different purposes and are both intentionally included.
- If you are benchmarking or building loaders, prefer the sharded stores for realistic large-scale access patterns.
## Acknowledgements
Built from the CellxGene Census. Please cite and follow the upstream Census terms, licensing, and attribution requirements when using this data in research or products.
|