Skip to content

Commit

Permalink
Merge pull request #99 from Roestlab/patch/ui_rename_results_peak_bou…
Browse files Browse the repository at this point in the history
…ndaries

[CHANGE] ui option name for feature file boundaries
  • Loading branch information
singjc authored Jan 24, 2024
2 parents 9320cc6 + ea57a56 commit 36243d9
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 17 deletions.
4 changes: 2 additions & 2 deletions massdash/server/ExtractedIonChromatogramAnalysisServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ def main(self):
st.write(f"Loading XIC data... Elapsed time: {elapsed_time()}")

# Perform peak picking based on user settings
if peak_picking_settings.do_peak_picking == 'OSW-PyProphet':
if peak_picking_settings.do_peak_picking == 'Feature File Boundaries':
with time_block() as elapsed_time:
tr_group_feature_data = self.xic_data.loadTransitionGroupFeatures(transition_list_ui.transition_settings.selected_peptide, transition_list_ui.transition_settings.selected_charge)
st.write(f"Loading OSW-PyProphet Peak Boundaries... Elapsed time: {elapsed_time()}")
st.write(f"Loading Feature File Peak Boundaries... Elapsed time: {elapsed_time()}")
elif peak_picking_settings.do_peak_picking == 'pyPeakPickerMRM':
with time_block() as elapsed_time:
# Peak picking using pyMRMTransitionGroupPicker
Expand Down
8 changes: 6 additions & 2 deletions massdash/server/OneDimensionPlotterServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from os.path import basename
import streamlit as st

# Loaders
from ..loaders.MzMLDataLoader import MzMLDataLoader
# Plotting
from ..plotting.GenericPlotter import PlotConfig
from ..plotting.InteractivePlotter import InteractivePlotter
Expand Down Expand Up @@ -45,10 +47,12 @@ class OneDimensionPlotterServer:

def __init__(self,
feature_map_dict: Dict[str, FeatureMap],
mzml_loader_dict: Dict[str, MzMLDataLoader],
transition_list_ui: TransitionListUISettings, chrom_plot_settings: ChromatogramPlotUISettings,
peak_picking_settings: PeakPickingUISettings, spectral_library_path: str=None,
verbose: bool=False):
self.feature_map_dict = feature_map_dict
self.mzml_loader_dict = mzml_loader_dict
self.transition_list_ui = transition_list_ui
self.chrom_plot_settings = chrom_plot_settings
self.peak_picking_settings = peak_picking_settings
Expand All @@ -75,9 +79,9 @@ def generate_chromatogram_plots(self):
tr_group = feature_map.to_chromatograms()
# Perform peak picking if enabled
peak_picker = PeakPickingServer(self.peak_picking_settings, self.chrom_plot_settings)
tr_group_feature_data = peak_picker.perform_peak_picking(tr_group_data={'tmp':tr_group}, transition_list_ui=self.transition_list_ui, spec_lib=self.spectral_library_path)
tr_group_feature_data = peak_picker.perform_peak_picking(tr_group_data={file:tr_group}, mzml_loader_dict=self.mzml_loader_dict, transition_list_ui=self.transition_list_ui, spec_lib=self.spectral_library_path)
plot_settings_dict = self._get_plot_settings('Retention Time (s)', 'Intensity', file, 'chromatogram')
plot_obj = self._generate_plot(tr_group, plot_settings_dict, tr_group_feature_data['tmp'])
plot_obj = self._generate_plot(tr_group, plot_settings_dict, tr_group_feature_data[file])
run_plots_list.append(plot_obj)

# Generate Mobilogram Plot
Expand Down
21 changes: 11 additions & 10 deletions massdash/server/PeakPickingServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ def __init__(self, peak_picking_settings: PeakPickingUISettings, chrom_plot_sett
self.peak_picking_settings = peak_picking_settings
self.chrom_plot_settings = chrom_plot_settings

def perform_osw_pyprophet_peak_picking(self, xic_data: SqMassLoader, transition_list_ui: Literal['ExtractedIonChromatogramAnalysisUI', 'RawTargetedExtractionAnalysisUI']):
def perform_feature_file_peak_picking(self, tr_group_data, mzml_loader_dict, transition_list_ui: Literal['ExtractedIonChromatogramAnalysisUI', 'RawTargetedExtractionAnalysisUI']):
"""
Performs peak picking using OSW-PyProphet algorithm.
Get peak boundaries from Feature File Boundaries.
Args:
xic_data (object): The XIC data.
Expand All @@ -44,12 +44,13 @@ def perform_osw_pyprophet_peak_picking(self, xic_data: SqMassLoader, transition_
Returns:
dict: The transition group feature data.
"""

tr_group_feature_data = {}
with time_block() as elapsed_time:
tr_group_feature_data = xic_data.loadTransitionGroupFeature(
transition_list_ui.transition_settings.selected_peptide,
transition_list_ui.transition_settings.selected_charge
)
st.write(f"Loading OSW-PyProphet Peak Boundaries... Elapsed time: {elapsed_time()}")
for file in tr_group_data.keys():
tr_group_feature_data[file] = mzml_loader_dict.loadTransitionGroupFeatures(transition_list_ui.transition_settings.selected_peptide,
transition_list_ui.transition_settings.selected_charge)[file]
st.write(f"Loading Feature File Peak Boundaries... Elapsed time: {elapsed_time()}")
return tr_group_feature_data

def perform_pypeakpicker_mrm_peak_picking(self, tr_group_data: TransitionGroup):
Expand Down Expand Up @@ -133,7 +134,7 @@ def perform_conformer_peak_picking(self, spec_lib_path: str, tr_group_data: Tran
st.write(f"Performing Conformer Peak Picking... Elapsed time: {elapsed_time()}")
return tr_group_feature_data

def perform_peak_picking(self, tr_group_data: TransitionGroup=None, xic_data: SqMassLoader=None, transition_list_ui: Literal['ExtractedIonChromatogramAnalysisUI', 'RawTargetedExtractionAnalysisUI']=None, spec_lib: str=None):
def perform_peak_picking(self, tr_group_data: TransitionGroup=None, xic_data: SqMassLoader=None, mzml_loader_dict=None, transition_list_ui: Literal['ExtractedIonChromatogramAnalysisUI', 'RawTargetedExtractionAnalysisUI']=None, spec_lib: str=None):
"""
Performs peak picking based on the selected method.
Expand All @@ -149,8 +150,8 @@ def perform_peak_picking(self, tr_group_data: TransitionGroup=None, xic_data: Sq
tr_group_feature_data = {}

# Perform peak picking based on the selected method
if self.peak_picking_settings.do_peak_picking == 'OSW-PyProphet':
tr_group_feature_data = self.perform_osw_pyprophet_peak_picking(xic_data, transition_list_ui)
if self.peak_picking_settings.do_peak_picking == 'Feature File Boundaries':
tr_group_feature_data = self.perform_feature_file_peak_picking(tr_group_data, mzml_loader_dict, transition_list_ui)
elif self.peak_picking_settings.do_peak_picking == 'pyPeakPickerMRM':
tr_group_feature_data = self.perform_pypeakpicker_mrm_peak_picking(tr_group_data)
elif self.peak_picking_settings.do_peak_picking == 'MRMTransitionGroupPicker':
Expand Down
2 changes: 1 addition & 1 deletion massdash/server/RawTargetedExtractionAnalysisServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def main(self):
# Initialize plot object dictionary
plot_obj_dict = {}
if chrom_plot_settings.display_plot_dimension_type == "1D":
plot_obj_dict = OneDimensionPlotterServer(featureMaps, transition_list_ui, chrom_plot_settings, peak_picking_settings, self.massdash_gui.file_input_settings.transition_list_file_path, self.massdash_gui.verbose).generate_chromatogram_plots().plot_obj_dict
plot_obj_dict = OneDimensionPlotterServer(featureMaps, self.mzml_loader, transition_list_ui, chrom_plot_settings, peak_picking_settings, self.massdash_gui.file_input_settings.transition_list_file_path, self.massdash_gui.verbose).generate_chromatogram_plots().plot_obj_dict
elif chrom_plot_settings.display_plot_dimension_type == "2D":
plot_obj_dict = TwoDimensionPlotterServer(featureMaps, transition_list_ui, chrom_plot_settings).generate_two_dimensional_plots().plot_obj_dict
elif chrom_plot_settings.display_plot_dimension_type == "3D":
Expand Down
4 changes: 2 additions & 2 deletions massdash/ui/PeakPickingUISettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def create_ui(self, plot_settings: ChromatogramPlotUISettings):
st.sidebar.title("Peak Picking")

## Perform Peak Picking
self.do_peak_picking = st.sidebar.selectbox("Peak Picking", ['none', 'OSW-PyProphet', 'pyPeakPickerMRM', 'MRMTransitionGroupPicker', 'Conformer'], help="Peak picking method to use.")
self.do_peak_picking = st.sidebar.selectbox("Peak Picking", ['none', 'Feature File Boundaries', 'pyPeakPickerMRM', 'MRMTransitionGroupPicker', 'Conformer'], help="Peak picking method to use.")

if self.do_peak_picking != 'none':
## Perform peak picking on displayed chromatogram, or adjust smoothing separately for peak picking?
Expand All @@ -54,7 +54,7 @@ def create_ui(self, plot_settings: ChromatogramPlotUISettings):
if self.do_peak_picking == "pyPeakPickerMRM":
self.peak_picker_algo_settings = pyPeakPickerMRMUISettings(self)
self.peak_picker_algo_settings.create_ui(plot_settings)
elif self.do_peak_picking == "OSW-PyProphet":
elif self.do_peak_picking == "Feature File Boundaries":
pass
elif self.do_peak_picking == "MRMTransitionGroupPicker":
self.peak_picker_algo_settings = MRMTransitionGroupPickerUISettings(self)
Expand Down

0 comments on commit 36243d9

Please sign in to comment.