def main(): matrixfile = sys.argv[1] g2sfile = sys.argv[2] outdir = sys.argv[3] # read in matrix: r2c2count = read_matrix(matrixfile) # group info: groups, g2s, matched = read_group_info(g2sfile) pair2count = get_pair2count(r2c2count) # get distribution (draw dist and get outliers) lowpoint, uppoint = get_dist(pair2count, g2s, outdir) # re draw group comparison boxplot with lims: group_cmp(pair2count, g2s, lowpoint, uppoint, outdir) # draw heatmap: s2g = lcommon.get_val2key_1to1(g2s) s2color = dcommon.get_name2color_wtgroup(s2g.keys(), s2g, g2s) heatmap_file = os.path.join(outdir, "heatmap.pdf") names = [] for g, gnames in g2s.iteritems(): for n in gnames: if n in r2c2count: names.append(n) draw_heatmap(r2c2count, s2color, lowpoint, uppoint, heatmap_file, names)
def samples_group_info(names, g2names, groups, matched): n2group = {} n2color = {} n2marker = {} if g2names: n2group = libcommon.get_val2key_1to1(g2names) n2color = drawcommon.get_name2color_wtgroup(names, n2group, g2names, groups, matched) n2marker = drawcommon.get_name2marker_wtgroup(names, g2names) return n2group, n2color, n2marker
def run(self): opts = self.opts sample2group = libcommon.get_val2key_1to1(opts.group2samples) global_dir = self.getGlobalTempDir() tc_dir = os.path.join(global_dir, "trackclone_%s" % os.path.basename(self.outdir.rstrip('/'))) system("mkdir -p %s" % tc_dir) for clone in self.clones: outfile = os.path.join(tc_dir, "%s.pickle" % clone) self.addChildTarget(TrackClone(clone, self.indir, outfile, opts, sample2group)) self.setFollowOnTarget(TrackClonesAgg(tc_dir, self.outdir, opts))