def open(self): make_directory(self.trace_dir) self.alpha_writer = ConcentrationParameterWriter(self.trace_dir) self.labels_writer = LabelsWriter(self.trace_dir, self.mutation_ids) self.cellular_frequency_writers = {} for sample_id in self.sample_ids: self.cellular_frequency_writers[sample_id] = CellularFrequenciesWriter(self.trace_dir, sample_id, self.mutation_ids) if self.update_precision: self.precision_writer = PrecisionWriter(self.trace_dir)
def open(self): make_directory(self.trace_dir) self.alpha_writer = ConcentrationParameterWriter(self.trace_dir) self.labels_writer = LabelsWriter(self.trace_dir, self.mutation_ids) self.cellular_frequency_writers = {} for sample_id in self.sample_ids: self.cellular_frequency_writers[ sample_id] = CellularFrequenciesWriter(self.trace_dir, sample_id, self.mutation_ids) if self.update_precision: self.precision_writer = PrecisionWriter(self.trace_dir)
def _setup_analysis(config_extras_file, density, in_files, init_method, num_iters, samples, prior, tumour_contents, working_dir): make_directory(working_dir) make_directory(os.path.join(working_dir, 'yaml')) mutations_files = OrderedDict() _tumour_contents = {} for i, in_file in enumerate(in_files): if samples is not None: sample_id = samples[i] else: sample_id = os.path.splitext(os.path.basename(in_file))[0] mutations_files[sample_id] = os.path.join(working_dir, 'yaml', '{0}.yaml'.format(sample_id)) _build_mutations_file(in_file, mutations_files[sample_id], prior) if tumour_contents is not None: _tumour_contents[sample_id] = tumour_contents[i] else: _tumour_contents[sample_id] = 1.0 config_file = os.path.join(working_dir, 'config.yaml') _write_config_file( config_file=config_file, density=density, init_method=init_method, mutations_files=mutations_files, num_iters=num_iters, tumour_contents=_tumour_contents, working_dir=working_dir, config_extras_file=config_extras_file, ) return config_file
def open(self): make_directory(paths.get_trace_dir(self.config_file)) self.alpha_writer = ConcentrationParameterWriter(paths.get_concentration_trace_file(self.config_file)) self.labels_writer = LabelsWriter( paths.get_labels_trace_file(self.config_file), self.mutation_ids ) self.cellular_frequency_writers = {} for sample_id, file_name in paths.get_cellular_prevalence_trace_files(self.config_file).items(): self.cellular_frequency_writers[sample_id] = CellularFrequenciesWriter( file_name, self.mutation_ids, sample_id ) if self.update_precision: self.precision_writer = PrecisionWriter(paths.get_precision_trace_file(self.config_file))
def run_analysis_pipeline(args): config_file = _setup_analysis( density=args.density, in_files=args.in_files, init_method=args.init_method, num_iters=args.num_iters, samples=args.samples, prior=args.prior, tumour_contents=args.tumour_contents, working_dir=args.working_dir, config_extras_file=args.config_extras_file, ) _run_analysis(config_file, args.seed) tables_dir = os.path.join(args.working_dir, 'tables') make_directory(tables_dir) for table_type in ['cluster', 'loci']: out_file = os.path.join(tables_dir, '{0}.tsv'.format(table_type)) _build_table(config_file=config_file, out_file=out_file, burnin=args.burnin, max_clusters=args.max_clusters, mesh_size=args.mesh_size, table_type=table_type, thin=args.thin) plots_dir = os.path.join(args.working_dir, 'plots') plots = [('cluster', 'density'), ('cluster', 'parallel_coordinates'), ('cluster', 'scatter'), ('loci', 'density'), ('loci', 'parallel_coordinates'), ('loci', 'scatter'), ('loci', 'similarity_matrix'), ('loci', 'vaf_parallel_coordinates'), ('loci', 'vaf_scatter')] for category, plot_type in plots: plot_file = os.path.join( plots_dir, category, '{0}.{1}'.format(plot_type, args.plot_file_format)) make_parent_directory(plot_file) if category == 'cluster': _cluster_plot(config_file, plot_file, args.burnin, args.max_clusters, args.mesh_size, args.min_cluster_size, plot_type, args.samples, args.thin) elif category == 'loci': _loci_plot(config_file, plot_file, plot_type, burnin=args.burnin, min_cluster_size=args.min_cluster_size, samples=args.samples, thin=args.thin)