def save_gem_class_json(self, base_dir): json_file_path = MultiGenomeAnalysis.json_path(base_dir) cr_utils.makedirs(os.path.dirname(json_file_path), allow_existing=True) with open(json_file_path, 'w') as f: json.dump(tk_safe_json.json_sanitize(self.result), f, indent=4, sort_keys=True)
def main(args, outs): if args.skip or args.is_multi_genome: return cr_io.combine_h5_files([args.kmeans_h5, args.graphclust_h5], outs.clustering_h5, [cr_constants.ANALYSIS_H5_KMEANS_GROUP, cr_constants.ANALYSIS_H5_CLUSTERING_GROUP]) csv_path = os.path.join(outs.clustering_csv) cr_utils.makedirs(csv_path, allow_existing=True) copy_subdirs(args.kmeans_csv, csv_path) copy_subdirs(args.graphclust_csv, csv_path)
def save_gem_class_csv(self, base_dir): csv_file_path = os.path.join(base_dir, 'gem_classification.csv') cr_utils.makedirs(os.path.dirname(csv_file_path), allow_existing=True) with open(csv_file_path, 'wb') as f: writer = csv.writer(f) writer.writerow([ 'barcode', self.result['genome0'], self.result['genome1'], 'call' ]) for i in xrange(len(self.result['barcode'])): call = self.result['call'][i] call = call.replace(cr_constants.GEM_CLASS_GENOME0, self.result['genome0']) call = call.replace(cr_constants.GEM_CLASS_GENOME1, self.result['genome1']) writer.writerow([ self.result['barcode'][i], self.result['count0'][i], self.result['count1'][i], call, ])
def main(args, outs): if args.skip: return if args.is_multi_genome: cr_utils.copytree(args.multi_genome_json, outs.analysis) cr_utils.copytree(args.multi_genome_csv, outs.analysis_csv) return analysis_h5 = cr_io.h5_path(outs.analysis) cr_utils.makedirs(os.path.dirname(analysis_h5), allow_existing=True) with tables.open_file(args.matrix_h5, 'r') as matrix,\ tables.open_file(args.pca_h5, 'r') as pca,\ tables.open_file(args.clustering_h5, 'r') as clustering,\ tables.open_file(args.diffexp_h5, 'r') as diffexp,\ tables.open_file(args.tsne_h5, 'r') as tsne,\ tables.open_file(analysis_h5, 'w') as out: # NOTE - genome name is replaced with 'matrix' mat_groups = [m for m in matrix.root] matrix.copy_node(mat_groups[0], out.root, recursive=True, newname='matrix') pca.copy_children(pca.root, out.root, recursive=True) clustering.copy_children(clustering.root, out.root, recursive=True) diffexp.copy_children(diffexp.root, out.root, recursive=True) tsne.copy_children(tsne.root, out.root, recursive=True) pca_dir = os.path.join(outs.analysis_csv, 'pca') cr_utils.copytree(args.pca_csv, pca_dir) clustering_dir = os.path.join(outs.analysis_csv, 'clustering') cr_utils.copytree(args.clustering_csv, clustering_dir) diffexp_dir = os.path.join(outs.analysis_csv, 'diffexp') cr_utils.copytree(args.diffexp_csv, diffexp_dir) tsne_dir = os.path.join(outs.analysis_csv, 'tsne') cr_utils.copytree(args.tsne_csv, tsne_dir)