Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plot crash when there is 0 modified reads #224

Closed
matandro opened this issue Jun 13, 2022 · 3 comments · Fixed by #226
Closed

Plot crash when there is 0 modified reads #224

matandro opened this issue Jun 13, 2022 · 3 comments · Fixed by #226

Comments

@matandro
Copy link
Contributor

matandro commented Jun 13, 2022

Describe the bug
When a sample has 0 reads considered as modified the code crashes on plot generation. See log below (actual sequences and window replaced with ????? for reasons 😬 ):

CRISPResso version 2.2.6
[Command used]:
/opt/CRISPResso_env/bin/CRISPResso -n experimental_EXP22001693-F6 -a ????? -o /data/output --min_frequency_alleles_around_cut_to_plot 0.05 --max_rows_alleles_around_cut_to_plot 50 --needleman_wunsch_gap_extend -1 --fastq_r1 /data/input/EXP22001693-F6_S16_L001_R1_001.fastq.gz --fastq_r2 /data/input/EXP22001693-F6_S16_L001_R2_001.fastq.gz --max_paired_end_reads_overlap 500 -g ????? -gn S1 -w ????? -wc ????? --ignore_substitutions --coding_seq ?????


[Execution log]:
Estimating average read length...
Merging paired sequences with Flash...
Running FLASH command: flash "/data/input/EXP22001693-F6_S16_L001_R1_001.fastq.gz" "/data/input/EXP22001693-F6_S16_L001_R2_001.fastq.gz" --min-overlap 10 --max-overlap 500 --allow-outies -z -d /data/output/CRISPResso_on_experimental_EXP22001693-F6 -o out >>/data/output/CRISPResso_on_experimental_EXP22001693-F6/CRISPResso_RUNNING_LOG.txt 2>&1
[FLASH] Starting FLASH v1.2.11
[FLASH] Fast Length Adjustment of SHort reads
[FLASH]  
[FLASH] Input files:
[FLASH]     /data/input/EXP22001693-F6_S16_L001_R1_001.fastq.gz
[FLASH]     /data/input/EXP22001693-F6_S16_L001_R2_001.fastq.gz
[FLASH]  
[FLASH] Output files:
[FLASH]     /data/output/CRISPResso_on_experimental_EXP22001693-F6/out.extendedFrags.fastq.gz
[FLASH]     /data/output/CRISPResso_on_experimental_EXP22001693-F6/out.notCombined_1.fastq.gz
[FLASH]     /data/output/CRISPResso_on_experimental_EXP22001693-F6/out.notCombined_2.fastq.gz
[FLASH]     /data/output/CRISPResso_on_experimental_EXP22001693-F6/out.hist
[FLASH]     /data/output/CRISPResso_on_experimental_EXP22001693-F6/out.histogram
[FLASH]  
[FLASH] Parameters:
[FLASH]     Min overlap:           10
[FLASH]     Max overlap:           500
[FLASH]     Max mismatch density:  0.250000
[FLASH]     Allow "outie" pairs:   true
[FLASH]     Cap mismatch quals:    false
[FLASH]     Combiner threads:      8
[FLASH]     Input format:          FASTQ, phred_offset=33
[FLASH]     Output format:         FASTQ, phred_offset=33, gzip
[FLASH]  
[FLASH] Starting reader and writer threads
[FLASH] Starting 8 combiner threads
[FLASH] Processed 25000 read pairs
[FLASH] Processed 50000 read pairs
[FLASH] Processed 75000 read pairs
[FLASH] Processed 82763 read pairs
[FLASH]  
[FLASH] Read combination statistics:
[FLASH]     Total pairs:      82763
[FLASH]     Combined pairs:   67531
[FLASH]         Innie pairs:   67482 (99.93% of combined)
[FLASH]         Outie pairs:   49 (0.07% of combined)
[FLASH]     Uncombined pairs: 15232
[FLASH]     Percent combined: 81.60%
[FLASH]  
[FLASH] Writing histogram files.
[FLASH]  
[FLASH] FLASH v1.2.11 complete!
[FLASH] 4.377 seconds elapsed
Done!
Aligning sequences...
Processing reads; N_TOT_READS: 0 N_COMPUTED_ALN: 0 N_CACHED_ALN: 0 N_COMPUTED_NOTALN: 0 N_CACHED_NOTALN: 0
Processing reads; N_TOT_READS: 10000 N_COMPUTED_ALN: 3278 N_CACHED_ALN: 6702 N_COMPUTED_NOTALN: 20 N_CACHED_NOTALN: 0
Processing reads; N_TOT_READS: 20000 N_COMPUTED_ALN: 6072 N_CACHED_ALN: 13904 N_COMPUTED_NOTALN: 24 N_CACHED_NOTALN: 0
Processing reads; N_TOT_READS: 30000 N_COMPUTED_ALN: 8318 N_CACHED_ALN: 21652 N_COMPUTED_NOTALN: 30 N_CACHED_NOTALN: 0
Processing reads; N_TOT_READS: 40000 N_COMPUTED_ALN: 10838 N_CACHED_ALN: 29127 N_COMPUTED_NOTALN: 35 N_CACHED_NOTALN: 0
Processing reads; N_TOT_READS: 50000 N_COMPUTED_ALN: 12828 N_CACHED_ALN: 37128 N_COMPUTED_NOTALN: 44 N_CACHED_NOTALN: 0
Processing reads; N_TOT_READS: 60000 N_COMPUTED_ALN: 14851 N_CACHED_ALN: 45100 N_COMPUTED_NOTALN: 49 N_CACHED_NOTALN: 0
Finished reads; N_TOT_READS: 67531 N_COMPUTED_ALN: 16245 N_CACHED_ALN: 51230 N_COMPUTED_NOTALN: 56 N_CACHED_NOTALN: 0
Done!
Quantifying indels/substitutions...
Done!
Calculating allele frequencies...
Done!
Saving processed data...
Making Plots...
Unexpected error, please check your input.

ERROR: cannot convert float NaN to integer

Expected behavior
Should still show proper report...

To reproduce
See command above. It seems to be coding sequence specific. This doesn't fail on non CDS mode.

Debug output

/data/tools/CRISPResso2-2.2.7/.venv/lib/python3.8/site-packages/matplotlib/axes/_axes.py:3052: RuntimeWarning: invalid value encountered in true_divide
  x = x / sx
Traceback (most recent call last):
  File "/data/tools/CRISPResso2-2.2.7/CRISPResso2/CRISPRessoCORE.py", line 4226, in main
    CRISPRessoPlot.plot_global_frameshift_analysis(
  File "/data/tools/CRISPResso2-2.2.7/CRISPResso2/CRISPRessoPlot.py", line 1496, in plot_global_frameshift_analysis
    patches, texts, autotexts = ax.pie(
  File "/data/tools/CRISPResso2-2.2.7/.venv/lib/python3.8/site-packages/matplotlib/__init__.py", line 1412, in inner
    return func(ax, *map(sanitize_sequence, args), **kwargs)
  File "/data/tools/CRISPResso2-2.2.7/.venv/lib/python3.8/site-packages/matplotlib/axes/_axes.py", line 3094, in pie
    w = mpatches.Wedge((x, y), radius, 360. * min(theta1, theta2),
  File "/data/tools/CRISPResso2-2.2.7/.venv/lib/python3.8/site-packages/matplotlib/patches.py", line 1158, in __init__
    self._recompute_path()
  File "/data/tools/CRISPResso2-2.2.7/.venv/lib/python3.8/site-packages/matplotlib/patches.py", line 1170, in _recompute_path
    arc = Path.arc(theta1, theta2)
  File "/data/tools/CRISPResso2-2.2.7/.venv/lib/python3.8/site-packages/matplotlib/path.py", line 947, in arc
    n = int(2 ** np.ceil((eta2 - eta1) / halfpi))
ValueError: cannot convert float NaN to integer
CRITICAL @ Mon, 13 Jun 2022 16:47:01:
         Traceback (most recent call last):
  File "/data/tools/CRISPResso2-2.2.7/CRISPResso2/CRISPRessoCORE.py", line 4226, in main
    CRISPRessoPlot.plot_global_frameshift_analysis(
  File "/data/tools/CRISPResso2-2.2.7/CRISPResso2/CRISPRessoPlot.py", line 1496, in plot_global_frameshift_analysis
    patches, texts, autotexts = ax.pie(
  File "/data/tools/CRISPResso2-2.2.7/.venv/lib/python3.8/site-packages/matplotlib/__init__.py", line 1412, in inner
    return func(ax, *map(sanitize_sequence, args), **kwargs)
  File "/data/tools/CRISPResso2-2.2.7/.venv/lib/python3.8/site-packages/matplotlib/axes/_axes.py", line 3094, in pie
    w = mpatches.Wedge((x, y), radius, 360. * min(theta1, theta2),
  File "/data/tools/CRISPResso2-2.2.7/.venv/lib/python3.8/site-packages/matplotlib/patches.py", line 1158, in __init__
    self._recompute_path()
  File "/data/tools/CRISPResso2-2.2.7/.venv/lib/python3.8/site-packages/matplotlib/patches.py", line 1170, in _recompute_path
    arc = Path.arc(theta1, theta2)
  File "/data/tools/CRISPResso2-2.2.7/.venv/lib/python3.8/site-packages/matplotlib/path.py", line 947, in arc
    n = int(2 ** np.ceil((eta2 - eta1) / halfpi))
ValueError: cannot convert float NaN to integer
@Colelyman
Copy link
Contributor

Thanks @matandro for reporting the bug! And sorry that it occurred. I think I was able to reproduce the issue, and like you said I believe it comes up when all of the values for the pie chart are 0.

I have pushed a fix (and added a test case to try and replicate this) on this branch https://github.com/edilytics/CRISPResso2/tree/fix-empty-reads. Would you mind trying this branch to see if it fully fixes this issue?

@matandro
Copy link
Contributor Author

matandro commented Jun 16, 2022

Yep, the branch doesn't crash with this

Do you have a timeline on incorporating this patch into a release?

@Colelyman
Copy link
Contributor

Thanks again for reporting this @matandro. As for a release, we have some other bug fixes waiting in master, so it should be released soon.

@kclem do you think by the end of the month would be a good estimate for the next release?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants