Repository navigation
Support non-perturbed scRNA-seq and mouse data - #17
Closed
OlgaPushkarev wants to merge 5 commits into
Closed
OlgaPushkarev wants to merge 5 commits into
OlgaPushkarev wants to merge 5 commits into
Conversation
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Applies 'ruff format' (default black-compatible style, line length 88) to every tracked .py file so later changes have small, reviewable diffs. Notebooks are untouched. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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>
Author
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.
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, ascompute_kd_efficiencyalready does.--Perform_perturbationwithout guide information now fails early with a clear message.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. Details:src/Stage2_Evaluation/Resources/;--ortholog_tablepins a fixed copy.organismvalues other thanhuman/mousenow raise a clear error.--organism mouseannotates each gene with its human orthologs' MyGene summaries and a newHuman orthologcolumn.speciesargument.Other changes
ensure_umapreuses embeddings stored asobsm['UMAP']/obsm['PCA'](e.g. Seurat conversions) instead of computing a different UMAP.ruff formatof all tracked.pyfiles, as a separate format-only commit, listed in.git-blame-ignore-revssogit blameskips it. Reviewing commit by commit (orgit diff -w) is easiest: the feature changes are in the last two commits.--cell_typehelp string.Testing
New tests (synthetic data, offline):
tests/Script/test_non_perturbed.py(7)tests/Script/Stage2_Evaluation/test_orthologs.py(9)tests/Script/Stage3_Interpretation/A_Plotting/Program/test_ensure_umap.py(3)All pass. Against the previous code, the tests for new behavior fail and the tests for unchanged behavior pass.
Regression: the existing Stage 2 metrics and Stage 3 suites (146 tests) give identical per-test outcomes before and after, on the same torch-cNMF test inference output. On human test data, the evaluation outputs match the previous code exactly (same rows and p-values), except gene order within the
Genescolumn and last-digit rounding ofCombined Score.End to end: a 4,000-cell subsample of a public mouse endothelial scRNA-seq dataset with no 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".Pre-existing issues (not changed here)
mainbecause they are stale (load_perturbation_data(samples=...),plot_top_program_per_geneerror expectations, and inference output files that are no longer written).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 and is not affected.tools/check_no_lab_specific_content.pyreports pre-existing hits onmain(mostly user and study paths in.shrunners).🤖 Generated with Claude Code