V1 prep#149
Open
parashardhapola wants to merge 37 commits into
Open
Conversation
- Added entries to .gitignore for *.egg-info, .venv, .ruff_cache, and coverage files. - Removed the coverage.xml file as it is no longer needed. - Updated pyproject.toml to include 'obstore' in optional dependencies. - Modified various files to implement prefetching of blocks for improved performance in data processing. - Introduced a new method in RNAassay for saving normalized data with optional renormalization. - Enhanced data handling in several modules to support new storage options and improve efficiency.
Cache executed myst-nb outputs under docs/.jupyter_cache so Read the Docs can build with nb_execution_mode=cache. Add local execute scripts, replace gensim LSI with TruncatedSVD, fix integrate_assays and get_markers compat, auto-compute norm stats for mapping, and resolve zarr v2 CORAL writes. Co-authored-by: Cursor <cursoragent@cursor.com>
…nhance mypy configuration and add new dependencies for development. Refactor print statements in documentation scripts for improved readability. Clean up notebook code for consistency in string formatting and function calls.
- Updated .gitignore to include test environment files and prevent unnecessary tracking. - Removed 'joblib' dependency from pyproject.toml and uv.lock to streamline requirements. - Introduced a new method in RNAassay for optimized reading of blocks from zarr arrays, improving data access efficiency. - Refactored marker statistics computation in markers.py to utilize Numba for performance gains. - Adjusted plotting functions to handle groupings more effectively and improve visual output. - Enhanced DataStore class to support memory budget configurations for better resource management during data processing.
- Introduced a new script to download bundled test datasets for CI and local development. - Updated the GitHub Actions workflow to include a step for downloading test fixtures before running tests with pytest. - The new script allows for optional downloading of specific datasets, enhancing test setup flexibility.
- Added a new function to build and compress a directory fixture for the 1K PBMC CITE-seq dataset, including matrix and feature files. - Integrated the new fixture creation into the existing download process to ensure availability for tests. - Updated test prefetching to set a resource budget for improved performance during testing.
…llel IO Replace static per-profile chunk/shard tables and one-off prefetch/thread loops with matrix_layout() and shared parallel.py primitives (map_shards, stream_shards), plus staged-normed mirroring to avoid a remote read-back.
The fixture was gitignored, so CI downloaded the stale copy from master and failed after deterministic marker sorting changed tie order. Co-authored-by: Cursor <cursoragent@cursor.com>
Avoid live notebook execution on memory-constrained builders and replace broken image substitutions with valid links. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Scarf 1.0 is a storage and I/O rewrite for reliable local and cloud analysis at atlas scale, plus API hardening, mapping/reference tooling, and a much larger test surface. Existing Zarr v2 datasets remain fully usable. Most day-to-day
DataStoreworkflows keep the same call sites. Migration cost is mainly environment (Python 3.12+), Dask removal, and a small set of renamed or clarified APIs.Migration guide (start here)
1. Environment
requirements.txt+setup.pymetadatapyproject.tomlpip install scarf[extra]uv pip install scarf[extra](pip still works)Removed dependencies:
dask,polars,pyarrow,joblib,importlib_metadata,gensim(extra),cmocean(extra).Major upgrades:
zarr<=2.16→zarr>=3.1.2,numpy==1.26→numpy>=2,numcodecs>=0.16, plusobstorefor object-store URIs.conda create -n scarf_v1 python=3.12 conda activate scarf_v1 uv pip install 'scarf[extra]'2. Existing Zarr stores (no conversion required)
Open your current
.zarrwith Scarf 1.0 as usual. Zarr Python 3 reads v2 layouts; Scarf wraps arrays withChunkedArrayinstead of Dask.finalize_sharded_counts) no-ops on v2 groups.Optional performance upgrade only: if you want a new Zarr v3 copy with sharded counts (better local throughput or object-store IO), use:
uv run python -m scarf.tools.repack_zarr old.zarr new.zarr --profile fast_local # cloud-oriented compressors / layout: uv run python -m scarf.tools.repack_zarr old.zarr new.zarr --profile cloudThis writes a separate output store. It is not part of the upgrade path and is unnecessary for users who already hold large archives and are happy with current IO.
New ingest (
CrToZarr,H5adToZarr, merge, etc.) writes Zarr v3 and finalizes sharded counts automatically. That applies to newly created datasets, not to upgrading existing ones.3. Replace Dask usage
Assay.rawData,normed(), andsave_normalized_data()returnscarf.chunked.ChunkedArray, notdask.array.Array.Custom normalization callables must be
(Assay, ChunkedArray) -> ChunkedArray.Names kept for compatibility (no Dask underneath):
dask_to_zarr,show_dask_progress.4. Imports: no more star exports
scarf/__init__.pyno longer doesfrom .readers import *(and similar). Use the explicit public surface or submodule imports.Notable removals:
MetaData.to_polars_dataframe(polars removed; useto_pandas_dataframe)from scarf import *for every submodule helper5. Cloud and memory knobs (new, optional)
Writers (
CrToZarr,H5adToZarr,DatasetMerge, …) accept the samestorage_options/mem_budget/working_copiespattern.On Zarr v3 writers,
chunk_size=(1000, 1000)remains in the signature but is largely advisory: geometry comes from the memory budget. On existing v2 stores, prior chunking is left alone.6. API renames and clarifications
ZarrMergeAssayMerge(ZarrMergestill works, warns)metric_integration(...)metric_label_concordance(...)(same ARI/NMI between two label columns). For neighborhood batch mixing usemetric_batch_mixing(...)metrics.integration_scoremetrics.label_concordance_scorerun_mapping(..., exclude_missing=True)missing_feature_policy="intersection"run_mapping(..., run_coral=True)ref_mu/ref_sigmacmocean.cm.matter_rmagma_r(cmocean removed)7. Mapping defaults that can change results
Several mapping helpers now resolve
cell_key=Nonevia the latest graph keys instead of hard-coding"I":run_mapping,get_mapping_score,get_target_classesrun_unified_umap,run_unified_tsne,load_unified_graphIf you relied on implicit
"I"while your latest graph used another cell key, passcell_key="I"explicitly.missing_feature_policyfor ordinary mapping:"zero"(default when unset),"intersection", or"error". Harmonized /MappingReferencepaths additionally support"reference_mean"(their neutral default).8. When to recompute (correctness, not storage format)
You do not need to rebuild stores to upgrade. Recompute only if you depend on these fixed or redesigned paths:
integrate_assays(..., method="wnn")) – internal weighting and k handling were rewritten. Old WNN graphs still load; rebuild if you want the corrected behavior.compact_v2. Legacy marker tables still read. Re-runrun_marker_searchonly if you want the new layout.build_mapping_referencethenrun_mapping/MappingReference.map_query. Legacy graphs without a reference artifact may auto-rebuild once (needszarr_mode="r+").ann_idx_bytes. Legacy filesystemann_idxis still found and can be migrated on read.9. Signature / default gotchas
load_zarr(..., synchronizer=...)still acceptssynchronizerbut ignores it under Zarr v3 (debug log only). Multi-process concurrent writes viaThreadSynchronizerare not on the supported path.ZARRLOCis nowstr | zarr.abc.store.Store(nozarr.LRUStoreCache).Suggested upgrade path
scarf[extra].filter_cells→mark_hvgs→make_graph→run_umap.ZarrMerge/metric_integration-as-batch-mixing usage.build_mapping_reference; usemetric_batch_mixingfor batch QC.repack_zarr. Skip this for large archives unless you have a measured need.Breaking changes (checklist)
ChunkedArray.MetaData.to_polars_dataframeremoved.chunk_sizeno longer owns count/norm geometry (memory budget does).cell_keydefaults and feature-missing policy semantics (see above).Behavioural changes (same API, different outcomes)
working_copies(default 8). Normed matrices use full-width row chunks, no shards.fast_local→ Blosc/LZ4+bitshuffle;cloud→ Zstd. EnvSCARF_ZARR_PROFILE.local_cache="auto": remote stores stage the normed matrix locally before PCA/ANN/kNN.log-sum-exp),min(k1,k2), finite checks.ss_vecvalidation; numeric finite regressor checks for pseudotime markers.peaks_coordsskips BED parse.storage_options.sort_marker_resultson load; optional prefetch. Legacy marker Zarr trees still load.magma_r.metric_integration: documentation and deprecation clarify it was always label concordance (ARI/NMI), not batch mixing.New features
Cloud-native Zarr
Open and write
s3:///gs://(and other obstore URLs) throughDataStoreand writers withstorage_options. Remote-aware column-block pipelines and local staging for normed matrices.Mapping reference + Symphony-style query correction
Also new:
get_target_label_evidence(vote fractions, entropy, conformal sets)calibrate_label_transfer_thresholdproject_mapping_layout(place query on a fixed reference UMAP/tSNE)Doublet detection
Simulates doublets, maps them, scores cells, optionally smooths on the graph.
Integration metrics
Harmony API surface
Documented
run_harmony,fit_harmony,HarmonyResult;make_graph(..., harmony_params=...)for graph builds.Optional repack tool
python -m scarf.tools.repack_zarrcreates a new v3 store with optional count sharding. Use when you want performance characteristics of the new layout; not required to keep using existing data.Under the hood (for maintainers)
scarf.storage.zarr_store,scarf.storage.budget,scarf.chunked,scarf.parallel,scarf.symphony,scarf.mapping_reference,scarf.doublet_utils,scarf.tools.repack_zarr,scarf._types.finalize_writer_countsafter ingest on v3 groups (skipped on v2).AnnStreamfor mapping/metrics.VERSION, optional dependency groupsextra/test/docs, uv lockfile).scarf/.Bug fixes and impact
component_policy; component handling__validmaskcompleteflagMappingReferencepersistence + auto rebuildgene_batch_sizeHNSWLIB_NO_NATIVE/ build pins in CI and uvmetric_integrationsounded like batch mixingTests, coverage, and CI
Tests: ~9 modules under
scarf/tests→ ~40 under top-leveltests/(~9.8k lines of test code). New coverage includes Zarr store / budget / chunked / parallel / prefetch, ephemeral datastore, graph coverage and cache, mapping (label transfer, reference, Symphony golden JSON), merger, markers, metrics, meld, readers/writers, doublet paths, pseudotime, UMAP/Harmony, knn utils, renorm subset, and repack.Fixtures are downloaded in CI (
tests.download_fixtures) instead of shipping large binaries in-repo.CI (
pytest.yml):pytest-xdist)scarf→ Codecov-m 'not integration')Documentation and packaging
README.md(replaces RST / pypi README split)repack_zarr,mem_budgetapi.md(MappingReference, Harmony, metrics, merge, meld, utilities, plots)Deprecations (still work in 1.0)
ZarrMerge→ useAssayMergeDataStore.metric_integration→metric_label_concordanceormetric_batch_mixingmetrics.integration_score→label_concordance_scorerun_mapping(exclude_missing=...),run_coral=True,ref_mu/ref_sigmadask_to_zarr/show_dask_progress(Dask-free implementations)