AlexandrovLab / SigProfilerAssignment

Assignment of known mutational signatures to individual samples and individual somatic mutations
BSD 2-Clause "Simplified" License
46 stars 10 forks source link

export_probabilities_per_mutation=True doesn't work with exome=True #98

Closed ImNotaGit closed 11 months ago

ImNotaGit commented 12 months ago

The issue is literally as described in the title: export_probabilities_per_mutation=True leads to an error with exome=True. However, it works when exome=False.

An example run is as follows:

from SigProfilerAssignment import Analyzer as Analyze
Analyze.cosmic_fit(samples="input", output="output", genome_build="GRCh37", input_type="vcf", context_type="96", collapse_to_SBS96=True, cosmic_version=2, exome=True, exclude_signature_subgroups=None, export_probabilities_per_mutation=True)

The error message is as follows:

Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File ".../SigProfiler/lib/python3.11/site-packages/SigProfilerAssignment/Analyzer.py", line 11, in cosmic_fit
    decomp.spa_analyze(samples=samples,  output=output, signatures=signatures, signature_database=signature_database,nnls_add_penalty=nnls_add_penalty, nnls_remove_penalty=nnls_remove_penalty, initial_remove_penalty=initial_remove_penalty,genome_build=genome_build, cosmic_version=cosmic_version, make_plots=make_plots, collapse_to_SBS96=collapse_to_SBS96,connected_sigs=connected_sigs, verbose=verbose,decompose_fit_option= False,denovo_refit_option=False,cosmic_fit_option=True,devopts=devopts,exclude_signature_subgroups=exclude_signature_subgroups,exome=exome,input_type=input_type,context_type=context_type,export_probabilities=export_probabilities, export_probabilities_per_mutation=export_probabilities_per_mutation, sample_reconstruction_plots=sample_reconstruction_plots)
  File ".../SigProfiler/lib/python3.11/site-packages/SigProfilerAssignment/decomposition.py", line 642, in spa_analyze
    sub.make_final_solution(processAvg, genomes, allsigids, layer_directory3, mutation_type, index, colnames,
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../SigProfiler/lib/python3.11/site-packages/SigProfilerAssignment/decompose_subroutines.py", line 798, in make_final_solution
    probability_per_mutation, samples_prob_per_mut = probabilities_per_mutation(probability, samples, m)
                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../SigProfiler/lib/python3.11/site-packages/SigProfilerAssignment/decompose_subroutines.py", line 989, in probabilities_per_mutation
    sample_names.append(new['Sample Names'][0])
                        ~~~~~~~~~~~~~~~~~~~^^^
  File ".../SigProfiler/lib/python3.11/site-packages/pandas/core/series.py", line 978, in __getitem__
    return self._values[key]
           ~~~~~~~~~~~~^^^^^
IndexError: index 0 is out of bounds for axis 0 with size 0
Tina04021997 commented 11 months ago

Hi @ImNotaGit, thank you for reaching out! Would you mind sharing your input data so that we can try to reproduce the issue and figure out where might go wrong? We've tested on the sample vcf input with the same parameters and the error didn't show up. Thank you.

ImNotaGit commented 11 months ago

Would you mind sharing your input data so that we can try to reproduce the issue and figure out where might go wrong?

Thanks a lot for your reply! I may not be allowed to share the particular input I used above but let me see if I can reproduce the error with another input that can share. How should I send you the data?

Tina04021997 commented 11 months ago

Thanks for your reply, @ImNotaGit ! Please send your file to tiy002@ucsd.edu Thank you.

Tina04021997 commented 11 months ago

Dear @ImNotaGit, thank you again for reaching out, once you have your input file sent to us, we can communicate via email! I will close this ticket at the time.

ImNotaGit commented 11 months ago

Thanks to the kind help from @Tina04021997 the issue is now resolved by updating SigProfilerAssignment to 0.0.32.

Just for informational purposes, below are the software versions where the error occurred:

Python Version: 3.11.0
SigProfilerPlotting Version: 1.3.10
SigProfilerMatrixGenerator Version: 1.2.13
SigProfilerAssignment Version: 0.0.24
Pandas version: 1.5.2
Numpy version: 1.24.1

And now I have these (and there is no error):

Python Version: 3.11.0
SigProfilerPlotting Version: 1.3.17
SigProfilerMatrixGenerator Version: 1.2.19
SigProfilerAssignment Version: 0.0.32
Pandas version: 1.5.2
Numpy version: 1.24.1