Skip to content

Commit

Permalink
Merge pull request #17 from MannLabs/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
EugeniaVoytik authored Mar 21, 2022
2 parents 1964a2c + 8304551 commit 46eb43c
Show file tree
Hide file tree
Showing 16 changed files with 73 additions and 41 deletions.
8 changes: 5 additions & 3 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
## Changelog

### 1.1.2
* FIX: Correct the bug with MS2 intensity prediction using deep learning.
* FIX: Correct the hover information/color for the MS2 spectrum for the predicted ion intensities.
* FIX: Fix the behaviour of the "Previous/Next frame" & "Overlay frames" buttons for DDA data analyzed by MaxQuant.

### 1.1.0
* FEAT: Integrate the AlphaPeptDeep package into AlphaViz to predict the peptide properties, such as the MS2 intensity prediction for DDA data and retention time/ion mobility prediction for DIA data.
* FEAT: Update the Quality Control tab to make it lighter than the previous version. Variables for plots (m/z, im, rt, length, etc. distributions) can now be selected.
* FEAT: Reorganize the Settings panel and add more customization options.
* DOCS: Extend Jupyter notebooks for manual visual inspection of timsTOF DDA and DIA data analyzed by MaxQuant and DIA-NN, respectively.


### 1.0.5

* FEAT: Enable the possibility to read DIA data analysed by the DIA-NN software analysis tool.
* FEAT: Extend the "Quality Control" tab with a summary statistics table and additional plots.
* FEAT: Add a "Targeted Mode" tab to work with raw data only.
Expand All @@ -17,6 +20,5 @@
* FIX: Correct the error when reading the MQ output files (missing columns).

### 0.0.1

* FEAT: Initial creation of alphaviz.
* FEAT: Read DDA Bruker data processed with MaxQuant software.
2 changes: 1 addition & 1 deletion alphaviz/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!python

__project__ = "alphaviz"
__version__ = "1.1.1"
__version__ = "1.1.2"
__license__ = "Apache"
__description__ = "A interactive Dashboard to explore mass spectrometry data."
__author__ = "Eugenia Voytik"
Expand Down
Binary file modified alphaviz/docs/alphaviz_tutorial.docx
Binary file not shown.
Binary file modified alphaviz/docs/alphaviz_tutorial.pdf
Binary file not shown.
66 changes: 47 additions & 19 deletions alphaviz/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
import logging
import platform
import json
import warnings
import pandas as pd
from pandas.core.common import SettingWithCopyWarning
from io import StringIO

import alphatims.bruker
Expand All @@ -21,6 +23,8 @@
import alphaviz.preprocessing
import alphaviz.plotting

warnings.simplefilter(action="ignore", category=SettingWithCopyWarning)


def get_css_style(
file_name="dashboard_style.css",
Expand Down Expand Up @@ -506,6 +510,7 @@ def load_data(self, *args):

self.psm_df['nce'] = 30
self.psm_df['instrument'] = 'timsTOF' # trained on more Lumos files therefore should work better than 'timsTOF'
self.psm_df['spec_idx'] += 1

self.trigger_dependancy()
self.upload_progress.active = False
Expand Down Expand Up @@ -886,19 +891,22 @@ def __init__(self, data, options):
button_type='default',
width=250,
align='center',
disabled=True,
margin=(25, 0, 0, 10),
)
self.export_svg_ms2_button = pn.widgets.Button(
name='Export as .svg',
button_type='default',
align='center',
disabled=True,
width=250,
margin=(25, 0, 0, 10),
)
self.export_svg_elprofiles_button = pn.widgets.Button(
name='Export as .svg',
button_type='default',
align='center',
disabled=True,
width=250,
margin=(25, 0, 0, 10),
)
Expand Down Expand Up @@ -1443,10 +1451,9 @@ def display_heatmap_spectrum(self, *args):
ms2_frame = self.ms2_frame
mz = self.peptide['mz']
im = self.peptide['im']
data_ms1 = self.data.raw_data[ms1_frame].copy()
try:
self.heatmap_ms1_plot = alphaviz.plotting.plot_heatmap(
data_ms1,
self.data.raw_data[ms1_frame],
mz=mz,
im=im,
x_axis_label=self.heatmap_x_axis.value,
Expand All @@ -1460,9 +1467,8 @@ def display_heatmap_spectrum(self, *args):
height=450,
margin=(0, 10, 10, 0),
)
data_ms2 = self.data.raw_data[ms2_frame].copy()
self.heatmap_ms2_plot = alphaviz.plotting.plot_heatmap(
data_ms2,
self.data.raw_data[ms2_frame],
x_axis_label=self.heatmap_x_axis.value,
y_axis_label=self.heatmap_y_axis.value,
title=f'MS2 frame(s) #{ms2_frame}',
Expand All @@ -1472,7 +1478,12 @@ def display_heatmap_spectrum(self, *args):
height=450,
margin=(0, 10, 10, 0),
)

self.layout[10] = pn.Row(
None,
None,
align='center',
sizing_mode='stretch_width'
)
self.layout[10][0] = pn.Column(
pn.pane.HoloViews(
self.heatmap_ms1_plot,
Expand All @@ -1495,13 +1506,21 @@ def display_heatmap_spectrum(self, *args):
)
except ValueError:
print('The x- and y-axis of the heatmaps should be different.')
except BaseException as x:
print('The heatmaps cannot be displayed.')
if self.analysis_software == 'diann':
if self.x_axis_label_diann.value == 'RT/IM dimension':
self.display_elution_profile_plots()
if self.analysis_software == 'maxquant':
self.layout[9][0] = self.previous_frame
self.layout[9][1] = self.next_frame
self.layout[11] = self.plot_overlapped_frames
for each in [self.previous_frame, self.next_frame, self.plot_overlapped_frames]:
if len(self.ms1_ms2_frames.keys()) < 2:
each.disabled = True
else:
each.disabled = False
if type(self.layout[9][0]) == pn.pane.markup.Str:
self.layout[9][0] = self.previous_frame
self.layout[9][1] = self.next_frame
self.layout[11] = self.plot_overlapped_frames
self.display_mass_spectrum()

def display_mass_spectrum(self, *args):
Expand All @@ -1527,7 +1546,6 @@ def display_mass_spectrum(self, *args):
predicted_df['FragmentMz'] = mz_ions.b_z1.values.tolist() + mz_ions.y_z1.values.tolist()[::-1]
predicted_df['RelativeIntensity'] = intensities_ions.b_z1.values.tolist() + intensities_ions.y_z1.values.tolist()[::-1]
predicted_df['ions'] = [f"b{i}" for i in range(1, len(mz_ions.b_z1)+1)] + [f"y{i}" for i in range(1, len(mz_ions.y_z1)+1)]

self.ms_spectra_plot = alphaviz.plotting.plot_complex_ms_plot(
data_ions,
title=f'MS2 spectrum for Precursor: {self.ms1_ms2_frames[self.current_frame][1]}',
Expand All @@ -1551,15 +1569,15 @@ def display_previous_frame(self, *args):
self.layout[12].loading = True
except IndexError:
pass
self.plot_overlapped_frames.value = False
current_frame_index = list(self.ms1_ms2_frames.keys()).index(self.current_frame)
if current_frame_index == 0:
self.current_frame = list(self.ms1_ms2_frames.keys())[-1]
else:
self.current_frame = list(self.ms1_ms2_frames.keys())[current_frame_index - 1]
if self.x_axis_label_mq.value == 'm/z':
self.display_line_spectra_plots()
self.display_heatmap_spectrum()
if self.plot_overlapped_frames.value == True:
self.plot_overlapped_frames.value = False
else:
self.display_heatmap_spectrum()

def display_next_frame(self, *args):
try:
Expand All @@ -1568,15 +1586,15 @@ def display_next_frame(self, *args):
self.layout[12].loading = True
except IndexError:
pass
self.plot_overlapped_frames.value = False
current_frame_index = list(self.ms1_ms2_frames.keys()).index(self.current_frame)
if current_frame_index == len(self.ms1_ms2_frames.keys())-1:
self.current_frame = list(self.ms1_ms2_frames.keys())[0]
else:
self.current_frame = list(self.ms1_ms2_frames.keys())[current_frame_index + 1]
if self.x_axis_label_mq.value == 'm/z':
self.display_line_spectra_plots()
self.display_heatmap_spectrum()
if self.plot_overlapped_frames.value == True:
self.plot_overlapped_frames.value = False
else:
self.display_heatmap_spectrum()

def display_overlapped_frames(self, *args):
try:
Expand All @@ -1586,6 +1604,8 @@ def display_overlapped_frames(self, *args):
except IndexError:
pass
if self.plot_overlapped_frames.value is True:
self.layout[12] = None
self.layout[13] = None
mz = float(self.peptides_table.value.iloc[self.peptides_table.selection[0]]['m/z'])
im = float(self.peptides_table.value.iloc[self.peptides_table.selection[0]]['1/K0'])
try:
Expand Down Expand Up @@ -1613,6 +1633,12 @@ def display_overlapped_frames(self, *args):
height=450,
margin=(0, 10, 10, 0),
)
self.layout[10] = pn.Row(
None,
None,
align='center',
sizing_mode='stretch_width'
)
self.layout[10][0] = pn.Column(
pn.pane.HoloViews(
self.heatmap_ms1_plot,
Expand All @@ -1633,10 +1659,10 @@ def display_overlapped_frames(self, *args):
self.export_svg_ms2_button,
align='center',
)

except ValueError:
print('The x- and y-axis of the heatmaps should be different.')
self.layout[12] = None
except BaseException as x:
print('The heatmaps cannot be displayed.')
else:
self.display_heatmap_spectrum()

Expand Down Expand Up @@ -1981,13 +2007,15 @@ def __init__(self, data, options):
name='Export as .svg',
button_type='default',
align='center',
disabled=True,
width=250,
margin=(25, 0, 0, 10),
)
self.export_svg_prediction_button = pn.widgets.Button(
name='Export as .svg',
button_type='default',
align='center',
disabled=True,
width=250,
margin=(25, 0, 0, 10),
)
Expand Down
12 changes: 7 additions & 5 deletions alphaviz/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ def plot_heatmap(
z_dimension
)
)

agg = rasterize(
dmap,
width=width,
Expand Down Expand Up @@ -565,20 +566,21 @@ def plot_mass_spectra(
mode='markers',
opacity=0.7,
marker=dict(color=b_ion_color, size=1),
hovertext=predicted[2],
hovertext=predicted[2][predicted_b_ions_ind],
hovertemplate='<b>m/z:</b> %{x};<br><b>Intensity:</b> %{y};<br><b>Ion:</b> %{hovertext}.',
name='',
showlegend=False
)
)
predicted_y_ions_ind = list(set(predicted[2].index).difference(predicted_b_ions_ind))
fig.add_trace(
go.Scatter(
x=predicted[0][set(predicted[2].index).difference(predicted_b_ions_ind)],
y=predicted[1][set(predicted[2].index).difference(predicted_b_ions_ind)],
x=predicted[0][predicted_y_ions_ind],
y=predicted[1][predicted_y_ions_ind],
mode='markers',
opacity=0.7,
marker=dict(color=b_ion_color if 'b' in predicted[2] else y_ion_color, size=1),
hovertext=predicted[2],
marker=dict(color=y_ion_color, size=1),
hovertext=predicted[2][predicted_y_ions_ind],
hovertemplate='<b>m/z:</b> %{x};<br><b>Intensity:</b> %{y};<br><b>Ion:</b> %{hovertext}.',
name='',
showlegend=False
Expand Down
2 changes: 1 addition & 1 deletion misc/bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.1.1
current_version = 1.1.2
commit = True
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+)(?P<build>\d+))?
Expand Down
4 changes: 2 additions & 2 deletions nbs/tutorial_MaxQuant.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"metadata": {},
"source": [
"To save the Plotly plots as .svg, you need to add this code with the name of the file inside the show function:\n",
"`.show(config=alphaviz.gui.update_config(filename='elution_profile.svg'))`. \n",
"`.show(config=alphaviz.gui.update_config(filename='elution_profile.svg'))` and when the plot is shown, click the \"Download plot\" button on the Plotly tool panel. \n",
"\n",
"You can also specify the height and width of the saved plot. See example for the Chromatogram plot."
]
Expand Down Expand Up @@ -577,7 +577,7 @@
"metadata": {},
"outputs": [],
"source": [
"predlib = model_mgr.predict_all(data_slice, predict_items=['ms2'], frag_types=['b_z1', 'y_z1'])"
"predlib = model_mgr.predict_all(data_slice, predict_items=['ms2'], frag_types=['b_z1', 'y_z1'], multiprocessing=False)"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion release/one_click_linux_gui/control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: alphaviz
Version: 1.1.1
Version: 1.1.2
Architecture: all
Maintainer: Mann Labs <opensource@alphapept.com>
Description: alphaviz
Expand Down
2 changes: 1 addition & 1 deletion release/one_click_linux_gui/create_installer_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ python setup.py sdist bdist_wheel
# Setting up the local package
cd release/one_click_linux_gui
# Make sure you include the required extra packages and always use the stable or very-stable options!
pip install "../../dist/alphaviz-1.1.1-py3-none-any.whl[stable,gui-stable]"
pip install "../../dist/alphaviz-1.1.2-py3-none-any.whl[stable,gui-stable]"

# Creating the stand-alone pyinstaller folder
pip install pyinstaller==4.2
Expand Down
4 changes: 2 additions & 2 deletions release/one_click_macos_gui/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<key>CFBundleIconFile</key>
<string>alpha_logo.icns</string>
<key>CFBundleIdentifier</key>
<string>alphaviz.1.1.1</string>
<string>alphaviz.1.1.2</string>
<key>CFBundleShortVersionString</key>
<string>1.1.1</string>
<string>1.1.2</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
4 changes: 2 additions & 2 deletions release/one_click_macos_gui/create_installer_macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ python setup.py sdist bdist_wheel

# Setting up the local package
cd release/one_click_macos_gui
pip install "../../dist/alphaviz-1.1.1-py3-none-any.whl[stable,gui-stable]"
pip install "../../dist/alphaviz-1.1.2-py3-none-any.whl[stable,gui-stable]"

# Creating the stand-alone pyinstaller folder
pip install pyinstaller==4.2
Expand All @@ -40,5 +40,5 @@ cp ../../LICENSE.txt Resources/LICENSE.txt
cp ../logos/alpha_logo.png Resources/alpha_logo.png
chmod 777 scripts/*

pkgbuild --root dist/alphaviz --identifier de.mpg.biochem.alphaviz.app --version 1.1.1 --install-location /Applications/alphaviz.app --scripts scripts alphaviz.pkg
pkgbuild --root dist/alphaviz --identifier de.mpg.biochem.alphaviz.app --version 1.1.2 --install-location /Applications/alphaviz.app --scripts scripts alphaviz.pkg
productbuild --distribution distribution.xml --resources Resources --package-path alphaviz.pkg dist/alphaviz_gui_installer_macos.pkg
2 changes: 1 addition & 1 deletion release/one_click_macos_gui/distribution.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<installer-script minSpecVersion="1.000000">
<title>alphaviz 1.1.1</title>
<title>alphaviz 1.1.2</title>
<background mime-type="image/png" file="alpha_logo.png" scaling="proportional"/>
<welcome file="welcome.html" mime-type="text/html" />
<conclusion file="conclusion.html" mime-type="text/html" />
Expand Down
2 changes: 1 addition & 1 deletion release/one_click_windows_gui/alphaviz_innoinstaller.iss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "alphaviz"
#define MyAppVersion "1.1.1"
#define MyAppVersion "1.1.2"
#define MyAppPublisher "Max Planck Institute of Biochemistry and the University of Copenhagen, Mann Labs"
#define MyAppURL "https://github.com/MannLabs/alphaviz"
#define MyAppExeName "alphaviz_gui.exe"
Expand Down
2 changes: 1 addition & 1 deletion release/one_click_windows_gui/create_installer_windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ python setup.py sdist bdist_wheel
# Setting up the local package
cd release/one_click_windows_gui
# Make sure you include the required extra packages and always use the stable or very-stable options!
pip install "../../dist/alphaviz-1.1.1-py3-none-any.whl[stable,gui-stable]"
pip install "../../dist/alphaviz-1.1.2-py3-none-any.whl[stable,gui-stable]"

# Creating the stand-alone pyinstaller folder
pip install pyinstaller==4.2
Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
alphatims==0.3.0
peptdeep==0.0.4
peptdeep==0.0.5
alphabase==0.0.5

0 comments on commit 46eb43c

Please sign in to comment.