def plotSignal(self, ax: plt, n: int, xpos: int, ypos: float, sig: str, sig_type: str) -> None: if sig_type == "NS1": color = "deepskyblue" shift = 3 elif sig_type == "NS2": color = "deepskyblue" shift = 4 elif sig_type == "NS3": color = "deepskyblue" shift = 4 elif sig_type == "CON1": color = "goldenrod" shift = 3 elif sig_type == "CON2": color = "goldenrod" shift = 4 elif sig_type == "CON3": color = "goldenrod" shift = 4 elif sig_type == "RAP": color = "violet" shift = 2 else: raise ValueError("Wrong sig_type:" + sig_type) color = "gray" ax.plot(self.xMl[n - shift: n + 1], self.yMl[n - shift: n + 1], color=color, linewidth=1) # ax.text(xpos - 30, ypos - 0.004, sig, fontsize=12, color=color, fontweight="bold") ax.text(xpos - 120, ypos - 0.03, sig_type, fontsize=6, color=color, fontweight="bold")
def plotSignal(self, ax: plt, n: int, xpos: int, ypos: float, sig: str, sig_type: str) -> None: if sig_type == "CON1": shift = 3 elif sig_type == "CON3": shift = 4 elif sig_type == "RAP": shift = 2 else: raise ValueError("Wrong sig_type:" + sig_type) ax.plot(self.xMl[n - shift: n + 1], self.yMl[n - shift: n + 1], color="gray",linewidth=1) ax.text(xpos - 120, ypos - 0.03, sig_type, fontsize=6, color="gray", fontweight="bold")
def plotSignal(self, ax: plt, n: int, xpos: int, ypos: float, sig: str, sig_type: str) -> None: shift = 3 if sig_type == "CON1" else 2 ax.plot(self.xMl[n - shift:n + 1], self.yMl[n - shift:n + 1], color="gray", linewidth=1) ax.text(xpos - 120, ypos - 0.03, sig_type, fontsize=6, color="gray", fontweight="bold")
def add_scatter_and_annotate(self, fig: plt, x_all: np.array, y_all: np.array, colour: str, idxs: np.array, annotate=False): x = x_all[idxs] y = y_all[idxs] ax = fig.scatter(x, y, c=colour, alpha=self.opacity, s=20) # Check if we want to annotate any of these with their gene IDs if self.values_to_label is not None: texts = [] labels = self.df[self.label_column].values[idxs] for i, name in enumerate(labels): if name in self.values_to_label: lbl_bg = self.values_colours.get(name) color = self.text_colours.get(name) texts.append( fig.text(x[i], y[i], name, color=color, fontsize=self.label_font_size, bbox=dict(fc=lbl_bg, alpha=1.0))) adjust_text(texts, force_text=2.0) # Check if the user wants these labeled if self.label_big_sig and annotate: # If they do have a limit on the number of ones we show (i.e. we don't want 10000 gene names...) max_values = -1 * self.max_labels if len(y) < self.max_labels: max_values = -1 * (len(y) - 1) most_sig_idxs = np.argpartition(y, max_values)[max_values:] labels = self.df[self.label_column].values[idxs][most_sig_idxs] x = x[most_sig_idxs] y = y[most_sig_idxs] # We only label the ones with the max log fc for i, name in enumerate(labels): fig.annotate(name, (x[i], y[i]), xytext=(0, 10), textcoords='offset points', ha='center', va='bottom', bbox=dict(boxstyle='round,pad=0.5', fc='white', alpha=0.2)) return ax