Skip to content

Commit

Permalink
Make parameter available to select between 'old' and 'new' GUI radio …
Browse files Browse the repository at this point in the history
…buttons
  • Loading branch information
bkieft-usa committed Feb 7, 2025
1 parent 58cb54d commit e6cf11c
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 16 deletions.
40 changes: 25 additions & 15 deletions metatlas/plots/dill2plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ class adjust_rt_for_selected_compound(object):
def __init__(self,
data,
msms_sorting_method=None,
msms_radio_buttons=None,
include_lcmsruns=None,
exclude_lcmsruns=None,
include_groups=None,
Expand Down Expand Up @@ -308,6 +309,7 @@ def __init__(self,
logger.debug("Initializing new instance of %s.", self.__class__.__name__)
self.data = data
self.msms_hits, _ = sp.sort_msms_hits(msms_hits, sorting_method=msms_sorting_method)
self.msms_radio_buttons = msms_radio_buttons
self.color_me = or_default(color_me, [('black', '')])
self.compound_idx = compound_idx
self.width = width
Expand Down Expand Up @@ -509,24 +511,32 @@ def display_eic_data(self):
picker=True, pickradius=5, color=color, label=label)

def configure_flags(self):
default_peak = ['keep',
'remove',
'keep, unresolvable isomers',
'keep, poor peak shape']

default_msms = ['no selection',
if self.msms_radio_buttons is None or self.msms_radio_buttons == 'new':
default_peak = ['keep','remove','keep, unresolvable isomers','keep, poor peak shape']

'-1.0, poor match, should remove',
'0.0, no match or no MSMS collected',
'0.5, partial or putative match of fragments',
'1.0, good match',

'0.5, co-isolated precursor, partial match',
'1.0, co-isolated precursor, good match',
default_msms = ['no selection',
'-1.0, poor match, should remove',
'0.0, no match or no MSMS collected',
'0.5, partial or putative match of fragments',
'1.0, good match',
'0.5, co-isolated precursor, partial match',
'1.0, co-isolated precursor, good match',
'0.5, single ion match, no evidence',
'1.0, single ion match, ISTD/ref evidence']
elif self.msms_radio_buttons == 'old':
default_peak = ['keep','remove','unresolvable isomers','poor peak shape']

'0.5, single ion match, no evidence',
'1.0, single ion match, ISTD/ref evidence']

default_msms = ['no selection',
'-1, bad match - should remove compound',
'0, no ref match available or no MSMS collected',
'0.5, partial match of fragments',
'1, perfect match to internal reference library',
'1, perfect match to external reference library',
'1, co-isolated precursor but all reference ions are in sample spectrum']
else:
logger.warning('Unknown value for msms_radio_buttons: %s. Must use "old" or "new" or remove.', self.msms_radio_buttons)

if self.peak_flags is None or self.peak_flags == '':
self.peak_flags = default_peak
if self.msms_flags is None or self.msms_flags == '':
Expand Down
2 changes: 2 additions & 0 deletions metatlas/targeted/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def annotation_gui(
peak_flags=None,
msms_flags=None,
msms_sorting_method: str = None,
msms_radio_buttons: str = None,
) -> Optional[dp.adjust_rt_for_selected_compound]:
"""
Opens the interactive GUI for setting RT bounds and annotating peaks
Expand All @@ -96,6 +97,7 @@ def annotation_gui(
return dp.adjust_rt_for_selected_compound(
data,
msms_sorting_method=msms_sorting_method,
msms_radio_buttons=msms_radio_buttons,
msms_hits=data.hits,
color_me=colors,
compound_idx=compound_idx,
Expand Down
1 change: 1 addition & 0 deletions metatlas/tools/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class AnalysisNotebookParameters(BaseNotebookParameters):
slurm_execute: bool = False
clear_cache: bool = False
msms_sorting_method: Optional[str] = None
msms_radio_buttons: Optional[str] = None
# these are populated from the workflow's RTAlignment if None
google_folder: Optional[str] = None
msms_refs: Optional[Path] = None
Expand Down
11 changes: 10 additions & 1 deletion notebooks/reference/Targeted.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@
"# If True, then include MSMS fragment ions in the output documents\n",
"export_msms_fragment_ions = None\n",
"\n",
"# One of 'old', 'new', or None. If 'old', use the old version of the\n",
"# MSMS (and MS) radio button selections in the GUI. If 'new' or None, use the \n",
"# new version of the MSMS (and MS) radio button selections in the GUI.\n",
"msms_radio_buttons = None\n",
"\n",
"# Setting this to True will remove the cache of MSMS hits\n",
"# if you don't see MSMS data for any of your compounds in RT adjuster GUI,\n",
"# then you might want to try settings this to True. However, it will\n",
Expand Down Expand Up @@ -318,7 +323,11 @@
"metadata": {},
"outputs": [],
"source": [
"agui = annotation_gui(data=metatlas_dataset, compound_idx=0, width=15, height=3, colors=analysis.parameters.line_colors, msms_sorting_method=analysis.parameters.msms_sorting_method)"
"agui = annotation_gui(data=metatlas_dataset, \n",
" compound_idx=0, width=15, height=3, \n",
" colors=analysis.parameters.line_colors, \n",
" msms_sorting_method=analysis.parameters.msms_sorting_method, \n",
" msms_radio_buttons=analysis.parameters.msms_radio_buttons)"
]
},
{
Expand Down

0 comments on commit e6cf11c

Please sign in to comment.