Skip to content

Commit d79a158

Browse files
Merge pull request #197 from MannLabs/revision
Release 0.6.0 Revision
2 parents 719ba6c + adab852 commit d79a158

26 files changed

Lines changed: 1713 additions & 38 deletions

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.5.4
2+
current_version = 0.6.0
33
commit = True
44
tag = False
55
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+)(?P<build>\d+))?

HISTORY.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Changelog
2+
# 0.6.0
3+
* ADD mzTAB support
4+
* ENH color Volcano Plot data points using list of protein names `color_list=your_protein_list`
25

36
# 0.5.4
47
* FIX altair version - binning of streamlit version

alphastats/DataSet.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from alphastats.loader.FragPipeLoader import FragPipeLoader
1111
from alphastats.loader.MaxQuantLoader import MaxQuantLoader
1212
from alphastats.loader.SpectronautLoader import SpectronautLoader
13+
from alphastats.loader.mzTabLoader import mzTabLoader
1314

1415
from alphastats.DataSet_Plot import Plot
1516
from alphastats.DataSet_Preprocess import Preprocess
@@ -96,7 +97,7 @@ def _check_loader(self, loader):
9697
loader : loader
9798
"""
9899
if not isinstance(
99-
loader, (AlphaPeptLoader, MaxQuantLoader, DIANNLoader, FragPipeLoader, SpectronautLoader)
100+
loader, (AlphaPeptLoader, MaxQuantLoader, DIANNLoader, FragPipeLoader, SpectronautLoader, mzTabLoader)
100101
):
101102
raise LoaderError(
102103
"loader must be from class: AlphaPeptLoader, MaxQuantLoader, DIANNLoader, FragPipeLoader or SpectronautLoader"

alphastats/DataSet_Plot.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,16 @@ def plot_volcano(
119119
self,
120120
group1,
121121
group2,
122-
column=None,
123-
method="ttest",
124-
labels=False,
125-
min_fc=1,
126-
alpha=0.05,
127-
draw_line=True,
128-
perm=100,
129-
fdr=0.05,
130-
compare_preprocessing_modes=False
122+
column:str=None,
123+
method:str="ttest",
124+
labels:bool=False,
125+
min_fc:float=1.0,
126+
alpha:float=0.05,
127+
draw_line:bool=True,
128+
perm:int=100,
129+
fdr:float=0.05,
130+
compare_preprocessing_modes:bool=False,
131+
color_list:list=[]
131132
):
132133
"""Plot Volcano Plot
133134
@@ -142,6 +143,7 @@ def plot_volcano(
142143
draw_line(boolean): whether to draw cut off lines.
143144
perm(float,optional): number of permutations when using SAM as method. Defaults to 100.
144145
fdr(float,optional): FDR cut off when using SAM as method. Defaults to 0.05.
146+
color_list (list): list with ProteinIDs that should be highlighted.
145147
compare_preprocessing_modes(bool): Will iterate through normalization and imputation modes and return a list of VolcanoPlots in different settings, Default False.
146148
147149
@@ -166,7 +168,8 @@ def plot_volcano(
166168
alpha=alpha,
167169
draw_line=draw_line,
168170
perm=perm,
169-
fdr=fdr
171+
fdr=fdr,
172+
color_list=color_list
170173
)
171174

172175
return volcano_plot.plot
@@ -241,7 +244,7 @@ def plot_intensity(
241244
ID (str): ProteinGroup ID
242245
group (str, optional): A metadata column used for grouping. Defaults to None.
243246
subgroups (list, optional): Select variables from the group column. Defaults to None.
244-
method (str, optional): Violinplot = "violin", Boxplot = "box", Scatterplot = "scatter". Defaults to "box".
247+
method (str, optional): Violinplot = "violin", Boxplot = "box", Scatterplot = "scatter" or "all". Defaults to "box".
245248
add_significance (bool, optional): add p-value bar, only possible when two groups are compared. Defaults False.
246249
log_scale (bool, optional): yaxis in logarithmic scale. Defaults to False.
247250

alphastats/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__project__ = "alphastats"
2-
__version__ = "0.5.4"
2+
__version__ = "0.6.0"
33
__license__ = "Apache"
44
__description__ = "An open-source Python package for Mass Spectrometry Analysis"
55
__author__ = "Mann Labs"

alphastats/loader/mzTabLoader.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from pyteomics import mztab
2+
from alphastats.loader.BaseLoader import BaseLoader
3+
4+
class mzTabLoader(BaseLoader):
5+
def __init__(self, file, intensity_column: str="protein_abundance_[sample]", index_column:str="accession"):
6+
"""Load mzTab file. Will add contamination column for further analysis.
7+
8+
Args:
9+
file (str): path to mzTab file.
10+
intensity_column (str, optional): columns where the intensity of the proteins are given.. Defaults to "protein_abundance_[sample]".
11+
index_column (str, optional): column indicating the protein groups. Defaults to "accession".
12+
"""
13+
self.filter_columns = []
14+
self.gene_names = None
15+
self.intensity_column = intensity_column
16+
self.index_column = index_column
17+
self.confidence_column = None
18+
self.evidence_df = None
19+
self.gene_names = None
20+
self._load_protein_table(file=file)
21+
self._add_contamination_column()
22+
23+
24+
def _load_protein_table(self, file):
25+
tables = mztab.MzTab(file)
26+
self.rawinput = tables.protein_table
27+
self.mztab_metadata = tables.metadata
28+
self.software = tables.protein_table.search_engine[0]
29+

alphastats/plots/IntensityPlot.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ def _plot(self):
128128
self.prepared_df, y=self.protein_id, x=self.group, color=self.group, labels={self.protein_id: self.y_label}
129129
)
130130

131+
elif self.method == "all":
132+
fig = px.violin(
133+
self.prepared_df, y=self.protein_id, x=self.group, color=self.group, labels={self.protein_id: self.y_label},
134+
box=True, points="all"
135+
)
136+
131137
else:
132138
raise ValueError(
133139
f"{self.method} is not available."

alphastats/plots/VolcanoPlot.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ def __init__(
1515
column=None, method=None,
1616
labels=None, min_fc=None,
1717
alpha=None, draw_line=None,
18-
plot=True, perm=100, fdr=0.05
18+
plot=True, perm=100, fdr=0.05,
19+
color_list=[]
1920
):
2021
self.dataset = dataset
2122
self.group1 = group1
@@ -31,6 +32,7 @@ def __init__(
3132
self.res = None
3233
self.pvalue_column = None
3334
self.perm=perm
35+
self.color_list = color_list
3436
self._check_input()
3537

3638
if plot:
@@ -266,6 +268,10 @@ def _annotate_result_df(self):
266268

267269
value = ["down", "up"]
268270
self.res["color"] = np.select(condition, value, default="non_sig")
271+
272+
if len(self.color_list) > 0:
273+
self.res["color"] = np.where(self.res[self.dataset.index_column].isin(self.color_list),
274+
"color", "no_color")
269275

270276

271277
def _add_labels_plot(self):
@@ -327,6 +333,17 @@ def _draw_fdr_line(self):
327333
line_shape='spline',
328334
showlegend=False)
329335
)
336+
337+
def _color_data_points(self):
338+
# update coloring
339+
if len(self.color_list) == 0:
340+
color_dict = {"non_sig": "#404040", "up": "#B65EAF", "down": "#009599"}
341+
342+
else:
343+
color_dict = {"no_color": "#404040", "color": "#B65EAF"}
344+
345+
self.plot = self._update_colors_plotly(self.plot, color_dict=color_dict)
346+
330347

331348

332349
def _plot(self):
@@ -339,8 +356,7 @@ def _plot(self):
339356
)
340357

341358
# update coloring
342-
color_dict = {"non_sig": "#404040", "up": "#B65EAF", "down": "#009599"}
343-
self.plot = self._update_colors_plotly(self.plot, color_dict=color_dict)
359+
self._color_data_points()
344360

345361
if self.labels:
346362
self._add_labels_plot()

docs/Introduction.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77

88
AlphaPeptStats is an open-source package for analyzing mass spectrometry-based proteomics data.
99

10-
AlphaPeptStats was developed to simplify and standardize the process of analyzing complex datasets. Hereby AlphaPeptStats supports proteomics data generated by `AlphaPept`, `DIA-NN`, `FragPipe`, `MaxQuant` and `Spectronaut`. The tool allows a structured workflow from importing data, preprocessing data to visualization.
10+
AlphaPeptStats was developed to simplify and standardize the process of analyzing complex datasets. Hereby AlphaPeptStats supports proteomics data generated by `AlphaPept`, `DIA-NN`, `FragPipe`, `MaxQuant` and `Spectronaut` and quantiative proteomics results in `mzTab` format. The tool allows a structured workflow from importing data, preprocessing data to visualization.
1111

1212
AlphaPeptStats was developed by the [Mann Group at the University of Copenhagen](https://www.biochem.mpg.de/mann) and is freely available with an [Apache License](LICENSE.txt). External Python packages (available in the [requirements](requirements) folder) have their own licenses, which can be consulted on their respective websites.
13+
14+
The workflow consists of:
15+
1. Import of proteomics data
16+
2. Creation of the DataSet, consisting of the imported proteomics data and metadata
17+
3. Data preprocessing (optional)
18+
4. Statistical Analysis and Visualization

docs/api_reference/loader.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,9 @@ SpectronautLoader
3232
.. automodule:: alphastats.loader.SpectronautLoader
3333
:members:
3434
:undoc-members:
35+
36+
mzTabLoader
37+
~~~~~~~~~~~~~~~~~~~~~~
38+
.. automodule:: alphastats.loader.mzTabLoader
39+
:members:
40+
:undoc-members:

0 commit comments

Comments
 (0)