Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
hanyangii committed Aug 15, 2024
1 parent 86b01ca commit 42ab495
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/methylbert/deconvolute.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def grid_search(logits, margins, n_grid, verbose=True):
theta = m_theta*(1/n_grid)
theta = np.array([1-theta, theta]).reshape([2,1])
if logits.shape[1] != theta.shape[0]:
raise ValueError(f"Dimensions are wrong: theta {theta.shape}, prob {prob.shape}")
raise ValueError(f"Dimensions are wrong: theta {theta.shape}, prob {logits.shape}")
grid[0, m_theta] = likelihood_fun(theta, margins, logits)
if verbose:
pbar.update(1)
Expand Down Expand Up @@ -111,7 +111,7 @@ def skewness_test(x, *args):

estimates = np.clip(estimates, 0, 1)

return [estimates, 1-estimates], list(fi), dmr_labels, list(likelihood), list(region_purity), list(weights)
return [estimates, 1-estimates], list(fi), dmr_labels, list(likelihood), #list(region_purity), list(weights)

def optimise_nll_deconvolute(reads : pd.DataFrame,
margins : pd.Series):
Expand Down Expand Up @@ -222,6 +222,6 @@ def deconvolute(trainer : MethylBertFinetuneTrainer,
deconv_res = optimise_nll_deconvolute(reads = total_res, margins = margins)
deconv_res.to_csv(output_path+"/deconvolution.csv", sep="\t", header=True, index=False)
else:
raise RuntimeError("There is only one cell type in the training data set. Neither purity estimation nor deconvolution can be performed.")
raise RuntimeError(f"There are less than two cell types in the training data set. {margins.keys()} Neither purity estimation nor deconvolution can be performed.")


4 changes: 2 additions & 2 deletions src/methylbert/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import random
import warnings, random
import numpy as np
import torch

Expand Down Expand Up @@ -84,4 +84,4 @@ def _moment(a, moment, axis, *, mean=None):
s = s**2
if n % 2:
s *= a_zero_mean
return np.mean(s, axis)
return np.mean(s, axis)

0 comments on commit 42ab495

Please sign in to comment.