Skip to content

fix: surface ChimeraX failures and cap +inf scores before plotting#105

Merged
St3451 merged 7 commits into
masterfrom
fix/plot-script-robustness
May 28, 2026
Merged

fix: surface ChimeraX failures and cap +inf scores before plotting#105
St3451 merged 7 commits into
masterfrom
fix/plot-script-robustness

Conversation

@St3451
Copy link
Copy Markdown
Collaborator

@St3451 St3451 commented May 28, 2026

Two independent plot-script robustness fixes that share the same file area:

  1. ChimeraX subprocess failures were silent. subprocess.run(...) had no check and no capture_output. When ChimeraX errored out (e.g., the $HOME read-only issue), the script logged "Generating 3D images..", moved on, and produced no PNG with no warning. Replaced with a _run_chimerax() helper that captures stderr and logs a WARNING on non-zero return, matching the existing pattern in pdb_tool.py.

  2. +inf in Score_obs_sim broke downstream plots. Extreme hotspots (e.g., NOTCH1 in some cohorts) make the observed anomaly score saturate to +inf even after the high-precision Decimal fallback. That +inf then leaked into the gene plot (normalization via sum=inf zeroed the track), summary plot (wild y-axis), and chimerax-plot (np.log(+inf)). Added cap_inf_scores() in scripts/plotting/utils.py and call it right after loading pos_result in both plot entry points. +inf is replaced with 1.5 * max(finite) with a WARNING log.

Copilot AI review requested due to automatic review settings May 28, 2026 16:02
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Improves robustness of plotting scripts by (1) preventing +inf score values from breaking downstream plots and (2) surfacing ChimeraX subprocess failures instead of failing silently.

Changes:

  • Add cap_inf_scores() utility to replace +inf score values with a finite capped value for plotting.
  • Apply cap_inf_scores() immediately after loading position-level results in both plot.py and chimerax_plot.py.
  • Introduce _run_chimerax() to capture ChimeraX stderr and log warnings on non-zero exit codes.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
scripts/plotting/utils.py Adds cap_inf_scores() to cap inf scores prior to plotting.
scripts/plotting/plot.py Calls cap_inf_scores() after loading pos_result.
scripts/plotting/chimerax_plot.py Calls cap_inf_scores(), and replaces silent ChimeraX calls with _run_chimerax() warnings.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/plotting/utils.py Outdated
Comment thread scripts/plotting/chimerax_plot.py
Comment thread scripts/plotting/chimerax_plot.py Outdated
Comment thread scripts/plotting/utils.py
@St3451 St3451 force-pushed the fix/plot-script-robustness branch from c62f4b8 to def4aae Compare May 28, 2026 16:25
@St3451 St3451 requested a review from Copilot May 28, 2026 16:27
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

scripts/plotting/chimerax_plot.py:134

  • The ChimeraX --cmd script embeds file paths unquoted (e.g., open {pdb_path} / open {attr_file_path} / save {output_path}). If any of these paths contain spaces, ChimeraX will likely split them into multiple tokens and fail to open/save. Consider quoting/escaping these paths inside the ChimeraX script (and update the comment about “paths with spaces” accordingly).
    chimerax_script = (
        f"open {pdb_path}; "
        "set bgColor white; "
        "color lightgray; "
        f"open {attr_file_path}; "
        f"color byattribute {attribute} palette {palette}; "

Comment thread scripts/plotting/chimerax_plot.py Outdated
@St3451 St3451 requested a review from Copilot May 28, 2026 16:34
@St3451 St3451 merged commit d79a5e6 into master May 28, 2026
1 check passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread scripts/plotting/chimerax_plot.py
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.

2 participants