Repository navigation
Support non-perturbed scRNA-seq and mouse data - #20
Open
OlgaPushkarev wants to merge 4 commits into
Open
OlgaPushkarev wants to merge 4 commits into
OlgaPushkarev wants to merge 4 commits into
Conversation
Non-perturbed data (no guide information): - K-selection: new --no_trait / --no_perturbation flags skip the trait and perturbation inputs and plots; the shared regulator row is factored into _plot_regulator_row and hidden when there is no perturbation data. - Program analysis: tolerate a missing uns['guide_targets']. - Excel summary: skip the Targets Summary sheet (and the specificity scores it writes) when there are no guides; fall back to var_names when the gene symbol column is absent. - Evaluation: fail early with a clear message when --Perform_perturbation is requested without guide information. Mouse data: - Mouse genes are matched to human gene-set libraries and gene summaries through curated orthologs (union of MGI and Ensembl, new orthologs.py) instead of upper-casing symbols. The table is downloaded once and cached in src/Stage2_Evaluation/Resources/; --ortholog_table pins a fixed copy. Genes without a human ortholog are excluded from enrichment; one-to-many orthologs keep all human genes. MSigDB mouse gene sets keep mouse symbols. - Excel summary: --organism mouse annotates genes with their human orthologs' MyGene summaries and a 'Human ortholog' column. - Evaluation: trait (GWAS) enrichment is human-only and is skipped with a message for other organisms. - Plotting utilities: honor the species argument of the MyGene helpers. Human runs are unchanged: existing Stage 2/3 tests give identical per-test outcomes before and after, and human evaluation outputs match apart from gene order within the Genes column and last-digit rounding. Tests: tests/Script/test_non_perturbed.py and tests/Script/Stage2_Evaluation/test_orthologs.py (synthetic data, offline). Docs: README section on non-perturbed and mouse data, parameter tables. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Data converted from Seurat stores its embeddings as obsm['UMAP'] / obsm['PCA'] (often as DataFrames), which scanpy does not see, so program and perturbed-gene plots recomputed a different UMAP. ensure_umap now copies such embeddings to 'X_umap' (first two columns) / 'X_pca' before deciding whether to compute one. Existing X_umap/X_pca entries and the original keys are left untouched; files without these keys behave as before. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- orthologs.py: require BioMart's completion stamp so a truncated Ensembl response is rejected instead of cached; write the cache atomically (temp file + os.replace) so parallel jobs never read a partial table; on download failure, point to --ortholog_table. - Excel summary: map all top genes to orthologs once instead of once per program. - --organism accepts only human/mouse (case-insensitive) in evaluation and the Excel summary. - Evaluation checks for guide information in every h5mu before computing any metric when --Perform_perturbation is set. - run_add_umap.sh: correct the header (no SBATCH_MAIL_USER; create the log directory on the manual path); search_nature.py: generic data-source text. - Docs: CHANGELOG entries; README notes that program plots without perturbation results need PDF/SVG output and that custom gene sets for mouse data must use human symbols; Human ortholog column documented. - Tests for the download handling, organism validation, and the early guide check. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- Evaluation guide pre-check: if the --prog_key modality is not in the h5mu, say so instead of reporting missing guide information. - orthologs.py: remove the temporary file if writing the cache fails. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This was referenced Oct 10, 2026
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.
Summary
Lets the pipeline run on scRNA-seq data without perturbations (no guide information) and on mouse data. Human perturbation runs are unchanged.
Third of three stacked PRs. It is based on #19 (
ruff format), which is based on #18 (lab-content cleanup). Merge those first; GitHub then retargets this PR tomain. Replaces #17.Non-perturbed data (no guides)
--no_perturbationand--no_traitflags skip the perturbation and trait inputs and their plots. The regulator row shared by both panel functions is moved into one helper and hidden when there is no perturbation data.uns['guide_targets']is handled; perturbed-gene annotations are left empty, with a message.var_nameswhen the--gene_names_keycolumn is absent.--Perform_perturbation, every input h5mu is checked for guide information before any metric runs, with a clear error. A wrong--prog_keyis reported as such.Mouse data
src/Stage2_Evaluation/A_Metrics/src/orthologs.py): mouse genes are matched to the human Enrichr libraries and to human gene summaries through orthologs (the union of MGIHOM_MouseHumanSequenceand Ensembl BioMart homologs), instead of upper-casing symbols. Upper-casing misses orthologs with different names (e.g.Zfp451→ZNF451, mouseH2-*→ humanHLA-*) and sometimes picks a non-orthologous human gene.src/Stage2_Evaluation/Resources/;--ortholog_tablepins a fixed copy.--ortholog_table.--organism: accepts onlyhumanormouse(case-insensitive) in evaluation and the Excel summary.--organism mouse, each gene is annotated with its human orthologs' MyGene summaries, in a newHuman orthologcolumn.speciesargument.Other changes
ensure_umapreuses embeddings stored asobsm['UMAP']/obsm['PCA'](e.g. Seurat conversions) instead of computing a different UMAP.Testing
New tests (synthetic data, offline):
tests/Script/test_non_perturbed.pytests/Script/Stage2_Evaluation/test_orthologs.pytests/Script/Stage3_Interpretation/A_Plotting/Program/test_ensure_umap.py25 tests, all passing. Against the previous code, the tests for new behavior fail and the tests for unchanged behavior pass.
Regression:
main's.End to end: a 4,000-cell subsample of a public mouse endothelial scRNA-seq dataset without perturbations ran through inference, evaluation, K-selection, program analysis and the Excel summary. With ortholog mapping:
Cd74,H2-Ab1,H2-Aa,H2-Eb1,Ciita) is correctly annotated as antigen presentation. Upper-casing had dropped itsH2-*genes and returned "regulation of cell migration".An independent review of the changes was done before opening.
Pre-existing issues (not changed here)
mainbecause they are stale (see also Fix stale tests and empty significant-programs crash #15).Biomartclient currently fails ("Method Not Allowed") because www.ensembl.org redirects.get_idconversionuses it for Ensembl-ID-to-symbol conversion and falls back silently. The new ortholog code queries an Ensembl mirror directly.cNMF_program_analysis.pyrejects--output_format HTMLwithout--perturb_path_base, although the HTML exporter now handles missing perturbation data. The README documents using PDF/SVG for now; relaxing the guard could be a follow-up.🤖 Generated with Claude Code