@@ -155,8 +155,13 @@ def spa_analyze( samples, output, signatures=None, signature_database=None,dec
155155 #################
156156
157157 if denovo_refit_option == True :
158-
159-
158+ try :
159+ processAvg = pd .read_csv (signatures ,sep = '\t ' , index_col = 0 )
160+ except :
161+ try :
162+ processAvg = signatures
163+ except :
164+ sys .exit ("Error in formatting of input signatures, Pass a text file of signatures in the format of denovo signatures" )
160165
161166 if devopts == None :
162167 listOfSignatures = processAvg .columns
@@ -169,8 +174,7 @@ def spa_analyze( samples, output, signatures=None, signature_database=None,dec
169174 genomes = genomes .set_index (index )
170175 genomes .columns = colnames
171176 #genomes = genomes.rename_axis("Mutation Types", axis="columns")
172- exposureAvg_dummy = pd .DataFrame (np .random .rand (processAvg .shape [1 ],genomes .shape [1 ]),index = listOfSignatures ,columns = colnames .to_list ()).transpose ().rename_axis ('Samples' )
173- exposureAvg = exposureAvg_dummy
177+
174178 #creating list of mutational type to sync with the vcf type input
175179 if mutation_type == "78" :
176180 mutation_context = "DBS78"
@@ -187,9 +191,12 @@ def spa_analyze( samples, output, signatures=None, signature_database=None,dec
187191 allsigids = list (listOfSignatures )
188192 processAvg = np .array (processAvg )
189193 signature_names = sub .make_letter_ids (idlenth = processAvg .shape [1 ], mtype = mutation_context )
190- exposureAvg . columns = signature_names
194+
191195 # create the folder for the final solution/ De Novo Solution
192196 #pdb.set_trace()
197+ exposureAvg_dummy = pd .DataFrame (np .random .rand (processAvg .shape [1 ],genomes .shape [1 ]),index = listOfSignatures ,columns = colnames .to_list ()).transpose ().rename_axis ('Samples' )
198+ exposureAvg = exposureAvg_dummy
199+ exposureAvg .columns = signature_names
193200
194201
195202
@@ -251,6 +258,14 @@ def spa_analyze( samples, output, signatures=None, signature_database=None,dec
251258 # Decomposition
252259 #################
253260 if decompose_fit_option == True :
261+ try :
262+ processAvg = pd .read_csv (signatures ,sep = '\t ' , index_col = 0 )
263+ except :
264+ try :
265+ processAvg = signatures
266+ except :
267+ sys .exit ("Error in formatting of input signatures, Pass a text file of signatures in the format of denovo signatures" )
268+
254269 if devopts == None :
255270 listOfSignatures = processAvg .columns
256271 index = genomes .index
@@ -262,8 +277,7 @@ def spa_analyze( samples, output, signatures=None, signature_database=None,dec
262277 genomes = genomes .set_index (index )
263278 genomes .columns = colnames
264279 #genomes = genomes.rename_axis("Mutation Types", axis="columns")
265- exposureAvg_dummy = pd .DataFrame (np .random .rand (processAvg .shape [1 ],genomes .shape [1 ]),index = listOfSignatures ,columns = colnames .to_list ()).transpose ().rename_axis ('Samples' )
266- exposureAvg = exposureAvg_dummy
280+
267281 #creating list of mutational type to sync with the vcf type input
268282 if mutation_type == "78" :
269283 mutation_context = "DBS78"
@@ -280,8 +294,12 @@ def spa_analyze( samples, output, signatures=None, signature_database=None,dec
280294 allsigids = list (listOfSignatures )
281295 processAvg = np .array (processAvg )
282296 signature_names = sub .make_letter_ids (idlenth = processAvg .shape [1 ], mtype = mutation_context )
297+
298+ exposureAvg_dummy = pd .DataFrame (np .random .rand (processAvg .shape [1 ],genomes .shape [1 ]),index = listOfSignatures ,columns = colnames .to_list ()).transpose ().rename_axis ('Samples' )
299+ exposureAvg = exposureAvg_dummy
283300 exposureAvg .columns = signature_names
284301
302+
285303 #############################
286304 #layer_directory2 = output+"/Decompose_Solution"
287305 if isinstance (processAvg , pd .DataFrame ):
0 commit comments