def draw(self, roundrect=False, plot_label=True): if self.empty: return y = self.y color = self.color ax = self.ax xstart = self.xstart gap = self.gap va = self.va nseqids = len(self.seqids) tr = self.tr for i, sid in enumerate(self.seqids): size = self.sizes[sid] rsize = self.ratio * size xend = xstart + rsize hc = HorizontalChromosome(ax, xstart, xend, y, height=self.height, lw=self.lw, fc=color, roundrect=roundrect) hc.set_transform(tr) sid = sid.rsplit("_", 1)[-1] si = "".join(x for x in sid if x not in string.letters) si = str(int(si)) xx = (xstart + xend) / 2 xstart = xend + gap if nseqids > 2 * MaxSeqids and (i + 1) % 10 != 0: continue if nseqids < 5: continue pad = .02 if va == "bottom": pad = -pad TextCircle(ax, xx, y + pad, si, radius=.01, fc="w", color=color, size=10, transform=tr) xp = min(self.xstart / 2, .1) if (self.xstart + self.xend) / 2 <= .5 \ else max(1 - self.end / 2, .92) label = markup(self.label) c = color if color != "gainsboro" else "k" if plot_label: ax.text(xp, y + self.height * .6, label, ha="center", color=c, transform=tr)
def draw(self, roundrect=False, plot_label=True, plot_circles=True, pad=.03, vpad=.09): if self.empty: return y = self.y color = self.color ax = self.ax xstart = self.xstart gap = self.gap va = self.va nseqids = len(self.seqids) tr = self.tr def make_circle_name(sid): sid = sid.rsplit("_", 1)[-1] si = "".join(x for x in sid if x in string.digits) si = str(int(si)) if sid in self.rev: si += '-' return si for i, sid in enumerate(self.seqids): size = self.sizes[sid] rsize = self.ratio * size xend = xstart + rsize hc = HorizontalChromosome(ax, xstart, xend, y, height=self.height, lw=self.lw, fc=color, roundrect=roundrect) hc.set_transform(tr) si = make_circle_name(sid) xx = (xstart + xend) / 2 xstart = xend + gap step = 2 if nseqids <= 40 else 10 if nseqids >= 2 * MaxSeqids and (i + 1) % step != 0: continue if nseqids < 5: continue hpad = -pad if va == "bottom" else pad if plot_circles: TextCircle(ax, xx, y + hpad, si, radius=.01, fc="w", color=color, size=10, transform=tr) label = markup(self.label) c = color if color != "gainsboro" else "k" if plot_label: if self.label_va == "top": x, y = self.x, self.y + vpad elif self.label_va == "bottom": x, y = self.x, self.y - vpad else: # "center" x, y = self.xstart - vpad, self.y ax.text(x, y, label, ha="center", va="center", color=c, transform=tr)
def draw(self, roundrect=False, plot_label=True): if self.empty: return y = self.y color = self.color ax = self.ax xstart = self.xstart gap = self.gap va = self.va nseqids = len(self.seqids) tr = self.tr for i, sid in enumerate(self.seqids): size = self.sizes[sid] rsize = self.ratio * size xend = xstart + rsize hc = HorizontalChromosome(ax, xstart, xend, y, height=self.height, lw=self.lw, fc=color, roundrect=roundrect) hc.set_transform(tr) sid = sid.rsplit("_", 1)[-1] si = "".join(x for x in sid if x not in string.letters) si = str(int(si)) xx = (xstart + xend) / 2 xstart = xend + gap if nseqids > 2 * MaxSeqids and (i + 1) % 10 != 0: continue if nseqids < 5: continue pad = .02 if va == "bottom": pad = - pad TextCircle(ax, xx, y + pad, si, radius=.01, fc="w", color=color, size=10, transform=tr) xp = min(self.xstart / 2, .1) if (self.xstart + self.xend) / 2 <= .5 \ else max(1 - self.xend / 2, .92) label = markup(self.label) c = color if color != "gainsboro" else "k" if plot_label: ax.text(xp, y + self.height * .6, label, ha="center", color=c, transform=tr)
def draw(self, roundrect=False, plot_label=True, pad=.03, vpad=.09): if self.empty: return y = self.y color = self.color ax = self.ax xstart = self.xstart gap = self.gap va = self.va nseqids = len(self.seqids) tr = self.tr for i, sid in enumerate(self.seqids): size = self.sizes[sid] rsize = self.ratio * size xend = xstart + rsize hc = HorizontalChromosome(ax, xstart, xend, y, height=self.height, lw=self.lw, fc=color, roundrect=roundrect) hc.set_transform(tr) sid = sid.rsplit("_", 1)[-1] si = "".join(x for x in sid if x in string.digits) si = str(int(si)) xx = (xstart + xend) / 2 xstart = xend + gap step = 2 if nseqids <= 40 else 10 if nseqids >= 2 * MaxSeqids and (i + 1) % step != 0: continue if nseqids < 5: continue hpad = -pad if va == "bottom" else pad TextCircle(ax, xx, y + hpad, si, radius=.01, fc="w", color=color, size=10, transform=tr) label = markup(self.label) c = color if color != "gainsboro" else "k" if plot_label: if self.label_va == "top": x, y = self.x, self.y + vpad va = "bottom" elif self.label_va == "bottom": x, y = self.x, self.y - vpad va = "top" else: # "center" x, y = self.xstart - vpad, self.y va = "center" ax.text(x, y, label, ha="center", va="center", color=c, transform=tr)
def draw(self, roundrect=False, plot_label=True, plot_circles=True, pad=0.03, vpad=0.09): if self.empty: return y = self.y color = self.color ax = self.ax xstart = self.xstart gap = self.gap va = self.va nseqids = len(self.seqids) tr = self.tr for i, sid in enumerate(self.seqids): size = self.sizes[sid] rsize = self.ratio * size xend = xstart + rsize hc = HorizontalChromosome( ax, xstart, xend, y, height=self.height, lw=self.lw, fc=color, roundrect=roundrect, ) hc.set_transform(tr) si = make_circle_name(sid, self.rev) xx = (xstart + xend) / 2 xstart = xend + gap step = 2 if nseqids <= 40 else 10 if nseqids >= 2 * MaxSeqids and (i + 1) % step != 0: continue if nseqids < 5: continue hpad = -pad if va == "bottom" else pad if plot_circles: TextCircle( ax, xx, y + hpad, si, fc="w", color=color, size=10, transform=tr, ) label = markup(self.label) c = color if color != "gainsboro" else "k" if plot_label: if self.label_va == "top": x, y = self.x, self.y + vpad elif self.label_va == "bottom": x, y = self.x, self.y - vpad else: # "center" x, y = self.xstart - vpad / 2, self.y ax.text(x, y, label, ha="center", va="center", color=c, transform=tr)