fix: report No_mutability genes correctly and avoid UnboundLocalError#101
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes reporting for genes that are skipped due to missing mutability information during clustering, ensuring they are correctly identified and their mutation counts are populated.
Changes:
- Fixes the logic that computes
genes_not_mutabilityso it’s derived from the pre-filtergenes_to_processlist (previously it could be incorrectly empty). - Improves membership checks by caching
seq_dfgene values into asetfor faster lookups. - Populates
Mut_in_geneforNo_mutabilitygenes using the actual per-gene mutation counts instead ofNaN.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
When running with mutabilities, Oncodrive3D filters the sequences dataframe to keep only the genes with reference info available (needed to compute mutabilities). Genes dropped at this step should be reported in the output with status
No_mutability. However, there was an order-of-operations bug: the list of dropped genes was built after the filter had already been applied, so it always ended up empty. As a result, theNo_mutabilitystatus had effectively never been triggered in any run, and dropped genes silently disappeared from the output.This became visible when a user (running Oncodrive3D within deepCSA) hit a case where all genes were dropped at this step. With nothing left to cluster and nothing reported as filtered out, the code fell into a branch that referenced a variable that was never assigned →
UnboundLocalError.closes #86
Fix
genes_to_processis filtered. They will now be correctly reported with statusNo_mutability, and the crash goes away as a side effect.Mut_in_genewith the actual mutation count forNo_mutabilityentries (wasNaN), matching how the other non-processed status blocks (No_mut,No_ID_mapping,Fragmented) already behave.