Skip to content

Restore scGen batch-removal tutorial#66

Open
Zethson wants to merge 1 commit into
mainfrom
restore/scgen-batch-removal
Open

Restore scGen batch-removal tutorial#66
Zethson wants to merge 1 commit into
mainfrom
restore/scgen-batch-removal

Conversation

@Zethson

@Zethson Zethson commented Jun 26, 2026

Copy link
Copy Markdown
Member

Restores scgen_batch_removal.ipynb, which was removed in 4ef5318 (Nov 2023), and updates it for the current pertpy API and kang_2018 schema.

What changed vs the old notebook

  • Uses the exposed pt.tl.Scgen (the old pt.tl.SCGEN alias isn't routed by pt.tl).
  • batch_key="label" (ctrl/stim) + labels_key="cell_type" — the old batch/celltype columns no longer exist in kang_2018.
  • Proper log-normalization; raw kept in .raw.
  • Subsamples to 4,000 cells / 2,000 HVGs so the notebook executes in ~2 minutes on CPU (the old version trained on the full dataset for 100 epochs).
  • accelerator="cpu" in train().
  • Final marker plot uses ISG15 (this is PBMC data; the old INS is a pancreas gene).

Why now

pertpy's JAX scGen previously did not reproduce PyTorch scGen (see scverse/pertpy#1028). With that fixed, the batch-removal demo is meaningful again.

Outputs were regenerated by executing the notebook end-to-end (no errors).

Pairs with a pertpy PR that bumps this submodule and adds the notebook to the tutorials gallery.

🤖 Generated with Claude Code

Re-add scgen_batch_removal.ipynb (removed in 4ef5318), updated for the
current pertpy API and kang_2018 schema:

- use the exposed `pt.tl.Scgen` name
- `batch_key="label"`, `labels_key="cell_type"` (the old `batch`/`celltype` columns are gone)
- log-normalize and subsample to 4,000 cells / 2,000 HVGs so it runs in ~2 minutes
- `accelerator="cpu"`

Outputs regenerated with pertpy's scGen, which now reproduces PyTorch scGen.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

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.

1 participant