Fix mle ValueError on count tables with spaces in sgRNA/gene names (#7)#8
Merged
Merged
Conversation
read_gene_from_file split count-table lines on generic whitespace, while the rest of mageck2 (e.g. mageckCount.py) splits on tab. When an sgRNA or gene name contains a space -- common for control entries such as "Non-Targeting Control" in a with-control library -- the whitespace split shifts the count columns, a non-numeric token is read as a count, and the ValueError was silently swallowed without appending. That left nb_count ragged and later crashed in np.matrix() with an opaque "inhomogeneous shape" error. RRA (mageck2 test) was unaffected because it splits on tab. - Split non-CSV count tables on '\t', consistent with the rest of mageck2. - Fail loudly with line/column/value context on an unparseable count instead of silently producing a ragged matrix. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Fixes #7.
Problem
mageck2 mlecrashes with a cryptic numpy error on a count table thatmageck2 test(RRA) parses fine:from
np.matrix(ginst.nb_count)inread_gene_from_file.Root cause
read_gene_from_filesplit count-table lines on generic whitespace (line.strip().split()), while the rest of mageck2 splits on tab (e.g.mageckCount.py,splitter='\t').When an sgRNA or gene name contains a space — common for control entries such as
Non-Targeting Controlin a with-control library — the whitespace split shifts the count columns. A non-numeric token (Control) is then read as a count;float()raisedValueError, which was silently swallowed without appending. That left one sample's list one element short, makingnb_countragged and crashing later innp.matrix(). RRA was unaffected because it splits on tab.Reproduced with a minimal table containing a spaced gene name; the real
read_gene_from_filenow parses it correctly.Changes
\t, consistent with the rest of mageck2 (the actual fix).🤖 Generated with Claude Code