@@ -480,7 +480,7 @@ def signature_decomposition(signatures, mtype, directory, genome_build="GRCh37",
480480def make_final_solution (processAvg , allgenomes , allsigids , layer_directory , m , index , allcolnames , process_std_error = "none" , signature_stabilities = " " , \
481481 signature_total_mutations = " " , signature_stats = "none" , cosmic_sigs = False , attribution = 0 , denovo_exposureAvg = "none" , add_penalty = 0.05 , \
482482 remove_penalty = 0.01 , initial_remove_penalty = 0.05 , de_novo_fit_penalty = 0.02 , background_sigs = 0 , genome_build = "GRCh37" , sequence = "genome" , export_probabilities = True , export_probabilities_per_mutation = False , \
483- refit_denovo_signatures = True , collapse_to_SBS96 = True , connected_sigs = True , pcawg_rule = False , verbose = False ,make_plots = True , samples = './' , input_type = 'matrix' , denovo_refit_option = True ):
483+ refit_denovo_signatures = True , collapse_to_SBS96 = True , connected_sigs = True , pcawg_rule = False , verbose = False ,make_plots = True , samples = './' , input_type = 'matrix' , denovo_refit_option = True , exome = False ):
484484
485485 if processAvg .shape [0 ]== allgenomes .shape [0 ] and processAvg .shape [0 ] != 96 :
486486 collapse_to_SBS96 = False
@@ -794,7 +794,7 @@ def make_final_solution(processAvg, allgenomes, allsigids, layer_directory, m, i
794794 if export_probabilities == True :
795795 if input_type == 'vcf' :
796796 if m == '96' or m == '78' or m == '83' :
797- probability_per_mutation , samples_prob_per_mut = probabilities_per_mutation (probability , samples , m )
797+ probability_per_mutation , samples_prob_per_mut = probabilities_per_mutation (probability , samples , m , exome )
798798
799799 if denovo_refit_option == True :
800800 if refit_denovo_signatures == True :
@@ -941,7 +941,7 @@ def probabilities(W, H, index, allsigids, allcolnames):
941941
942942
943943################################################### Generation of probabilities for each processes given to A mutation ############################################
944- def probabilities_per_mutation (probability_matrix , samples_path , m ):
944+ def probabilities_per_mutation (probability_matrix , samples_path , m , exome = False ):
945945#
946946 probability_matrix = probability_matrix .reset_index ()
947947#
@@ -963,11 +963,15 @@ def probabilities_per_mutation(probability_matrix, samples_path, m):
963963#
964964 all_mutations = pd .DataFrame ()
965965 for file in seqinfo_files :
966- try :
967- new = pd .read_csv (seqinfo_path + file , sep = '\t ' ,header = None )
968- all_mutations = pd .concat ([all_mutations , new ])
969- except (pd .errors .EmptyDataError ):
970- pass
966+ if 'exome' in file :
967+ exome_df = pd .read_csv (seqinfo_path + file , sep = '\t ' ,header = None )
968+ else :
969+ try :
970+ new = pd .read_csv (seqinfo_path + file , sep = '\t ' ,header = None )
971+ all_mutations = pd .concat ([all_mutations , new ])
972+ except (pd .errors .EmptyDataError ):
973+ pass
974+
971975 all_mutations [3 ] = all_mutations [3 ].str [interval_low :interval_high ]
972976 if m == '96' or m == '78' :
973977 del all_mutations [4 ]
@@ -977,6 +981,14 @@ def probabilities_per_mutation(probability_matrix, samples_path, m):
977981 del all_mutations [4 ]
978982
979983 all_mutations .columns = ['Sample Names' , 'Chr' , 'Pos' , 'MutationType' ]
984+ if exome == True :
985+ del exome_df [2 ]
986+ del exome_df [3 ]
987+ del exome_df [4 ]
988+ exome_df .columns = ['Chr' , 'Pos' ]
989+ exome_df ['Chr' ] = [str (x ) for x in (exome_df ['Chr' ]).to_list ()]
990+ all_mutations ['Chr' ] = [str (x ) for x in (all_mutations ['Chr' ]).to_list ()]
991+ all_mutations = pd .merge (all_mutations , exome_df )
980992#
981993 all_samples_mutations = [y for x , y in all_mutations .groupby ('Sample Names' )]
982994#
0 commit comments