From 985b95a4f7880c82c4e01ec72edd7855ff909003 Mon Sep 17 00:00:00 2001 From: Julia Schessner Date: Fri, 20 Sep 2024 14:29:02 +0200 Subject: [PATCH] remove additions before log transform --- alphastats/DataSet_Preprocess.py | 2 +- alphastats/DataSet_Statistics.py | 6 +++--- alphastats/plots/VolcanoPlot.py | 2 +- alphastats/statistics/DifferentialExpressionAnalysis.py | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/alphastats/DataSet_Preprocess.py b/alphastats/DataSet_Preprocess.py index 6e292b34..486e7c0d 100644 --- a/alphastats/DataSet_Preprocess.py +++ b/alphastats/DataSet_Preprocess.py @@ -250,7 +250,7 @@ def _compare_preprocessing_modes(self, func, params_for_func) -> list: return results_list def _log2_transform(self): - self.mat = np.log2(self.mat + 0.1) + self.mat = np.log2(self.mat) self.preprocessing_info.update({"Log2-transformed": True}) print("Data has been log2-transformed.") diff --git a/alphastats/DataSet_Statistics.py b/alphastats/DataSet_Statistics.py index 7ec59114..32d69bf2 100644 --- a/alphastats/DataSet_Statistics.py +++ b/alphastats/DataSet_Statistics.py @@ -15,9 +15,9 @@ class Statistics: - def _calculate_foldchange(self, mat_transpose:pd.DataFrame, group1_samples:list, group2_samples:list) -> pd.DataFrame: - mat_transpose += 0.00001 - + def _calculate_foldchange( + self, mat_transpose: pd.DataFrame, group1_samples: list, group2_samples: list + ) -> pd.DataFrame: if self.preprocessing_info["Log2-transformed"]: fc = ( mat_transpose[group1_samples].T.mean().values diff --git a/alphastats/plots/VolcanoPlot.py b/alphastats/plots/VolcanoPlot.py index 60591650..f5916341 100644 --- a/alphastats/plots/VolcanoPlot.py +++ b/alphastats/plots/VolcanoPlot.py @@ -149,7 +149,7 @@ def _sam(self): transposed = self.dataset.mat.transpose() - if self.dataset.preprocessing_info["Normalization"] is None: + if self.dataset.preprocessing_info["Log2-transformed"] is None: # needs to be lpog2 transformed for fold change calculations transposed = transposed.transform(lambda x: np.log2(x)) diff --git a/alphastats/statistics/DifferentialExpressionAnalysis.py b/alphastats/statistics/DifferentialExpressionAnalysis.py index ad88f36f..5bcdf13b 100644 --- a/alphastats/statistics/DifferentialExpressionAnalysis.py +++ b/alphastats/statistics/DifferentialExpressionAnalysis.py @@ -90,7 +90,7 @@ def sam(self) -> pd.DataFrame: from alphastats.multicova import multicova transposed = self.dataset.mat.transpose() - if self.dataset.preprocessing_info["Normalization"] is None: + if self.dataset.preprocessing_info["Log2-transformed"] is None: # needs to be lpog2 transformed for fold change calculations transposed = transposed.transform(lambda x: np.log2(x)) @@ -190,9 +190,9 @@ def pairedttest(self) -> pd.DataFrame: df["log2fc"] = fc return df - def _calculate_foldchange(self, mat_transpose:pd.DataFrame, group1_samples:list, group2_samples:list): - mat_transpose += 0.00001 - + def _calculate_foldchange( + self, mat_transpose: pd.DataFrame, group1_samples: list, group2_samples: list + ): if self.dataset.preprocessing_info["Log2-transformed"]: fc = ( mat_transpose[group1_samples].T.mean().values