Skip to content

Fix args.reference_targets AttributeError in U-test fake-test path#4

Open
adamklie wants to merge 1 commit into
EngreitzLab:mainfrom
adamklie:fix/utest-args-reference-targets
Open

Fix args.reference_targets AttributeError in U-test fake-test path#4
adamklie wants to merge 1 commit into
EngreitzLab:mainfrom
adamklie:fix/utest-args-reference-targets

Conversation

@adamklie
Copy link
Copy Markdown

Fix args.reference_targets AttributeError in U-test fake-test path

Summary

Closes #2.

The U-test calibration's compute_fake_perturbation_tests crashes immediately on the first call to compute_perturbation_association because line 160 passes args.reference_targets, which is never defined on the argparse namespace. This makes --compute_fake_perturbation_tests unusable on main.

Change

One-line fix that mirrors the real-test path's fallback logic (lines 44–49). When --guide_annotation_path isn't provided, the real-test path falls back to args.guide_annotation_key (default ['non-targeting']); the fake-test path now does the same.

-                        reference_targets=args.reference_targets,
+                        reference_targets=args.guide_annotation_key,

In the fake-test code path, the relabeled NT subset has guide_targets ∈ {'non-targeting', 'targeting'} (see line 149 where the 6 fake-targeting guides are flipped), so reference_targets=['non-targeting'] is the correct reference set. Using args.guide_annotation_key matches the real-test fallback and respects user override.

Test plan

  • Run python U-test_perturbation_calibration.py --compute_fake_perturbation_tests --guide_annotation_path <tsv> --components 30 ... --sel_thresh 2.0 end-to-end on a real dataset (Huangfu HUES8 endoderm differentiation, K=30,50,60,80,100,200,250,300, sel_thresh=2.0).
  • Verify per-K <K>_fake_perturbation_association_results.txt files are written in Evaluation/<K>_<sel_thresh>/.
  • Verify q-values in the output have a sensible distribution.

Out of scope

Two adjacent issues spotted while debugging — filed/will file separately:

  1. main() line 391: pd.concat([test_stats_real_df, test_stats_fake_df], ...) raises NameError when --visualizations is set without --compute_real_perturbation_tests.
  2. load_real_perturbation_tests() line 199: hardcoded ['D0', 'D4', 'D7'] sample names. Function is currently unreachable from main() so harmless, but should be parameterized.

🤖 Generated with Claude Code

args.reference_targets is never defined on the argparse namespace; mirror
the real-test path's fallback (line 49) and use args.guide_annotation_key
instead. This is the correct reference-target list since the fake-test code
relabels NT guides to {'non-targeting', 'targeting'} before this call.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

compute_fake_perturbation_tests crashes with AttributeError: 'Namespace' object has no attribute 'reference_targets'

1 participant