Skip to content

Commit

Permalink
Merge pull request #103 from MannLabs/multicova
Browse files Browse the repository at this point in the history
Multicova
  • Loading branch information
elena-krismer authored Feb 10, 2023
2 parents 2fa7a7b + 9b6c350 commit fbbc7a3
Show file tree
Hide file tree
Showing 21 changed files with 977 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.3.0
current_version = 0.4.0
commit = True
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+)(?P<build>\d+))?
Expand Down
5 changes: 5 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

# 0.4.0
* SAM implementation from Isabel (MultiCova)
* Volcano Plot with permutation based FDR line
* Bug fix when reseting matrix and saving info

# 0.3.0
* One Click Installer for macOS, Linux and Windows
* Spectronaut support
Expand Down
5 changes: 3 additions & 2 deletions alphastats/DataSet.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ def _remove_misc_samples_in_metadata(self):
)

def create_matrix(self):
"""Creates a matrix of the Outputfile, with columns displaying features (Proteins) and
"""
Creates a matrix of the Outputfile, with columns displaying features (Proteins) and
rows the samples.
"""

Expand All @@ -126,7 +127,7 @@ def create_matrix(self):
# remove proteins with only zero
self.mat = mat.loc[:, (mat != 0).any(axis=0)]
# reset preproccessing info
self._save_dataset_info()
self.preprocessing_info = self._save_dataset_info()
self.preprocessed = False
self.rawmat = mat

Expand Down
8 changes: 7 additions & 1 deletion alphastats/DataSet_Plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,22 @@ def plot_volcano(
min_fc=1,
alpha=0.05,
draw_line=True,
perm=100,
fdr=0.05
):
"""Plot Volcano Plot
Args:
column (str): column name in the metadata file with the two groups to compare
group1 (str/list): name of group to compare needs to be present in column or list of sample names to compare
group2 (str/list): name of group to compare needs to be present in column or list of sample names to compare
method (str): "anova", "wald", "ttest", Defaul ttest.
method (str): "anova", "wald", "ttest", "SAM" Defaul ttest.
labels (bool): Add text labels to significant Proteins, Default False.
alpha(float,optional): p-value cut off.
min_fc (float): Minimum fold change
draw_line(boolean): whether to draw cut off lines.
perm(float,optional): number of permutations when using SAM as method. Defaults to 100.
fdr(float,optional): FDR cut off when using SAM as method. Defaults to 0.05.
Returns:
Expand All @@ -132,6 +136,8 @@ def plot_volcano(
min_fc=min_fc,
alpha=alpha,
draw_line=draw_line,
perm=perm,
fdr=fdr
)

return volcano_plot.plot
Expand Down
4 changes: 3 additions & 1 deletion alphastats/DataSet_Statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,11 @@ def diff_expression_analysis(self, group1, group2, column=None, method="ttest"):
elif method == "ttest":
test = de.test.t_test(data=d, grouping=column)

#elif method == "SAM":

else:
raise ValueError(
f"{method} is invalid choose between 'wald' for Wald-test and 'ttest'"
f"{method} is invalid choose between 'wald' for Wald-test, 'SAM' and 'ttest'"
)

df = test.summary().rename(columns={"gene": self.index_column})
Expand Down
2 changes: 1 addition & 1 deletion alphastats/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__project__ = "alphastats"
__version__ = "0.3.0"
__version__ = "0.4.0"
__license__ = "Apache"
__description__ = "An open-source Python package for Mass Spectrometry Analysis"
__author__ = "Mann Labs"
Expand Down
9 changes: 3 additions & 6 deletions alphastats/gui/pages/04_Analysis.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import streamlit as st
from alphastats.gui.utils.analysis_helper import (
get_analysis,
load_options,
) # , check_if_options_are_loaded
)
from alphastats.gui.utils.ui_helper import sidebar_info
import alphastats.gui.utils.analysis_helper
import pandas as pd
Expand Down Expand Up @@ -139,17 +138,15 @@ def select_analysis():
if method in st.session_state.plotting_options.keys():

analysis_result = get_analysis(

method=method, options_dict=st.session_state.plotting_options
)

plot_to_display = True

elif method in st.session_state.statistic_options.keys():

analysis_result = get_analysis(
method=method, options_dict=st.session_state.statistic_options
)
method=method, options_dict=st.session_state.statistic_options
)
df_to_display = True

st.markdown("")
Expand Down
13 changes: 11 additions & 2 deletions alphastats/gui/utils/analysis_helper.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from tkinter import E
import pandas as pd
import logging
import streamlit as st
Expand Down Expand Up @@ -93,7 +92,7 @@ def gui_volcano_plot():
chosen_parameter_dict = helper_compare_two_groups()
method = st.selectbox(
"Differential Analysis using:",
options=["ttest", "anova", "wald"],
options=["ttest", "anova", "wald", "sam"],
)
chosen_parameter_dict.update({"method": method})

Expand All @@ -116,6 +115,16 @@ def gui_volcano_plot():
"min_fc": min_fc,
}

if method == "sam":
perm = st.number_input(
label="Number of Permutations", min_value=1, max_value=1000, value=10
)
fdr = st.number_input(
label="FDR cut off", min_value=0.005, max_value=0.1, value=0.050
)
chosen_parameter_dict.update({"perm": perm, "fdr": fdr})


submitted = st.button("Submit")

if submitted:
Expand Down
Empty file.
Loading

0 comments on commit fbbc7a3

Please sign in to comment.