AlexandrovLab / SigProfilerExtractor

SigProfilerExtractor allows de novo extraction of mutational signatures from data generated in a matrix format. The tool identifies the number of operative mutational signatures, their activities in each sample, and the probability for each signature to cause a specific mutation type in a cancer sample. The tool makes use of SigProfilerMatrixGenerator and SigProfilerPlotting.
BSD 2-Clause "Simplified" License
154 stars 52 forks source link

[Errno 2] No such file or directory #214

Closed KANGseungseok closed 1 year ago

KANGseungseok commented 1 year ago

Hello, I am using sigprofilerExtractor version 1.1.21 and plotting version 1.3.14. I encountered the following error and would like to know the cause. Thank you.

KeyError                                  Traceback (most recent call last)
/opt/Yonsei/python/3.8.1/lib/python3.8/site-packages/sigProfilerPlotting/sigProfilerPlotting.py in plotSBS(matrix_path, output_path, project, plot_type, percentage, custom_text_upper, custom_text_middle, custom_text_bottom, savefig_format, volume)
   2640             buf = io.BytesIO()
-> 2641             fig_orig = make_pickle_file(
   2642                 context="SBS96", return_plot_template=True, volume=volume

/opt/Yonsei/python/3.8.1/lib/python3.8/site-packages/sigProfilerPlotting/sigProfilerPlotting.py in make_pickle_file(context, return_plot_template, volume)
    150     if os.path.exists(path):
--> 151         return pickle.load(open(path, "rb"))
    152 

/opt/Yonsei/python/3.8.1/lib/python3.8/site-packages/matplotlib/axes/_base.py in __setstate__(self, state)
    759         # Merge the grouping info back into the global groupers.
--> 760         shared_axes = state.pop("_shared_axes")
    761         for name, shared_siblings in shared_axes.items():

KeyError: '_shared_axes'

During handling of the above exception, another exception occurred:

FileNotFoundError                         Traceback (most recent call last)
<ipython-input-5-10c17304bfa3> in <module>
      1 input_data = '/data/project/Alzheimer/Main/00.Neurogenesis/04.analysis/01.SGZ_whole/01.SNV/Mutational_landscape/02.sigprofilerExtractor/vcf'
      2 output ='/data/project/Alzheimer/Main/00.Neurogenesis/04.analysis/01.SGZ_whole/01.SNV/Mutational_landscape/02.sigprofilerExtractor/result'
----> 3 sig.sigProfilerExtractor("vcf", output, input_data, reference_genome="GRCh38",
      4                          minimum_signatures=1, maximum_signatures=5, nmf_replicates=3, make_decomposition_plots=True)

/opt/Yonsei/python/3.8.1/lib/python3.8/site-packages/SigProfilerExtractor/sigpro.py in sigProfilerExtractor(input_type, output, input_data, reference_genome, opportunity_genome, cosmic_version, context_type, exome, minimum_signatures, maximum_signatures, nmf_replicates, resample, batch_size, cpu, gpu, nmf_init, precision, matrix_normalization, seeds, min_nmf_iterations, max_nmf_iterations, nmf_test_conv, nmf_tolerance, nnls_add_penalty, nnls_remove_penalty, initial_remove_penalty, collapse_to_SBS96, clustering_distance, export_probabilities, make_decomposition_plots, stability, min_stability, combined_stability, allow_stability_drop, get_all_signature_matrices)
    791 
    792             ################################# Export the results ###########################################################
--> 793             sub.export_information(loopResults, mutation_type, layer_directory, index, colnames, wall=wall, sequence=sequence)
    794             all_similirities_list.append(all_similarities)
    795             current_time_end = datetime.datetime.now()

/opt/Yonsei/python/3.8.1/lib/python3.8/site-packages/SigProfilerExtractor/subroutines.py in export_information(loopResults, mutation_type, output, index, colnames, sequence, wall)
   1108         if m.startswith("SBS"):
   1109             tmp_m = m[3:]
-> 1110         plot.plotSBS(signature_subdirectory+"/"+mutation_type+"_S"+str(i)+"_Signatures"+".txt", signature_subdirectory+"/Signature_plot", "S"+str(i), tmp_m, True, custom_text_upper=stability_list, custom_text_middle=total_mutation_list)
   1111     else:
   1112         custom_signatures_plot(processes, signature_subdirectory)

/opt/Yonsei/python/3.8.1/lib/python3.8/site-packages/sigProfilerPlotting/sigProfilerPlotting.py in plotSBS(matrix_path, output_path, project, plot_type, percentage, custom_text_upper, custom_text_middle, custom_text_bottom, savefig_format, volume)
   2919         except:
   2920             print("There may be an issue with the formatting of your matrix file.")
-> 2921             os.remove(os.path.join(output_path, "SBS_96_plots_" + project + ".pdf"))
   2922 
   2923     elif plot_type == "192" or plot_type == "96SB" or plot_type == "384":

FileNotFoundError: [Errno 2] No such file or directory: '/data/Mutational_landscape/02.sigprofilerExtractor/result/SBS96/All_Solutions/SBS96_1_Signatures/Signatures/Signature_plot/SBS_96_plots_S1.pdf'
mdbarnesUCSD commented 1 year ago

Hi @KANGseungseok,

I believe the issue occurs when the version of matplotlib to write and load the template file is different. To resolve the issue the templates need to be removed. You can find the templates here:

import sigProfilerPlotting as sigPlt
import os
template_path = os.path.join(os.path.dirname(sigPlt.__file__), "references/templates/")

Please let me know if this resolves your issue. Thanks!

KANGseungseok commented 1 year ago

Hi, @mdbarnesUCSD

Thank you very much for your help. The sigprofilerExtractor was successfully running. However, the template is recreated at the specified path. Do I need to delete it periodically? What is the role of this template?

mdbarnesUCSD commented 1 year ago

Hi @KANGseungseok,

The template is generated to speed up the plotting, since many plots are created during a run. A template contains a plot containing the x-axis labels and other plotting components that do not change. The issue occurs when the template is being loaded in. It seems this is because the version of matplotlib used to generate the plot template is different than the version of matplotlib that was used to load the template. It is necessary to remove the templates when the version of matplotlib changes in your environment.