Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:Roestlab/massseer into patch/ui_rena…
Browse files Browse the repository at this point in the history
…me_results_peak_boundaries
  • Loading branch information
jcharkow committed Jan 24, 2024
2 parents 989e919 + 9320cc6 commit ea57a56
Show file tree
Hide file tree
Showing 39 changed files with 426 additions and 106 deletions.
32 changes: 32 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
36 changes: 36 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes # (issue)

## Type of change

Please delete options that are not relevant.

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update

# How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

- [ ] Test A
- [ ] Test B

**Test Configuration**:
* Firmware version:
* Hardware:

# Checklist:

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules
36 changes: 36 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes # (issue)

## Type of change

Please delete options that are not relevant.

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update

# How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

- [ ] Test A
- [ ] Test B

**Test Configuration**:
* Firmware version:
* Hardware:

# Checklist:

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules
16 changes: 8 additions & 8 deletions .github/workflows/auto-pr-desc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@

name: generate-pull-request-description

on:
workflow_call:
secrets:
token:
required: true
on: [pull_request]

jobs:
update:
if: ${{ !contains(github.event.pull_request.body, '<!--- SKIP AUTOGENERATED NOTES --->') }}
runs-on: ubuntu-latest
steps:
- uses: octue/[email protected]
# Step 1: Use an action to generate the pull request description
- name: Generate PR Description
uses: octue/generate-pull-request-description@main
id: pr-description
with:
pull_request_url: ${{ github.event.pull_request.url }}
api_token: ${{ secrets.token }}
api_token: ${{ secrets.GITHUB_TOKEN }}

# Step 2: Update the pull request body using the generated description
- name: Update pull request body
uses: riskledger/update-pr-description@v2
with:
body: ${{ steps.pr-description.outputs.pull_request_description }}
token: ${{ secrets.token }}
token: ${{ secrets.GITHUB_TOKEN }}

5 changes: 5 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
"""
docs/conf
~~~~~~~~~
"""

# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
Expand Down
2 changes: 1 addition & 1 deletion docs/plottingGallery/Heatmap Per Transition.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"tags": []
},
"source": [
"By changing the ``type_of_heatmap`` in the `:py:class:~massseer.plotting.PlotConfig`, we can plot different axis against one another."
"By changing the ``type_of_heatmap`` in the `:py:class:~massdash.plotting.PlotConfig`, we can plot different axis against one another."
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions docs/python_docs/Advanced Plotting.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"tags": []
},
"source": [
"MassSeer is also capable of generating many different other plot types. Since these plots are more complex, plotting is more involved. "
"MassDash is also capable of generating many different other plot types. Since these plots are more complex, plotting is more involved. "
]
},
{
Expand Down Expand Up @@ -317,7 +317,7 @@
},
"outputs": [],
"source": [
"from massseer.plotting import PlotConfig\n",
"from massdash.plotting import PlotConfig\n",
"plotConfig = PlotConfig()\n",
"plotConfig.include_ms1 = True\n",
"plotConfig.include_ms2 = True\n",
Expand Down Expand Up @@ -353,7 +353,7 @@
},
"outputs": [],
"source": [
"from massseer.plotting import InteractivePlotter\n",
"from massdash.plotting import InteractivePlotter\n",
"plotter = InteractivePlotter(plotConfig)"
]
},
Expand Down
4 changes: 2 additions & 2 deletions docs/python_docs/Loading Data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Loading Data

.. currentmodule:: massdash.loaders

To load raw data into MassSeer, a loader object must be initiated. There are two types of loader classes
To load raw data into MassDash, a loader object must be initiated. There are two types of loader classes


1. :py:class:`Chromatogram Loaders<GenericChromatogramLoader>`: Chromatogram Loaders: Raw data stores chromatograms, this allows for faster loading however since extraction has already been performed by the upstream analysis tool. This includes :py:class:`SqMassLoader`
Expand All @@ -25,5 +25,5 @@ Since each loader type is linked with a results file each loader can be used to
Loading Spectrum Data
Loading Feature Information

Have an idea for a loader you want to see? Create a issue `here <https://github.com/Roestlab/massseer/issues>`_.
Have an idea for a loader you want to see? Create a issue `here <https://github.com/Roestlab/massdash/issues>`_.

2 changes: 1 addition & 1 deletion docs/python_docs/Quick Start.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
"tags": []
},
"source": [
"Since the .sqMass file does not contain any metadata, to link chromatograms with their corresponding peptide sequence we must link an ``.osw`` file with the ``.sqMass`` file. In MassSeer this is done by initiating a :py:class:`~loaders.SqMassLoader` as shown below. "
"Since the .sqMass file does not contain any metadata, to link chromatograms with their corresponding peptide sequence we must link an ``.osw`` file with the ``.sqMass`` file. In MassDash this is done by initiating a :py:class:`~loaders.SqMassLoader` as shown below. "
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@
"metadata": {},
"outputs": [],
"source": [
"from massseer.plotting import InteractivePlotter, PlotConfig\n",
"from massdash.plotting import InteractivePlotter, PlotConfig\n",
"\n",
"plotConfig = PlotConfig()\n",
"plotConfig.smoothing_dict = dict(type='none')\n",
Expand Down
1 change: 0 additions & 1 deletion massdash/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""
=======
massdash
~~~~~~~~
TODO: ADD general documentation about how to use the auto API here
Expand Down
5 changes: 3 additions & 2 deletions massdash/constants.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
massdash/constants
~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~
"""

import os
Expand All @@ -23,4 +23,5 @@
URL_TEST_OSW = "https://github.com/Roestlab/massdash/raw/dev/test/test_data/example_dia/openswath/osw/test.osw"
URL_TEST_PQP = "https://github.com/Roestlab/massdash/raw/dev/test/test_data/example_dia/openswath/lib/test.pqp"
URL_TEST_RAW_MZML = "https://github.com/Roestlab/massdash/raw/dev/test/test_data/example_dia/raw/test_raw_1.mzML"
URL_TEST_DREAMDIA_REPORT = "https://github.com/Roestlab/massdash/raw/dev/test/test_data/example_dia/dreamdia/test_dreamdia_report.tsv"
URL_TEST_DREAMDIA_REPORT = "https://github.com/Roestlab/massdash/raw/dev/test/test_data/example_dia/dreamdia/test_dreamdia_report.tsv"
URL_PRETRAINED_CONFORMER = "https://github.com/Roestlab/massdash/releases/download/v0.0.1-alpha/base_cape.onnx"
5 changes: 5 additions & 0 deletions massdash/loaders/GenericChromatogramLoader.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
"""
massdash/loaders/GenericChromatogramLoader
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"""

from abc import abstractmethod
import pandas as pd
from typing import Dict, List, Union, Literal
Expand Down
3 changes: 3 additions & 0 deletions massdash/loaders/GenericSpectrumLoader.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
'''
massdash/loaders/GenericSpectrumLoader
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is an abstract class for loading spectra from a file.
'''

Expand Down
2 changes: 1 addition & 1 deletion massdash/loaders/SqMassLoader.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def loadTransitionGroups(self, pep_id: str, charge: int) -> Dict[str, Transition
prec_chrom_ids = t.getPrecursorChromIDs(precursor_id)
precursor_chroms = t.getDataForChromatograms(prec_chrom_ids['chrom_ids'], prec_chrom_ids['native_ids'])

out[t] = TransitionGroup(precursor_chroms, transition_chroms)
out[t] = TransitionGroup(precursor_chroms, transition_chroms, pep_id, charge)
return out

def loadTransitionGroupFeaturesDf(self, pep_id: str, charge: int) -> pd.DataFrame:
Expand Down
5 changes: 4 additions & 1 deletion massdash/loaders/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
"""
The :mod:`massseer.loaders` subpackage contains the structures for loading data into MassSeer
massdash/loaders
~~~~~~~~~~~~~~~~
The :mod:`massdash.loaders` subpackage contains the structures for loading data into MassDash
"""

from .GenericChromatogramLoader import GenericChromatogramLoader
Expand Down
2 changes: 1 addition & 1 deletion massdash/loaders/access/MzMLDataAccess.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ def msExperimentToFeatureMap(self, msExperiment: po.MSExperiment, feature: Trans
else:
LOGGER.warn(f"No spectra found for peptide: {feature.sequence}{feature.precursor_charge}. Try adjusting the extraction parameters")

return FeatureMap(results_df, config)
return FeatureMap(results_df, feature.sequence, feature.precursor_charge, config)

def _find_closest_reference_mz(self, given_mz: np.array, reference_mz_values: np.array, peptide_product_annotation_list: np.array) -> np.array:
"""
Expand Down
38 changes: 25 additions & 13 deletions massdash/peakPickers/ConformerPeakPicker.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
# Structs
from ..structs.TransitionGroup import TransitionGroup
from ..structs.TransitionGroupFeature import TransitionGroupFeature
from ..loaders.SpectralLibraryLoader import SpectralLibraryLoader
# Utils
from ..util import check_package
from ..util import LOGGER

onnxruntime, ONNXRUNTIME_AVAILABLE = check_package("onnxruntime")

Expand All @@ -35,7 +37,7 @@ class ConformerPeakPicker:
_convertConformerFeatureToTransitionGroupFeatures: Convert conformer predicted feature to TransitionGroupFeatures.
"""

def __init__(self, transition_group: TransitionGroup, pretrained_model_file: str, window_size: int = 175, prediction_threshold: float = 0.5, prediction_type: str = "logits"):
def __init__(self, library_file: str, pretrained_model_file: str, prediction_threshold: float = 0.5, prediction_type: str = "logits"):
"""
Initialize the ConformerPeakPicker class.
Expand All @@ -46,14 +48,18 @@ def __init__(self, transition_group: TransitionGroup, pretrained_model_file: str
prediction_threshold (float, optional): The prediction threshold for peak picking. Defaults to 0.5.
prediction_type (str, optional): The prediction type for peak picking. Defaults to "logits".
"""
self.transition_group = transition_group
self.pretrained_model_file = pretrained_model_file
self.window_size = window_size
self.prediction_threshold = prediction_threshold
self.prediction_type = prediction_type
self.onnx_session = None
self.library = SpectralLibraryLoader(library_file)

self._validate_model()

## set in load_model
self.onnx_session = None
self.window_size = None

LOGGER.name = __class__.__name__

def _validate_model(self):
"""
Expand All @@ -73,8 +79,14 @@ def load_model(self):
raise ImportError("onnxruntime is required for loading the pretrained Conformer model, but not installed.")
# Load pretrained model
self.onnx_session = onnxruntime.InferenceSession(self.pretrained_model_file)
if len(self.onnx_session.get_inputs()) == 0:
raise ValueError("Pretrained model does not have any inputs.")
elif len(self.onnx_session.get_inputs()[0].shape) != 3:
raise ValueError("First input to model must be a 3D numpy array, current shape: {}".format(len(self.onnx_session.get_inputs()[0].shape)))
else:
self.window_size = self.onnx_session.get_inputs()[0].shape[2]

def pick(self, max_int_transition: int=1000) -> List[TransitionGroupFeature]:
def pick(self, transition_group, max_int_transition: int=1000) -> List[TransitionGroupFeature]:
"""
Perform peak picking.
Expand All @@ -85,19 +97,19 @@ def pick(self, max_int_transition: int=1000) -> List[TransitionGroupFeature]:
List[TransitionGroupFeature]: The list of transition group features.
"""
# Transform data into required input
print("Preprocessing data...")
conformer_preprocessor = ConformerPreprocessor(self.transition_group)
input_data = conformer_preprocessor.preprocess()
print("Loading model...")
LOGGER.info("Loading model...")
self.load_model()
print("Predicting...")
LOGGER.info("Preprocessing data...")
conformer_preprocessor = ConformerPreprocessor(transition_group, self.window_size)
input_data = conformer_preprocessor.preprocess(self.library)
LOGGER.info("Predicting...")
ort_input = {self.onnx_session.get_inputs()[0].name: input_data}
ort_output = self.onnx_session.run(None, ort_input)
print("Getting predicted boundaries...")
LOGGER.info("Getting predicted boundaries...")
peak_info = conformer_preprocessor.find_top_peaks(ort_output[0], ["precursor"], self.prediction_threshold, self.prediction_type)
# Get actual peak boundaries
peak_info = conformer_preprocessor.get_peak_boundaries(peak_info, self.transition_group, self.window_size)
print(f"Peak info: {peak_info}")
peak_info = conformer_preprocessor.get_peak_boundaries(peak_info)
LOGGER.info(f"Peak info: {peak_info}")
return self._convertConformerFeatureToTransitionGroupFeatures(peak_info, max_int_transition)

def _convertConformerFeatureToTransitionGroupFeatures(self, peak_info: dict, max_int_transition: int=1000) -> List[TransitionGroupFeature]:
Expand Down
Loading

0 comments on commit ea57a56

Please sign in to comment.