From 49bacd0c99edb4a0570ec509a989d67c3f912c05 Mon Sep 17 00:00:00 2001 From: pedrofale Date: Wed, 8 Jun 2022 14:52:25 +0200 Subject: [PATCH] Lint code --- scatrex/scatrex.py | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/scatrex/scatrex.py b/scatrex/scatrex.py index 4b7970c..3aa88cd 100644 --- a/scatrex/scatrex.py +++ b/scatrex/scatrex.py @@ -1551,16 +1551,28 @@ def plot_cnv_inheritance(self): def plot_proportions(self, dna=True, rna=True, show=True): if dna: - dna_props = np.array([self.observed_tree.tree_dict[node]['weight'] for node in self.observed_tree.tree_dict]) + dna_props = np.array( + [ + self.observed_tree.tree_dict[node]["weight"] + for node in self.observed_tree.tree_dict + ] + ) nodes_labels = np.array([node for node in self.observed_tree.tree_dict]) - colors = np.array([self.observed_tree.tree_dict[node]['color'] for node in self.observed_tree.tree_dict]) + colors = np.array( + [ + self.observed_tree.tree_dict[node]["color"] + for node in self.observed_tree.tree_dict + ] + ) s = np.argsort(np.array(nodes_labels)) dna_nodes_labels = nodes_labels[s] dna_colors = colors[s] dna_props = dna_props[s] if rna: - rna_nodes, rna_props = self.ntssb.get_node_data_sizes(normalized=True, super_only=True) + rna_nodes, rna_props = self.ntssb.get_node_data_sizes( + normalized=True, super_only=True + ) nodes_labels = [node.label for node in nodes] s = np.argsort(np.array(nodes_labels)) rna_nodes = np.array(rna_nodes)[s] @@ -1570,12 +1582,19 @@ def plot_proportions(self, dna=True, rna=True, show=True): if dna and rna: if set(dna_nodes_labels) != set(rna_nodes_labels): - raise ValueError(f"DNA and RNA nodes are not the same! DNA: {dna_nodes_labels}, RNA: {rna_nodes_labels}") + raise ValueError( + f"DNA and RNA nodes are not the same! DNA: {dna_nodes_labels}, RNA: {rna_nodes_labels}" + ) handles = [] for i, node in enumerate(rna_nodes): dna_bottom = np.sum(dna_props[:i]) rna_bottom = np.sum(rna_props[:i]) - h = plt.bar(['DNA', 'RNA'], [dna_props[i], rna_props[i]], color=[dna_colors[i], rna_colors[i]], bottom=[dna_bottom, rna_bottom]) + h = plt.bar( + ["DNA", "RNA"], + [dna_props[i], rna_props[i]], + color=[dna_colors[i], rna_colors[i]], + bottom=[dna_bottom, rna_bottom], + ) handles.append(h[0]) plt.legend(handles, nodes_labels) else: