Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
10ba6b4
Initial plan
Copilot Oct 28, 2025
c9f972d
Add export_feature_scores function and CLI command
Copilot Oct 28, 2025
e1be2df
Fix _plot_feature_scores to properly handle PDF merging
Copilot Oct 28, 2025
7c81fec
Add tests for export_feature_scores functionality
Copilot Oct 28, 2025
28c0e29
Address code review comments - move imports and improve exception han…
Copilot Oct 28, 2025
462e617
Fix KeyError by adding required SCORE column for plot_scores
Copilot Oct 28, 2025
31ed97b
Add memory optimizations for large datasets - sample data and select …
Copilot Oct 28, 2025
f10c534
Refactor plot_scores to make SCORE column optional
Copilot Oct 29, 2025
7c2e471
Refactor: move file type reader methods into IO export classes
Copilot Oct 29, 2025
f9f2b3b
Fix CI: Move pyarrow imports to module level
Copilot Oct 29, 2025
e11e24c
Use _ensure_pyarrow for lazy pyarrow import instead of module-level i…
Copilot Oct 29, 2025
0578aa4
Add robustness checks for empty dataframes and edge cases in _plot_fe…
Copilot Oct 29, 2025
140c2b0
Add check for temp file existence before PDF merging
Copilot Oct 29, 2025
6f986c9
Add check for empty PDF files before merging
Copilot Oct 29, 2025
e611458
Add exception handling for PDF merging and file operations
Copilot Oct 29, 2025
fe85ddb
Merge branch 'master' of github.com:singjc/pyprophet into copilot/add…
singjc Oct 29, 2025
b1b8b5f
Initial plan
Copilot Oct 29, 2025
06fe02b
Merge pull request #2 from singjc/copilot/add-export-method-feature-s…
singjc Oct 29, 2025
6fc08bf
Add export feature-scores command with unified logic for scored/unsco…
Copilot Oct 29, 2025
f720f45
Add comprehensive tests for export feature-scores command
Copilot Oct 29, 2025
ec63de9
Add error handling for pyarrow and update documentation
Copilot Oct 29, 2025
cf5d286
Refactor: Extract pyarrow import check to helper function to reduce c…
Copilot Oct 29, 2025
b0c4b06
Remove unused file_type variable assignments
Copilot Oct 29, 2025
3cf3d16
Add CHANGELOG entry for new feature-scores command
Copilot Oct 29, 2025
b3dded8
Merge master branch and resolve conflicts in export_report.py
Copilot Oct 29, 2025
22590b1
Merge branch 'master' into copilot/consolidate-export-commands
singjc Oct 29, 2025
3507b95
Refactor: use existing _ensure_pyarrow() instead of custom function
Copilot Oct 29, 2025
e10451c
Enhance reader methods with SCORE detection, simplify export_report.p…
Copilot Oct 29, 2025
b6bbdb6
add: regtest outputs
singjc Oct 29, 2025
0135e00
Merge pull request #5 from singjc/copilot/consolidate-export-commands
singjc Oct 29, 2025
8a38d3f
Merge branch 'PyProphet:master' into master
singjc Oct 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@

All notable changes to this project will be documented in this file.

## [Unreleased]

### 🚀 Features

- Add unified `pyprophet export feature-scores` command that works with all file formats (OSW, Parquet, Split Parquet)
- Auto-detects SCORE tables and adjusts behavior intelligently
- Applies RANK==1 filtering when SCORE tables exist
- Plots only VAR_ columns for unscored files
- Supports MS1, MS2, and transition level features

### 🔧 Deprecated

- Deprecate `pyprophet export score-plots` command in favor of `pyprophet export feature-scores`
- Old command still works with deprecation warning for backward compatibility

## [3.0.4] - 2025-10-21

### 🚀 Features
Expand Down
23 changes: 20 additions & 3 deletions docs/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,27 @@ To convert OpenSwath's *.osw* / *.sqMass* format to a parquet format, you can us
:prog: pyprophet export parquet
:nested: none

Export Score Plots
^^^^^^^^^^^^^^^^^^
Export Feature Score Plots
^^^^^^^^^^^^^^^^^^^^^^^^^^^

It may be useful to export the distribution of scores for the different input features. This can help you investigate the distribution and quality of scores for target-decoy separation.
To export the distribution of feature scores (VAR_ columns) and, if available, scorer scores (SCORE columns), you can use the :program:`export feature-scores` subcommand. This command works with all file formats (OSW, Parquet, and Split Parquet):

- **For unscored files**: Plots only VAR_ columns (feature variables)
- **For scored files**: Applies RANK==1 filtering and plots both SCORE and VAR_ columns

This is useful for investigating the distribution and quality of scores for target-decoy separation.

.. click:: pyprophet.cli.export:export_feature_scores
:prog: pyprophet export feature-scores
:nested: none

Export Score Plots (Deprecated)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. deprecated:: 3.1
Use :program:`pyprophet export feature-scores` instead.

The :program:`export score-plots` command is deprecated and will be removed in a future version. It has been replaced by the more flexible :program:`export feature-scores` command which works with all file formats.

.. click:: pyprophet.cli.export:export_score_plots
:prog: pyprophet export score-plots
Expand Down
69 changes: 66 additions & 3 deletions pyprophet/cli/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
from ..export.export_report import (
export_scored_report as _export_scored_report,
)
from ..export.export_report import (
export_feature_scores as _export_feature_scores,
)
from ..export.calibration_report import generate_report as generate_calibration_report
from ..glyco.export import (
export_score_plots as export_glyco_score_plots,
Expand Down Expand Up @@ -43,8 +46,10 @@ def export():
export.add_command(export_parquet, name="parquet")
export.add_command(export_compound, name="compound")
export.add_command(export_glyco, name="glyco")
export.add_command(export_score_plots, name="score-plots")
export.add_command(export_feature_scores, name="feature-scores")
export.add_command(export_score_plots, name="score-plots") # Deprecated
export.add_command(export_scored_report, name="score-report")
export.add_command(export_feature_scores, name="feature-scores")
export.add_command(export_calibration_report, name="calibration-report")

return export
Expand Down Expand Up @@ -829,7 +834,35 @@ def export_glyco(
)


# Export score plots
# Export feature scores (unified command)
@click.command(name="feature-scores", cls=AdvancedHelpCommand)
@click.option(
"--in",
"infile",
required=True,
type=click.Path(exists=True),
help="PyProphet input file (OSW, Parquet, or Split Parquet directory).",
)
@click.option(
"--out",
"outfile",
type=click.Path(exists=False),
help="Output PDF file path. If not specified, will be derived from input filename.",
)
@measure_memory_usage_and_time
def export_feature_scores(infile, outfile):
"""
Export feature score plots

Works with OSW, Parquet, and Split Parquet formats.
- If SCORE tables exist: applies RANK==1 filtering and plots SCORE + VAR_ columns
- If SCORE tables don't exist: plots only VAR_ columns
"""
from ..export.export_report import export_feature_scores as _export_feature_scores
_export_feature_scores(infile, outfile)


# Export score plots (deprecated - use feature-scores instead)
@click.command(name="score-plots", cls=AdvancedHelpCommand)
@click.option(
"--in",
Expand All @@ -849,8 +882,11 @@ def export_glyco(
@measure_memory_usage_and_time
def export_score_plots(infile, glycoform):
"""
Export score plots
Export score plots (DEPRECATED - use 'feature-scores' instead)

This command is deprecated. Please use 'pyprophet export feature-scores' instead.
"""
logger.warning("DEPRECATED: 'pyprophet export score-plots' is deprecated. Use 'pyprophet export feature-scores' instead.")
if infile.endswith(".osw"):
if not glycoform:
_export_score_plots(infile)
Expand Down Expand Up @@ -880,6 +916,33 @@ def export_scored_report(infile):
_export_scored_report(infile, outfile)


# Export feature scores
@click.command(name="feature-scores", cls=AdvancedHelpCommand)
@click.option(
"--in",
"infile",
required=True,
type=click.Path(exists=True),
help="PyProphet input file (OSW, Parquet, or Split Parquet directory).",
)
@click.option(
"--out",
"outfile",
type=click.Path(exists=False),
help="Output PDF file. If not provided, will be auto-generated based on input filename.",
)
@measure_memory_usage_and_time
def export_feature_scores(infile, outfile):
"""
Export feature score plots from a PyProphet input file.

Creates plots showing the distribution of feature scores (var_* columns)
at different levels (ms1, ms2, transition, alignment) colored by target/decoy status.
Works with OSW, Parquet, and Split Parquet files (scored or unscored).
"""
_export_feature_scores(infile, outfile)


# Export OpenSwath Calibration debug plots
@click.command(name="calibration-report", cls=AdvancedHelpCommand)
@click.option(
Expand Down
Loading