CoolFace
Datasetpublic

KokosDev/single-cell-lung-zarr

Single-cell lung (CellxGene Census) — Zarr This dataset was exported from the CellxGene Census as a chunked + compressed Zarr store intended for easy streaming access. Source: CellxGene Census API Organism: Homo sapiens Filter: tissue_general == 'lung' and is_primary_data == True Shape: 100,000 cells × 61,497 genes Zarr path: lung.zarr Compression Uncompressed (dense float32): 22.91 GB Compressed Zarr: ~307 MB (322 MB on Hub) Compression ratio: ~76× (Blosc zstd… See the full description on the dataset page: https://huggingface.co/datasets/KokosDev/single-cell-lung-zarr.

sourceHugging Facemitupdated 7mo agoView on Hugging Face
1likes196downloads
Dataset Card

Single-cell lung (CellxGene Census) — Zarr

This dataset was exported from the CellxGene Census as a chunked + compressed Zarr store intended for easy streaming access.

  • Source: CellxGene Census API
  • Organism: Homo sapiens
  • Filter: tissue_general == 'lung' and is_primary_data == True
  • Shape: 100,000 cells × 61,497 genes
  • Zarr path: lung.zarr

Compression

  • Uncompressed (dense float32): 22.91 GB
  • Compressed Zarr: ~307 MB (322 MB on Hub)
  • Compression ratio: ~76× (Blosc zstd on sparse single-cell data)

The high compression ratio is achieved through Blosc zstd compression optimized for sparse expression matrices typical in single-cell RNA-seq data.

Included labels

  • obs/cell_type
  • obs/disease
  • obs/tissue
  • obs/sex
  • obs/assay

Cell type distribution (top 25)

cell_typen_cells
neuron8,037
oligodendrocyte4,890
fibroblast4,539
glutamatergic neuron3,367
macrophage2,216
endothelial cell1,941
astrocyte1,808
natural killer cell1,803
T cell1,734
malignant cell1,625
GABAergic neuron1,589
classical monocyte1,562
basal cell of prostate epithelium1,401
myeloid cell1,379
plasma cell1,263
epithelial cell of proximal tubule1,185
adipocyte of omentum tissue1,170
microglial cell1,164
acinar cell of salivary gland1,074
oligodendrocyte precursor cell1,044
monocyte1,036
blood vessel endothelial cell982
pericyte942
subcutaneous adipocyte932
CD8-positive, alpha-beta T cell830

Disease labels included

Total unique disease labels: 72

text
Alzheimer disease
B-cell acute lymphoblastic leukemia
Barrett esophagus
COVID-19
Crohn disease
Down syndrome
HIV infectious disease
HIV infectious disease || leishmaniasis
HIV infectious disease || visceral leishmaniasis
Lewy body dementia
Parkinson disease
Wilms tumor
acute myeloid leukemia
acute promyelocytic leukemia
adenocarcinoma
age related macular degeneration 7
anencephaly
arrhythmogenic right ventricular cardiomyopathy
atrial fibrillation || mitral valve insufficiency
basal cell carcinoma
basal laminar drusen
benign prostatic hyperplasia
breast cancer
breast carcinoma
cataract
chromophobe renal cell carcinoma
clear cell renal carcinoma
colon adenocarcinoma
colon sessile serrated adenoma/polyp
colorectal cancer
common variable immunodeficiency
cytomegalovirus infection
dementia
dilated cardiomyopathy
enamel caries
gastric intestinal metaplasia
gastritis
glioblastoma
hyperplastic polyp
hypertrophic cardiomyopathy
influenza
invasive ductal breast carcinoma
invasive lobular breast carcinoma
leukoencephalopathy, diffuse hereditary, with spheroids 1
long COVID-19
luminal A breast carcinoma
luminal B breast carcinoma
macular degeneration
malignant ovarian serous tumor
multiple sclerosis
myocardial infarction
myocarditis
neuroblastoma
neuroendocrine carcinoma
non-compaction cardiomyopathy
normal
obstructive nephropathy
oral cavity squamous cell carcinoma
pilocytic astrocytoma
plasma cell myeloma
prediabetes syndrome
prostatic acinar adenocarcinoma
pulmonary emphysema
pulpitis
respiratory failure
rheumatoid arthritis
temporal lobe epilepsy
triple-negative breast carcinoma
tubular adenoma
tubulovillous adenoma
type 2 diabetes mellitus
ulcerative colitis

Data layout

  • Expression matrix: X (dense 2D array)
  • chunks: (1000, 1000)
  • dtype: float32
  • compression: Blosc zstd
  • Metadata:
  • obs/_index, obs/<col> (or obs/<col>_codes + obs/<col>_categories for categoricals)
  • var/_index, var/<col> (or var/<col>_codes + var/<col>_categories for categoricals)

Loading (zarr → AnnData)

python
import zarr
import numpy as np
import pandas as pd
from anndata import AnnData

root = zarr.open_group("lung.zarr", mode="r")
X = root["X"]  # zarr Array (lazy / on-demand)

obs = pd.DataFrame(index=root["obs/_index"][:].astype(str))
for col in ["cell_type", "disease", "tissue", "sex", "assay"]:
    codes_key = "obs/" + col + "_codes"
    cats_key = "obs/" + col + "_categories"
    if codes_key in root and cats_key in root:
        obs[col] = pd.Categorical.from_codes(root[codes_key][:], root[cats_key][:].astype(str))
    elif "obs/" + col in root:
        obs[col] = root["obs/" + col][:].astype(str)

var = pd.DataFrame(index=root["var/_index"][:].astype(str))
for col in ["feature_name", "feature_id", "gene_symbol"]:
    key = "var/" + col
    if key in root:
        var[col] = root[key][:].astype(str)

# Convert to in-memory AnnData (loads full matrix):
adata = AnnData(X=np.asarray(X), obs=obs, var=var)

Scanpy workflow example

python
import scanpy as sc

sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)
sc.pp.highly_variable_genes(adata, n_top_genes=2000, flavor="seurat_v3")
adata = adata[:, adata.var["highly_variable"]].copy()

sc.pp.scale(adata, max_value=10)
sc.tl.pca(adata, svd_solver="arpack")
sc.pp.neighbors(adata, n_neighbors=15, n_pcs=50)
sc.tl.umap(adata)
sc.tl.leiden(adata, resolution=0.5)

Streaming benchmark (single 1000×1000 chunk)

Measured locally while building this dataset:

  • open Zarr group: 0.0021 s
  • read one X[chunk] (1000×1000): 0.0864 s
json
{
  "open_seconds": 0.0021242350339889526,
  "read_chunk_seconds": 0.08641284704208374,
  "chunk_shape": [
    1000,
    1000
  ],
  "chunk_origin": [
    84212,
    38534
  ],
  "shape": [
    100000,
    61497
  ]
}

Build metadata

json
{
  "census_version": "2025-11-08",
  "created_at": "2026-02-03T06:49:50.898169+00:00",
  "max_cells": 100000,
  "n_hvg": 0,
  "obs_value_filter": "tissue_general == 'lung' and is_primary_data == True",
  "organism": "Homo sapiens",
  "schema_version": "1.0",
  "seed": 0,
  "source": "cellxgene-census",
  "x_chunks": [
    1000,
    1000
  ],
  "x_compression": {
    "clevel": 3,
    "cname": "zstd",
    "codec": "blosc",
    "shuffle": "bitshuffle"
  },
  "shape": [
    100000,
    61497
  ],
  "obs_arrays": [
    "_index",
    "assay",
    "cell_type",
    "disease",
    "sex",
    "tissue"
  ],
  "var_arrays": [
    "_index",
    "feature_id",
    "feature_length",
    "feature_name",
    "feature_type",
    "n_measured_obs",
    "nnz",
    "soma_joinid"
  ]
}

Upload to HuggingFace Hub

This repo is intended for: KokosDev/single-cell-lung-zarr.

If you have a HuggingFace token locally, upload with:

bash
python3.11 -m pip install huggingface_hub
HF_TOKEN=*** python3.11 build_lung_zarr.py --upload --repo-id "KokosDev/single-cell-lung-zarr"