fix: surface ChimeraX failures and cap +inf scores before plotting#105
Merged
Conversation
There was a problem hiding this comment.
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+infscore values with a finite capped value for plotting. - Apply
cap_inf_scores()immediately after loading position-level results in bothplot.pyandchimerax_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.
…subprocess commands
c62f4b8 to
def4aae
Compare
There was a problem hiding this comment.
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
--cmdscript 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}; "
…ons during execution
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.
Two independent plot-script robustness fixes that share the same file area:
ChimeraX subprocess failures were silent.
subprocess.run(...)had nocheckand nocapture_output. When ChimeraX errored out (e.g., the$HOMEread-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 aWARNINGon non-zero return, matching the existing pattern inpdb_tool.py.+infinScore_obs_simbroke downstream plots. Extreme hotspots (e.g., NOTCH1 in some cohorts) make the observed anomaly score saturate to+infeven after the high-precision Decimal fallback. That+infthen leaked into the gene plot (normalization viasum=infzeroed the track), summary plot (wild y-axis), and chimerax-plot (np.log(+inf)). Addedcap_inf_scores()inscripts/plotting/utils.pyand call it right after loadingpos_resultin both plot entry points.+infis replaced with1.5 * max(finite)with aWARNINGlog.