Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUGFIX: remove additions before log transform #337

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading