YurimJung's picture
Update README.md
1554f83 verified
|
Raw History Blame Contribute Delete
4.21 kB
---
pretty_name: MetacellFormer pretraining corpus
tags:
- single-cell
- metacell
---
# MetacellFormer pretraining corpus
This repository provides the **818,609 metacell profiles** used for MetacellFormer pretraining, constructed by summing raw counts from **44,389,000 cells** across **1,334 source datasets**. It also provides the source-cell memberships and fixed training–validation split: 799,562 metacells for training and 19,047 for validation. The matrices preserve the gene features and expression values used in the study.
## Contents
| File | Contents |
|---|---|
| `source_manifest.tsv` | Source accessions, citations, releases, terms, sizes and relative file paths |
| `metacells/{dataset_id}.h5ad` | Sparse raw-count sums in `X`; gene IDs and symbols in `var`; constituent cell counts and split in `obs` |
| `memberships/{dataset_id}.tsv.gz` | `source_cell_id`, `metacell_id`, in the selected source-cell order |
| `splits/{dataset_id}.tsv.gz` | `profile_id`, `split`, in metacell row order; `train` or `eval` for the tokenizer |
| `checksums.sha256` | SHA-256 file checksums |
IDs are unique within a source dataset; use `(dataset_id, ID)` across sources. `eval` in the split files means validation. Metacell matrices are unnormalized sums, not mean expression or log-transformed values. Keep all supplied features when computing the normalization denominator.
## Use
After installing the GitHub package in `MetacellFormer-env`, choose a row of `source_manifest.tsv` and use its `metacell_file`, `split_file` and `dataset_idx`:
```bash
python scripts/tokenize_training.py \
--input CORPUS/metacells/DATASET_ID.h5ad \
--split CORPUS/splits/DATASET_ID.tsv.gz \
--dataset-id DATASET_ID --dataset-idx DATASET_INDEX \
--model-dir MODEL_DIRECTORY --output-dir tokens/DATASET_ID
```
`MODEL_DIRECTORY` supplies the vocabulary, reference medians and fixed value-bin edges. Check downloaded files with `sha256sum -c checksums.sha256`.
## Reconstructing source counts
Full single-cell matrices are obtained from the original providers. The releases are **CELLxGENE Census 2025-11-08** and **scBaseCount 2026-01-12**. Source selection and MetaQ membership are already fixed; do not draw a new sample or rerun MetaQ to reproduce this corpus.
- **CELLxGENE:** `source_cell_id` is the decimal row index of the dataset-specific filtered Census export, **not** a Discover barcode or a Census `soma_joinid`. Use the Census release above, `X_name="raw"`, the exact `source_filter` in the manifest, and retain the complete Census gene axis with `feature_id`. The original export used `cellxgene_census.get_anndata` with observation metadata excluding `soma_joinid`, producing sequential string row IDs. Preserve this row order and check its row count against `source_input_cells`. A current Discover download is not interchangeable with this view.
- **scBaseCount:** `source_cell_id` is the source H5AD observation name. The manifest links the pinned `Gene/Homo_sapiens` file. Follow the [provider's access instructions](https://github.com/ArcInstitute/arc-virtual-cell-atlas/tree/main/scBaseCount) if its bucket requires an authenticated billing project.
Prepare the selected source matrix and aggregate using the published memberships:
```bash
python scripts/prepare_corpus_source.py --input upstream_counts.h5ad \
--corpus-root CORPUS --dataset-id DATASET_ID --output selected_counts.h5ad
python scripts/aggregate_metacells.py selected_counts.h5ad \
CORPUS/memberships/DATASET_ID.tsv.gz reconstructed.h5ad --source-id DATASET_ID
```
The preparation command checks cell IDs and the frozen gene universe. Specify `--counts-layer` if needed. It reads chunks; the selected sparse output remains in memory. The aggregation command sorts metacell IDs lexically, so compare reconstructed and released matrices **after alignment by metacell ID and gene ID**.
## Attribution and terms
CELLxGENE-derived data retain **CC BY 4.0**; scBaseCount data retain **CC0 1.0**. Original source citations and terms are recorded per dataset in the manifest. Changes comprise the recorded cell selection, metacell raw-count summation, fixed split and reduced metadata. See [LICENSES.md](LICENSES.md).