Skip to content

Round-trip analysis results through AnnData - #21

Merged
parashardhapola merged 1 commit into
masterfrom
pr/06-anndata-round-trip
Oct 22, 2026
Merged

parashardhapola merged 1 commit into
masterfrom
pr/06-anndata-round-trip

Conversation

@parashardhapola

Copy link
Copy Markdown
Member

Exports could not carry analysis results, cluster labels exported as integers (so scanpy's rank_genes_groups failed), categoricals and colours were lost on import, and external latents could not be imported.

Changes

  • to_anndata and to_h5ad take obsm, obs, graph, cell_selection, and dtype: PCA (with varm["PCs"] and uns["pca"]), UMAP, labels as categoricals with colours, and graphs in scanpy's obsp layout with uns["neighbors"], checked against the memory budget.
  • Run exports write labels as string categoricals with the run's colours and add the run's PCA and Harmony correction.
  • Imports keep categories, order, ordered, and colours; reduction.import_coordinates imports an external latent space, such as scVI's, aligned by cell ID.
  • An index that is neither the ID nor the name column no longer imports as _index; count matrices are chosen by conventional name, with a warning when several hold counts; repeated obs names import with duplicate_cell_ids="make_unique"; to_mtx is faster.

Behaviour changes

  • Exports of uint8 and uint16 counts are float32 unless dtype says otherwise.
  • Run exports change shape (categorical labels, PCA added).
  • H5AD inspection is stricter: negative integers are not counts, and a repeated index raises at import unless made unique.

Exports could not carry analysis results, cluster labels exported as integers (so scanpy's `rank_genes_groups` failed), categoricals and colours were lost on import, and external latents could not be imported.
@parashardhapola
parashardhapola changed the base branch from pr/05-pca to master October 22, 2026 22:01
@parashardhapola
parashardhapola force-pushed the pr/06-anndata-round-trip branch from 54db073 to 045ed66 Compare October 22, 2026 22:01
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@parashardhapola
parashardhapola merged commit 5b13bd6 into master Oct 22, 2026
24 checks passed
@parashardhapola
parashardhapola deleted the pr/06-anndata-round-trip branch October 22, 2026 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants