Add gene_symbols parameter to render_shapes, render_points, render_labels#578
Merged
Add gene_symbols parameter to render_shapes, render_points, render_labels#578
Conversation
…bels (#247) Allow coloring by gene symbols when var_names are ENSEMBL IDs, mirroring scanpy's gene_symbols parameter. When provided, the code looks up the color key in the specified adata.var column and maps it back to the actual var_name before proceeding with the normal rendering pipeline. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Avoid mutating col_for_color inside the auto-detect loop — resolve gene symbol to var_name only once after the table is selected. Add non-visual tests for the auto-detect path, missing symbol, and missing column error cases. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…t loop Avoid calling _resolve_gene_symbols twice for the winning table by caching the result during the filtering loop. Add a warning when a gene symbol maps to multiple var_names. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Generated from CI runner (py3.11-stable). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #578 +/- ##
==========================================
+ Coverage 75.36% 75.51% +0.15%
==========================================
Files 10 10
Lines 2935 2986 +51
Branches 684 699 +15
==========================================
+ Hits 2212 2255 +43
- Misses 441 445 +4
- Partials 282 286 +4
🚀 New features to boost your workflow:
|
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
gene_symbolsparameter torender_shapes(),render_points(), andrender_labels(), mirroring scanpy's established patternvar_namesare ENSEMBL IDs, users can now color by gene symbols stored in avarcolumn (e.g.,color="TP53", gene_symbols="gene_symbol")gene_symbols=None(default) preserves all existing behaviorCloses #247
How it works
When
color="TP53"isn't found inobs.columnsorvar_names, andgene_symbols="gene_symbol"is provided, the code looks up"TP53"inadata.var["gene_symbol"], maps it to the corresponding var_name (index), and proceeds with normal rendering. This happens in_validate_col_for_column_table()via a new_resolve_gene_symbols()helper.