Skip to content

Commit

Permalink
Merge pull request #230 from abyzovlab/master
Browse files Browse the repository at this point in the history
Fixing bug related to py12
  • Loading branch information
arpanda authored Jul 21, 2024
2 parents f6d0e79 + b6d1937 commit 1ac6b28
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
12 changes: 5 additions & 7 deletions cnvpytor/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def gc_at_decompress(gcat):
Binned AT content (100bp bins).
"""
return list(gcat[:gcat.size // 2]), list(100 - gcat[:gcat.size // 2] - gcat[gcat.size // 2:])
return list(map(int, gcat[:gcat.size // 2])), list(map(int, 100 - gcat[:gcat.size // 2] - gcat[gcat.size // 2:]))


def gcp_decompress(gcat, bin_ratio=1):
Expand Down Expand Up @@ -580,7 +580,8 @@ def fit_bimodal(x, y):
try:
with warnings.catch_warnings():
warnings.simplefilter("error", OptimizeWarning)
popt, pcov = curve_fit(bimodal, x, y, p0=[area / 2, mean * 0.66, sigma / 2, area / 2, mean * 1.33, sigma / 2])
popt, pcov = curve_fit(bimodal, x, y,
p0=[area / 2, mean * 0.66, sigma / 2, area / 2, mean * 1.33, sigma / 2])
return popt, pcov
except OptimizeWarning:
_logger.warning("Problem with fit: OptimizeWarning. Return None!")
Expand Down Expand Up @@ -1212,7 +1213,7 @@ def calculate_likelihood(io, bin_size, chrom, snp_use_mask=True, snp_use_id=Fals
count01[b] += 1
if reduce_noise:
likelihood[b] *= beta_fun(nalt[i] + (1 if nalt[i] < nref[i] else 0),
nref[i] + (1 if nref[i] < nalt[i] else 0), lh_x)
nref[i] + (1 if nref[i] < nalt[i] else 0), lh_x)
else:
likelihood[b] *= beta_fun(nalt[i] * blw, nref[i] * blw, lh_x)
s = np.sum(likelihood[b])
Expand All @@ -1229,14 +1230,11 @@ def calculate_likelihood(io, bin_size, chrom, snp_use_mask=True, snp_use_id=Fals
count11[b] += 1

for i in range(max_bin):
if (count01[i] + count10[i])==0 and use_hom:
if (count01[i] + count10[i]) == 0 and use_hom:
likelihood[i] = lh_x * 0. + 1 / res
likelihood[i][0] = 0.5 * (count11[i] + count00[i])
likelihood[i][-1] = 0.5 * (count11[i] + count00[i])
s = np.sum(likelihood[i])
likelihood[i] /= s

return likelihood



2 changes: 1 addition & 1 deletion cnvpytor/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4624,7 +4624,7 @@ def rd_stat_violin(self):
ax.grid(True)
self.fig_show(suffix="rd_stat_violin")

def rd_stat_violin(self, regions, factor=1):
def rd_stat_violin_regions(self, regions, factor=1):
chroms = []
for c, (l, t) in self.reference_genome["chromosomes"].items():
rd_chr = self.io[self.plot_files[0]].rd_chromosome_name(c)
Expand Down

0 comments on commit 1ac6b28

Please sign in to comment.