Skip to content

Commit

Permalink
Nothing transform for comparison; make min_samples more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
Bribak committed Apr 17, 2024
1 parent 5393626 commit 2222556
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions build/lib/glycowork/motif/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,8 @@ def get_differential_expression(df, group1, group2,
df = get_additive_logratio_transformation(df, group1, group2, paired = paired)
elif transform == "CLR":
df.iloc[:, 1:] = clr_transformation(df.iloc[:, 1:], group1, group2, gamma = gamma, custom_scale = custom_scale)
elif transform == "Nothing":
pass
else:
raise ValueError("Only ALR and CLR are valid transforms for now.")
# Sample-size aware alpha via Bayesian-Adaptive Alpha Adjustment
Expand Down
6 changes: 3 additions & 3 deletions glycowork/glycan_data/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,9 @@ def impute_and_normalize(df, groups, impute = True, min_samples = 0.1):
| Returns a dataframe in the same style as the input
"""
if min_samples:
min_count = np.floor(df.shape[1] * min_samples)
min_count = max(np.floor(df.shape[1] * min_samples), 2) + 1
mask = (df != 0).sum(axis = 1) >= min_count
df = df[mask]
df = df[mask].reset_index(drop = True)
colname = df.columns[0]
glycans = df[colname]
df = df.iloc[:, 1:]
Expand Down Expand Up @@ -998,7 +998,7 @@ def correct_multiple_testing(pvals, alpha):
corrpvals = [p if p >= pvals[i] else pvals[i] for i, p in enumerate(corrpvals)]
significance = [p < alpha for p in corrpvals]
if sum(significance) > 0.9*len(significance):
print("Significance inflation detected. The CLR/ALR transformation cannot seem to handle this dataset.\
print("Significance inflation detected. The CLR/ALR transformation cannot seem to handle this dataset. Consider running again with a higher gamma value.\
Proceed with caution; for now switching to Bonferroni correction to be conservative about this.")
res = multipletests(pvals, method = 'bonferroni')
corrpvals, alpha = res[1], res[3]
Expand Down
2 changes: 2 additions & 0 deletions glycowork/motif/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,8 @@ def get_differential_expression(df, group1, group2,
df = get_additive_logratio_transformation(df, group1, group2, paired = paired)
elif transform == "CLR":
df.iloc[:, 1:] = clr_transformation(df.iloc[:, 1:], group1, group2, gamma = gamma, custom_scale = custom_scale)
elif transform == "Nothing":
pass
else:
raise ValueError("Only ALR and CLR are valid transforms for now.")
# Sample-size aware alpha via Bayesian-Adaptive Alpha Adjustment
Expand Down

0 comments on commit 2222556

Please sign in to comment.