Skip to content

Refuse the disabled Bayes options instead of ignoring them - #37

Merged
davidliwei merged 2 commits into
mainfrom
fix/reject-disabled-bayes-flags
Aug 31, 2026
Merged

Refuse the disabled Bayes options instead of ignoring them#37
davidliwei merged 2 commits into
mainfrom
fix/reject-disabled-bayes-flags

Conversation

@davidliwei

Copy link
Copy Markdown
Owner

mle accepted -p/--PPI-prior, -w/--PPI-weighting and -e/--negative-control, then ignored all three. The run exited 0 and wrote a complete, normal-looking result set produced without them.

All three are read only inside mlemageck_bayes / mageck_bayes_PPI, which mlemageck.py never imports. --bayes itself already errored and exited 1 — but its modifiers did not, which is the inconsistency users actually hit.

The failure this causes

Not a failed run, a false belief. In #26 a user compared "PPI on" against "PPI off", got two result sets, and reasoned about a discrepancy against another tool from the difference. They were comparing one model against itself.

Confirmed on the bundled count table across three runs — -p, no -p, and a plain repeat:

  • beta, z and wald-p-value are byte-identical across all three (cut -f1,3,4,7 → md5 06292574c19931d0aa71a7ab9b54534f)
  • only the permutation p-value/fdr columns move, and they move between the two identical commands too, because the permutation is unseeded

The change

Refuse all three together, exiting non-zero and writing nothing — matching --bayes in the same subsystem. Reported together so fixing one flag does not just reveal the next:

ERROR: The experimental mle --bayes module is currently disabled and not supported in this
release, so the following options cannot be honored: -p/--PPI-prior, -w/--PPI-weighting,
-e/--negative-control. Rerun without them; no other results change, because they were never applied.
ERROR: To normalize against negative-control sgRNAs, use --norm-method control together with
--control-sgrna instead of -e/--negative-control.

-e gets that second line because it is the trap of the three: mle has a real --control-sgrna, so a user passing -e reasonably believes they specified negative controls for normalization.

The options stay registered rather than being deleted, so the error can be specific instead of argparse's generic unrecognized arguments — the approach taken for --pairguide auto in #33. Their help text now marks them disabled.

No deprecation period. Deprecation protects working behavior during migration; there is none here to protect, and a release spent warning is a release spent letting people draw the #26 conclusion.

Tests

Six new tests, written failing first — each previously got returncode == 0 and a gene_summary.txt on disk. They cover -p, the --PPI-prior long form, -w, -e, the --control-sgrna pointer, and all three reported in one message. Each asserts no output file is written, not just the exit code.

_run_mle gained an extra_args parameter (behavior-preserving). Suite: 43 → 49, all passing.

Closes #36.

mle accepted -p/--PPI-prior, -w/--PPI-weighting and -e/--negative-control
and then never read them again. All three are only consumed inside
mlemageck_bayes, which mlemageck does not import, so a run passing them
exited 0 and wrote a complete gene_summary.txt produced without them --
indistinguishable from a run that had applied them.

The practical consequence is a false comparison rather than a failed run:
a user running "PPI on" against "PPI off" gets two result sets and
concludes they compared two models. Confirmed on the bundled count table,
where the beta, z and wald-p-value columns are byte-identical across -p,
no -p, and a plain repeat; only the permutation p-values move, and those
move between the two identical runs as well, because the permutation is
unseeded.

Refuse all three together, exiting non-zero and writing nothing, matching
what --bayes already did in the same subsystem. Reporting them together
means fixing one does not just reveal the next. -e additionally names
--norm-method control with --control-sgrna, since mle has a real
control-sgRNA option and that is what a user reaching for -e usually
wants. The options stay registered so the message can be specific, with
their help text marking them disabled.

No deprecation period: deprecation protects working behavior during
migration, and there is none here to protect. Any script passing these
flags is already producing results that do not honor them.

Closes #36.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8bebc40912

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread mageck2/mlemageck.py Outdated
Comment on lines +61 to +62
logging.error('To normalize against negative-control sgRNAs, use --norm-method control together '
'with --control-sgrna instead of -e/--negative-control.')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Point gene-based controls to --control-gene

When a user replaces -e A1CF as this error recommends, --control-sgrna expects a file containing sgRNA IDs, whereas the disabled option accepted gene names. Supplying the same gene identifiers therefore finds fewer than two controls and aborts in mageckcount_checkcontrolsgrna; the supported equivalent is --norm-method control --control-gene <gene-list-file>, which expands genes to their sgRNAs.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — confirmed and fixed in 2b00294.

Verified both directions on the bundled count table:

--norm-method control --control-sgrna genes.txt
  -> 0 out of 2 control sgRNAs are found in count table, exit 255
--norm-method control --control-gene genes.txt
  -> 2 gene(s) used as negative controls, 20 sgRNAs used as negative controls, exit 0

So the hint would have moved a user from a silently ignored option to a hard failure, which is the exact class of problem this PR exists to remove.

The message now names --control-gene, says the genes go in a file (-e took a bare name on the command line), and warns off --control-sgrna explicitly so the mistake cannot be made from the other direction:

To normalize against negative-control genes, list them one per line in a file and pass --norm-method control with --control-gene. Note --control-sgrna is not the equivalent: it expects sgRNA IDs, and gene names given to it match nothing.

The test asserted --control-sgrna and so was green through the bug; it now asserts --control-gene and carries the reason. Help text and CHANGELOG updated to match, and following the corrected advice literally now runs to completion.

The hint added in the previous commit named the wrong replacement. -e
took a gene name, but --control-sgrna matches sgRNA IDs, so following the
advice moved the user from an ignored option to a hard failure:

  --norm-method control --control-sgrna genes.txt
    -> 0 out of 2 control sgRNAs are found in count table, exit 255
  --norm-method control --control-gene genes.txt
    -> 2 gene(s) used as negative controls, 20 sgRNAs, exit 0

--control-gene is the option that expands genes to their sgRNAs, and both
are on the mle subparser as a mutually exclusive pair. Name it instead,
say that the genes go in a file (-e took a bare name on the command
line), and warn off --control-sgrna explicitly so the same mistake is not
made from the other direction.

Reported by Codex review on #37.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@davidliwei

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-31T15:24:32.017862Z 2b00294 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 2b00294325

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@davidliwei
davidliwei merged commit 77debe4 into main Aug 31, 2026
6 checks passed
@davidliwei
davidliwei deleted the fix/reject-disabled-bayes-flags branch August 31, 2026 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mle silently ignores -p/--PPI-prior, -w/--PPI-weighting and -e/--negative-control

1 participant