Description
pyprophet export matrix crashes with a pandas IndexError in _summarize_peptide_level (file pyprophet/io/_base.py, line ~804). This affects both --level=peptide and --level=protein exports.
Environment
- pyprophet 3.0.7
- pandas 2.1.4 (also reproducible with 2.3.3)
- Python 3.10.19
- Linux
Error
File "pyprophet/io/_base.py", line 804, in _summarize_peptide_level
data = data.iloc[
data.groupby(["run_id", "transition_group_id"]).apply(
lambda x: x["m_score"].idxmin()
)
]
IndexError: DataFrame indexer is not allowed for .iloc
Consider using .loc for automatic alignment.
Root cause
groupby().apply() returns a Series object. In recent pandas versions (>=2.1), passing a Series to .iloc[] is no longer allowed. The fix is to use .loc[] with idxmin() directly:
# Before (broken):
data = data.iloc[
data.groupby(["run_id", "transition_group_id"]).apply(
lambda x: x["m_score"].idxmin()
)
]
# After (fixed):
idx = data.groupby(["run_id", "transition_group_id"])["m_score"].idxmin()
data = data.loc[idx]
Note: there is a second instance of the same .iloc pattern in the same function (for _summarize_protein_level) that should be fixed as well.
Steps to reproduce
- Run
pyprophet score on an .osw file
- Run
pyprophet export matrix --level=peptide
The crash occurs in _summarize_peptide_level regardless of the data content.
Description
pyprophet export matrixcrashes with apandasIndexErrorin_summarize_peptide_level(filepyprophet/io/_base.py, line ~804). This affects both--level=peptideand--level=proteinexports.Environment
Error
Root cause
groupby().apply()returns aSeriesobject. In recent pandas versions (>=2.1), passing aSeriesto.iloc[]is no longer allowed. The fix is to use.loc[]withidxmin()directly:Note: there is a second instance of the same
.ilocpattern in the same function (for_summarize_protein_level) that should be fixed as well.Steps to reproduce
pyprophet scoreon an.oswfilepyprophet export matrix --level=peptideThe crash occurs in
_summarize_peptide_levelregardless of the data content.