MannLabs / alphadia

modular & open DIA search
https://alphadia.readthedocs.io
Apache License 2.0
41 stars 3 forks source link

rquantify doesn't use column choice from extraction #353

Open GeorgWa opened 3 days ago

GeorgWa commented 3 days ago

Describe the bug When extraction is performed on uncalibrated values due to optimization failure, requantification must use mz_library instead of mz_calibrated. This is currently ignored.

14:05:42.137243 INFO: Test AUC: 0.566
14:06:08.966922 INFO: Train AUC: 0.573
14:06:08.969052 INFO: AUC difference: 1.32%
14:06:09.656906 INFO: Removing fragments below FDR threshold
14:06:10.201699 PROGRESS: ============================= Precursor FDR =============================
14:06:10.207703 PROGRESS: Total precursors accumulated: 5,148
14:06:10.210269 PROGRESS: Target precursors: 5,098 (99.03%)
14:06:10.212665 PROGRESS: Decoy precursors: 50 (0.97%)
14:06:10.215309 PROGRESS:
14:06:10.217821 PROGRESS: Precursor Summary:
14:06:10.226231 PROGRESS: Channel   0:   0.05 FDR: 5,098; 0.01 FDR: 5,098; 0.001 FDR: 3,086
14:06:10.228762 PROGRESS:
14:06:10.231328 PROGRESS: Protein Summary:
14:06:10.240532 PROGRESS: Channel   0:   0.05 FDR: 1,555; 0.01 FDR: 1,555; 0.001 FDR: 1,058
14:06:10.242858 PROGRESS: =========================================================================
14:06:10.325998 PROGRESS: === Transfer learning quantification ===
14:06:10.328782 INFO: creating library for charged fragment types: ['b', 'y']
14:06:10.377433 INFO: Calibrating library
14:06:10.379990 INFO: calibration group: precursor, predicting mz
14:06:10.383113 WARNING: mz prediction was skipped as it has not been fitted yet
14:06:10.383160 INFO: calibration group: precursor, predicting rt
14:06:10.385585 WARNING: rt prediction was skipped as it has not been fitted yet
14:06:10.385628 INFO: calibration group: fragment, predicting mz
14:06:10.387715 WARNING: mz prediction was skipped as it has not been fitted yet
14:06:10.387759 INFO: quantifying 5,148 precursors with 243,304 fragments
14:06:10.409045 INFO: Starting candidate scoring
14:06:10.409955 ERROR: Search for 20230921_OA3_ThNo_SA_N756_4Th5ms_Evo01_21min_F40_2400V_ISDA_Plate1_Position38_Psoriasis_06 failed with error: 'mz_calibrated'
Traceback (most recent call last):
  File "/fs/home/wallmann/conda-envs/alpha4/lib/python3.11/site-packages/pandas/core/indexes/base.py", line 3805, in get_loc
    return self._engine.get_loc(casted_key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "index.pyx", line 167, in pandas._libs.index.IndexEngine.get_loc
  File "index.pyx", line 196, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/hashtable_class_helper.pxi", line 7081, in pandas._libs.hashtable.PyObjectHashTable.get_item
  File "pandas/_libs/hashtable_class_helper.pxi", line 7089, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'mz_calibrated'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/fs/gpfs41/lv07/fileset03/home/b_mann/wallmann/git/alphadia/alphadia/planning.py", line 353, in run
    psm_df, frag_df = workflow.requantify_fragments(psm_df)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/fs/gpfs41/lv07/fileset03/home/b_mann/wallmann/git/alphadia/alphadia/workflow/peptidecentric.py", line 1151, in requantify_fragments
    _, frag_df = scoring(scored_candidates)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/fs/gpfs41/lv07/fileset03/home/b_mann/wallmann/git/alphadia/alphadia/plexscoring.py", line 1887, in __call__
    fragment_container = self.assemble_fragments()
                         ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/fs/gpfs41/lv07/fileset03/home/b_mann/wallmann/git/alphadia/alphadia/plexscoring.py", line 1630, in assemble_fragments
    self.fragments_flat[self.fragment_mz_column].values,
    ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/fs/home/wallmann/conda-envs/alpha4/lib/python3.11/site-packages/pandas/core/frame.py", line 4102, in __getitem__
    indexer = self.columns.get_loc(key)
              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/fs/home/wallmann/conda-envs/alpha4/lib/python3.11/site-packages/pandas/core/indexes/base.py", line 3812, in get_loc
    raise KeyError(key) from err
KeyError: 'mz_calibrated'
14:06:10.428437 ERROR: 'mz_calibrated'
14:06:10.433599 INFO: Finished workflow for 20230921_OA3_ThNo_SA_N756_4Th5ms_Evo01_21min_F40_2400V_ISDA_Plate1_Position38_Psoriasis_06
14:06:10.439017 INFO: Traceback (most recent call last):
  File "/fs/home/wallmann/conda-envs/alpha4/lib/python3.11/site-packages/pandas/core/indexes/base.py", line 3805, in get_loc
    return self._engine.get_loc(casted_key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "index.pyx", line 167, in pandas._libs.index.IndexEngine.get_loc
  File "index.pyx", line 196, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/hashtable_class_helper.pxi", line 7081, in pandas._libs.hashtable.PyObjectHashTable.get_item
  File "pandas/_libs/hashtable_class_helper.pxi", line 7089, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'mz_calibrated'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/fs/gpfs41/lv07/fileset03/home/b_mann/wallmann/git/alphadia/alphadia/cli.py", line 342, in run
    plan.run()
  File "/fs/gpfs41/lv07/fileset03/home/b_mann/wallmann/git/alphadia/alphadia/planning.py", line 365, in run
    raise e
  File "/fs/gpfs41/lv07/fileset03/home/b_mann/wallmann/git/alphadia/alphadia/planning.py", line 353, in run
    psm_df, frag_df = workflow.requantify_fragments(psm_df)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/fs/gpfs41/lv07/fileset03/home/b_mann/wallmann/git/alphadia/alphadia/workflow/peptidecentric.py", line 1151, in requantify_fragments
    _, frag_df = scoring(scored_candidates)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/fs/gpfs41/lv07/fileset03/home/b_mann/wallmann/git/alphadia/alphadia/plexscoring.py", line 1887, in __call__
    fragment_container = self.assemble_fragments()
                         ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/fs/gpfs41/lv07/fileset03/home/b_mann/wallmann/git/alphadia/alphadia/plexscoring.py", line 1630, in assemble_fragments
    self.fragments_flat[self.fragment_mz_column].values,
    ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/fs/home/wallmann/conda-envs/alpha4/lib/python3.11/site-packages/pandas/core/frame.py", line 4102, in __getitem__
    indexer = self.columns.get_loc(key)
              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/fs/home/wallmann/conda-envs/alpha4/lib/python3.11/site-packages/pandas/core/indexes/base.py", line 3812, in get_loc
    raise KeyError(key) from err
KeyError: 'mz_calibrated'

14:06:10.439090 ERROR: 'mz_calibrated'

Logs Please provide the log (see the AlphaDIA terminal on where to find it).

Version (please complete the following information): alphadia 1.8.1