Skip to content

Commit

Permalink
Merge pull request #166 from MannLabs/feature_release_0_5
Browse files Browse the repository at this point in the history
Release 0.5.0
  • Loading branch information
elena-krismer authored Apr 11, 2023
2 parents 3a6a326 + 738ccf3 commit b8a9183
Show file tree
Hide file tree
Showing 32 changed files with 754 additions and 246 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.4.5
current_version = 0.5.0
commit = True
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+)(?P<build>\d+))?
Expand Down
Binary file modified .coverage
Binary file not shown.
8 changes: 8 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

# 0.5.0
* ADD plot Sample Distribution Histogram
* ADD paired-ttest option
* ENH add option to remove samples in GUI
* ADD pyComBat Batch correction Behdenna A, Haziza J, Azencot CA and Nordor A. (2020) pyComBat, a Python tool for batch effects correction in high-throughput molecular data using empirical Bayes methods. bioRxiv doi: 10.1101/2020.03.17.995431
* remove iteration utilities, remove C++ dependency
* ENH upgrade to pandas 2.0.0

# 0.4.5
* FIX loading of Data on Windows

Expand Down
9 changes: 9 additions & 0 deletions alphastats/DataSet_Plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from alphastats.plots.VolcanoPlot import VolcanoPlot
from alphastats.plots.IntensityPlot import IntensityPlot
from alphastats.plots.ClusterMap import ClusterMap
from alphastats.plots.SampleHistogram import SampleHistogram
from alphastats.utils import ignore_warning, check_for_missing_values


Expand Down Expand Up @@ -290,6 +291,14 @@ def plot_clustermap(
)
return clustermap.plot

def plot_samplehistograms(self):
"""Plots the Denisty distribution of each sample
Returns:
plotly: Plotly Graph Object
"""
return SampleHistogram(dataset=self).plot()

@check_for_missing_values
def plot_dendrogram(
self, linkagefun=lambda x: scipy.cluster.hierarchy.linkage(x, "complete")
Expand Down
36 changes: 25 additions & 11 deletions alphastats/DataSet_Preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import itertools



class Preprocess:
def _remove_sampels(self, sample_list):
# exclude samples for analysis
Expand Down Expand Up @@ -166,7 +167,7 @@ def reset_preprocessing(self):
self.create_matrix()
print("All preprocessing steps are reset.")

def _compare_preprocessing_modes(self, func, params_for_func):
def _compare_preprocessing_modes(self, func, params_for_func) -> list:
dataset = self
imputation_methods = ["mean", "median", "knn"]
normalization_methods = ["zscore", "quantile", "vst"]
Expand Down Expand Up @@ -195,18 +196,31 @@ def _compare_preprocessing_modes(self, func, params_for_func):

def _log2_transform(self):
self.mat = np.log2(self.mat + 0.1)
self.preprocessing_info.update({"Log2 Transformed": True})
self.preprocessing_info.update({"Log2-transformed": True})
print("Data has been log2-transformed.")

def batch_correction(self, batch:str):
"""Correct for technical bias/batch effects
Behdenna A, Haziza J, Azencot CA and Nordor A. (2020) pyComBat, a Python tool for batch effects correction in high-throughput molecular data using empirical Bayes methods. bioRxiv doi: 10.1101/2020.03.17.995431
Args:
batch (str): column name in the metadata describing the different batches
"""
import combat
from combat.pycombat import pycombat
data = self.mat.transpose()
series_of_batches = self.metadata.set_index(self.sample).reindex(data.columns.to_list())[batch]
self.mat = pycombat(data=data, batch=series_of_batches).transpose()

@ignore_warning(RuntimeWarning)
def preprocess(
self,
log2_transform=True,
remove_contaminations=False,
subset=False,
normalization=None,
imputation=None,
remove_samples=None,
log2_transform: bool=True,
remove_contaminations: bool=False,
subset: bool=False,
normalization: str=None,
imputation: str=None,
remove_samples: list=None,
):
"""Preprocess Protein data
Expand Down Expand Up @@ -251,6 +265,9 @@ def preprocess(
"""
if remove_contaminations:
self._filter()

if remove_samples is not None:
self._remove_sampels(sample_list=remove_samples)

if subset:
self.mat = self._subset()
Expand All @@ -264,8 +281,5 @@ def preprocess(
if imputation is not None:
self._imputation(method=imputation)

if remove_samples is not None:
self._remove_sampels(sample_list=remove_samples)

self.mat = self.mat.loc[:, (self.mat != 0).any(axis=0)]
self.preprocessed = True
Loading

0 comments on commit b8a9183

Please sign in to comment.