def work(name, params): cmp_dir = '%s/%s/upgma_cmp' % (params['out_dir'], name) tree = '%s/master_tree.tre' % cmp_dir support = '%s/color_support.txt' % cmp_dir get_support_file(params['group'], tree_file=tree, support_file=support) pdf = '%s/%s_cluster.pdf' % (params['out_dir'], name) png = '%s/%s_cluster.png' % (params['out_dir'], name) command = '%s -m %s -s %s -o %s' % (params['bootstrap_soft'], tree, support, pdf) os.system(command) image_trans(pdf, png) return command
def work(r_job, name, params): file = os.popen('ls %s/%s*.txt' % (params['beta_dir'], name)).read().strip() pdf_file = '%s/%s.heatmap.pdf' % (params['out_dir'], name) png_file = '%s/%s.heatmap.png' % (params['out_dir'], name) R_file = '%s/%s.heatmap.R' % (params['out_dir'], name) distance_name = name.replace('_', ' ').title() vars = {'for_plot': file, 'group_file': params['group_file'], 'pdf_file': pdf_file, 'distance_name': distance_name} r_job.format(vars) r_job.write(R_file) r_job.run() image_trans(pdf_file, png_file)
def work(r_job, name, params): file_name = os.popen('ls %s/%s*.txt' % (params['beta_dir'], name)).read().strip() file_pdf = '%s/%s.anosim.pdf' % (params['out_dir'], name) file_png = '%s/%s.anosim.png' % (params['out_dir'], name) file_R = '%s/%s.anosim.R' % (params['out_dir'], name) distance_name = name.replace('_', ' ').title() vars_in = {'distance_table': file_name, 'group_file': params['group_file'], 'pdf_file': file_pdf, 'distance_name': distance_name } r_job.format(vars_in) r_job.write(file_R) r_job.run() image_trans(file_pdf, file_png)
def plot_one_tree(newick_file, profile_dict, node_dict, params, prefix=''): t = Tree(newick_file, format=1) ts = get_tree_style() set_node_default(t, node_dict=node_dict) suf = '' if params['with_branch_circle']: add_node_circle(t, node_dict=node_dict) suf += '_circle' if params['with_leaf_pie'] and not params['with_branch_circle']: remove_node_circle(t, node_dict=node_dict) if params['with_leaf_pie']: add_pie_face(t, ts, profile_dict, group=params['group']) suf += '_pie' add_branch_text(t, tree_style=ts, node_dict=node_dict) set_node_style(t, node_dict=node_dict) if prefix: prefix += '_' pdf_file = '%s/%stax_tree%s.pdf' % (params['outdir'], prefix, suf) png_file = '%s/%stax_tree%s.png' % (params['outdir'], prefix, suf) t.render(pdf_file, tree_style=ts, dpi=100) image_trans(pdf_file, png_file)
search_name[value] = outlevel_name with open(outfile,"w") as fqout: for key,value in search_name.items(): fqout.write("%s\t%s\n" %(key.split("__")[1],value.split("__")[1])) mkdir(params['out_dir']) if params['for_plot'] is None: params['for_plot'] = params['out_dir'] + '/for_plot.txt' tax_profile_filter(params['otu_table'], params['for_plot'], params['level']) pdf_file = params['out_dir'] + '/heatmap.pdf' png_file = params['out_dir'] + '/heatmap.png' vars = {'row_group':outfile, 'heatmap_profile': params['for_plot'], 'pdf_file': pdf_file, 'group': params['group'], 'top': params['top'], 'dendrogram': params['dendrogram']} r_job = rp.Rparser() r_job.open(this_script_path + '/../src/template/03_tax_heatmap_twolegend.Rtp') r_job.format(vars) r_job.write(params['out_dir'] + '/heatmap.R') r_job.run() image_trans(pdf_file, png_file)
mkdir(params['upload_dir']) subject = mg.Subject(infile_list=params['infile_list'], upload_dir=params['upload_dir'], out_fasta_file=params['out_fasta_file'], out_stat_file=params['out_stat_file'], upload_stat=params['upload_stat'], required_data=params['required'], out_length_file=params['length_stat_file'], max_length=params['max_length'], min_length=params['min_length'], length_step=params['length_step'], name_table_file=params['name_table'], required_data_file=params['required_file'],) subject.read_name_table() subject.merge() subject.write_stat() subject.upload_stat() subject.write_length() # R works r_job = rp.Rparser() r_job.open(this_script_path + '/../src/template/00_sum_length.Rtp') vars = {'pdf_out': params['outdir'] + '/length_distrubution.pdf', 'length_stat': params['length_stat_file'], } r_job.format(vars) r_job.write(params['outdir'] + '/length_distrubution.R') r_job.run() image_trans(params['outdir'] + '/length_distrubution.pdf', params['outdir'] + '/length_distrubution.png')
help="set the work dir") parser.add_argument('-g', '--group', dest='group', metavar='FILE', type=str, required=True, help="set the group file") args = parser.parse_args() params = vars(args) return params if __name__ == '__main__': params = read_params(sys.argv) mkdir(params['outdir']) r_job = rp.Rparser() r_job.open(this_script_path + '/../src/template/05_diff_pca.Rtp') r_file = params['outdir'] + '/diff_pca.R' pdf_file = params['outdir'] + '/diff_pca.pdf' png_file = params['outdir'] + '/diff_pca.png' var = { 'input_file': params['infile'], 'group_file': params['group'], 'pdf_file': pdf_file } r_job.format(var) r_job.write(r_file) r_job.run() image_trans(pdf_file, png_file)
print "sample %s no in group" % samples[ind] return otu_in_group def write(otu_in_group, outfile): with open(outfile, 'w') as fp: for group, otus in otu_in_group.iteritems(): otus = sorted(list(otus), cmp=lambda a, b: cmp(int(a), int(b))) fp.write('%s\t%s\n' % (group, ' '.join(otus))) if __name__ == '__main__': params = read_params(sys.argv) mkdir(params['out_dir']) for_plot = params['out_dir'] + '/for_plot.txt' tiff_file = params['out_dir'] + '/venn.tiff' png_file = params['out_dir'] + '/venn.png' vars = {'for_plot': for_plot, 'tiff_file': tiff_file, 'group_file': params['group_dir']} otu_in_group = read(params['otu_table'], params['group'], vars) write(otu_in_group, for_plot) r_job = rp.Rparser() r_job.open(this_script_path + '/../src/template/03_otu_venn.Rtp') r_job.format(vars) r_job.write(params['out_dir'] + '/otu_venn.R') r_job.run() image_trans(tiff_file, png_file)