Skip to content

Commit

Permalink
remove additions before log transform
Browse files Browse the repository at this point in the history
  • Loading branch information
JuliaS92 committed Sep 20, 2024
1 parent 0d86381 commit 985b95a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion alphastats/DataSet_Preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")

Expand Down
6 changes: 3 additions & 3 deletions alphastats/DataSet_Statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion alphastats/plots/VolcanoPlot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
8 changes: 4 additions & 4 deletions alphastats/statistics/DifferentialExpressionAnalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 985b95a

Please sign in to comment.