wdecoster / NanoPlot

Plotting scripts for long read sequencing data
http://nanoplot.bioinf.be
MIT License
419 stars 47 forks source link

NanoPlot not making figures: Error "matplotlib.cm' has no attribute 'cmap_d' #370

Closed cavery12 closed 3 months ago

cavery12 commented 3 months ago

I am running NanoPlot on a linux HPC enviroment, installed via conda. When I run the program, a log and txt file are produced but no pngs are created. The txt file has the statistics associated with my dataset and the log file contains the following:

2024-06-13 13:27:32,477 NanoPlot 1.30.1 started with arguments Namespace(threads=64, verbose=False, store=False, raw=False, huge=False, outdir='nanoplot/raw', prefix='Sample3_SUP_First200', maxlength=None, minlength=None, drop_outliers=False, downsample=None, loglength=False, percentqual=False, alength=False, minqual=None, runtime_until=None, readtype='1D', barcoded=False, no_supplementary=False, color='red', colormap='Greens', format='png', plots=['kde'], listcolors=False, listcolormaps=False, no_N50=False, N50=True, title=None, font_scale=1, dpi=300, hide_stats=False, fastq=['/p/work1/cavery12/metagenomics/data/GridION_Sample3/Sample3_SUP_First200.fastq.gz'], fasta=None, fastq_rich=None, fastq_minimal=None, summary=None, bam=None, ubam=None, cram=None, pickle=None, path='nanoplot/raw/Sample3_SUP_First200') 2024-06-13 13:27:32,478 Python version is: 3.10.14 | packaged by conda-forge | (main, Mar 20 2024, 12:45:18) [GCC 12.3.0] 2024-06-13 13:27:32,535 NanoPlot: valid output format png 2024-06-13 13:27:32,601 Nanoget: Starting to collect statistics from plain fastq file. 2024-06-13 13:27:32,606 Nanoget: Decompressing gzipped fastq /p/work1/cavery12/metagenomics/data/GridION_Sample3/Sample3_SUP_First200.fastq.gz 2024-06-13 13:28:51,893 Reduced DataFrame memory usage from 13.148941040039062Mb to 13.148941040039062Mb 2024-06-13 13:28:51,943 Nanoget: Gathered all metrics of 861721 reads 2024-06-13 13:28:52,346 Calculated statistics 2024-06-13 13:28:52,347 Using sequenced read lengths for plotting. 2024-06-13 13:28:52,412 NanoPlot: Valid color red. 2024-06-13 13:28:52,412 module 'matplotlib.cm' has no attribute 'cmap_d' Traceback (most recent call last): File "/p/home/cavery12/.conda/envs/ont-meta/lib/python3.10/site-packages/nanoplot/NanoPlot.py", line 97, in main plots = make_plots(datadf, settings) File "/p/home/cavery12/.conda/envs/ont-meta/lib/python3.10/site-packages/nanoplot/NanoPlot.py", line 134, in make_plots colormap = nanoplotter.check_valid_colormap(settings["colormap"]) File "/p/home/cavery12/.conda/envs/ont-meta/lib/python3.10/site-packages/nanoplotter/nanoplotter_main.py", line 65, in check_valid_colormap if colormap in list(cm.cmap_d.keys()): AttributeError: module 'matplotlib.cm' has no attribute 'cmap_d'

This error looks like its stemming from matplotlib. My NanoPlot version is 1.30.1 and matplotlib version is 3.8.4

Any help/fixes for this?

wdecoster commented 3 months ago

Hi,

Would it be hard for you to try to update your NanoPlot installation? Maybe the issue is already solved :)

Wouter

cavery12 commented 3 months ago

I tried to update as far as I could with the rest of my environment (using some older code). I also tried updating matplotlib.

I did a bit more digging and did find a work-around. In the file nanoplotter_main.py, I edited line 65 from "if colormap in list(cm.cmap_d.keys()):" to "if colormap in plt.colormaps():" and now pngs are generating.

wdecoster commented 3 months ago

Oh, that is wonderful :) thanks for sharing your solution.