best_cn = [a.split(',') for a in best_cn.split(':')] best_cn = np.array(best_cn).astype(int).T chrom_idx_filename = self.get_analysis_filename('chrom_idx.tsv') chrom_idx = pd.read_csv(chrom_idx_filename, sep='\t') count_data_filename = self.get_analysis_filename('counts.tsv') cn_data = pd.read_csv(count_data_filename, sep='\t', header=None, names=count_cols) cn_data = cn_data.merge(chrom_idx) cn_data['total_1'] = best_cn[0] cn_data['total_2'] = best_cn[1] cn_data = cn_data[[ 'chromosome', 'start', 'end', 'total_1', 'total_2', ]] cn_data.to_csv(output_cn_filename, sep='\t', index=False, header=True) if __name__ == '__main__': cmdline.interface(ThetaTool)
self.get_analysis_filename('h_table.tsv'), ) cn_data = pd.read_csv(self.get_analysis_filename('cn.tsv'), sep='\t', converters={'chromosome': str}) cn_data['total_1'] = cn_data['major_1'] + cn_data['minor_1'] cn_data['total_2'] = cn_data['major_2'] + cn_data['minor_2'] cn_columns = [ 'chromosome', 'start', 'end', 'major_1', 'minor_1', 'total_1', 'major_2', 'minor_2', 'total_2', ] cn_data = cn_data[cn_columns] cn_data.to_csv(output_cn_filename, sep='\t', index=False) if __name__ == '__main__': cmdline.interface(ReMixTTool)
'major': 'major_{0}'.format(clone_id), }) if cn_table is None: cn_table = data else: cn_table_prev = cn_table cn_table = remixt.segalg.reindex_segments(cn_table_prev, data) cn_table_prev.drop(['chromosome', 'start', 'end'], axis=1, inplace=True) data.drop(['chromosome', 'start', 'end'], axis=1, inplace=True) cn_table = cn_table.merge(cn_table_prev, left_on='idx_1', right_index=True) cn_table = cn_table.merge(data, left_on='idx_2', right_index=True) cn_table.drop(['idx_1', 'idx_2'], axis=1, inplace=True) cn_table.to_csv(output_cn_filename, sep='\t', index=False) if __name__ == '__main__': cmdline.interface(CloneHDTool)
cn_columns = { 'Chromosome': 'chromosome', 'Start_Position(bp)': 'start', 'End_Position(bp)': 'end', 'Copy_Number': 'total_1', 'MajorCN': 'major_1', 'MinorCN': 'minor_1', 'Clonal_Cluster': 'clone', } cn_data = cn_data.rename(columns=cn_columns)[cn_columns.values()] cn_data['clone'] = cn_data['clone'].fillna(1).astype(int) cn_data['total_2'] = np.where(cn_data['clone'] == 1, cn_data['total_1'], 2) cn_data['major_2'] = np.where(cn_data['clone'] == 1, cn_data['major_1'], 1) cn_data['minor_2'] = np.where(cn_data['clone'] == 1, cn_data['minor_1'], 1) cn_data = cn_data.drop(['clone'], axis=1) cn_data.to_csv(output_cn_filename, sep='\t', index=False) if __name__ == '__main__': cmdline.interface(TitanTool)