From b6d19377a0f7df05ee28ae698e895979e0028ae4 Mon Sep 17 00:00:00 2001 From: suvakov Date: Sat, 20 Jul 2024 04:02:53 -0500 Subject: [PATCH] Fixing bug related to py12 --- cnvpytor/utils.py | 12 +++++------- cnvpytor/viewer.py | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/cnvpytor/utils.py b/cnvpytor/utils.py index 35fc1a0..fc02b09 100644 --- a/cnvpytor/utils.py +++ b/cnvpytor/utils.py @@ -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): @@ -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!") @@ -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]) @@ -1229,7 +1230,7 @@ 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]) @@ -1237,6 +1238,3 @@ def calculate_likelihood(io, bin_size, chrom, snp_use_mask=True, snp_use_id=Fals likelihood[i] /= s return likelihood - - - diff --git a/cnvpytor/viewer.py b/cnvpytor/viewer.py index 4bc07ec..bdaf895 100644 --- a/cnvpytor/viewer.py +++ b/cnvpytor/viewer.py @@ -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)