marbl / canu

A single molecule sequence assembler for genomes large and small.
http://canu.readthedocs.io/
649 stars 178 forks source link

Fail at unitigging consensus step (core dump) #1142

Closed oneillkza closed 5 years ago

oneillkza commented 5 years ago

Hi

I got a core dump at the consensus stage of unitigging. I'm running Canu from within Conda, on a single large (144 CPU / 1.5TB RAM) machine running CentOS6.7.

I'm also kinda doing a hacky thing trying to combine a low-coverage nanopore set with some contigs generated from high-coverage 10X Chromium data (but pretending that the contigs are corrected nanopore reads). I realise this is beyond the design parameters of Canu, but still thought you might want to try and find/catch the bug.

Only the first job in the consensus stage seems to have failed, so I've included the output of that log file.

Canu command:

canu -p Marmota_flaviventris \
    -d /projects/koneill_scratch/marmot_minion/marmot_assembly_chromium \
    genomeSize=3000m \
    stopOnLowCoverage=1 \
    -nanopore-corrected \
    /projects/koneill_scratch/marmot_minion/marmot_assembly/Marmota_flaviventris.correctedReads.fasta.gz \
    -nanopore-corrected \
    /projects/koneill_scratch/marmot_minion/ybm.fa 

Conda environment:

name: canu
channels:
  - bioconda
  - conda-forge
  - defaults
dependencies:
  - bandage=0.8.1=hb59a952_0
  - canu=1.8=pl526h470a237_0
  - perl-filesys-df=0.92=pl526h470a237_2
  - sambamba=0.6.8=h682856c_0
  - bzip2=1.0.6=h470a237_2
  - ca-certificates=2018.10.15=ha4d7672_0
  - cairo=1.14.10=0
  - dbus=1.13.0=h3a4f0e9_0
  - expat=2.2.5=hfc679d8_2
  - fontconfig=2.12.6=0
  - freetype=2.8.1=hfa320df_1
  - gettext=0.19.8.1=h5e8e0c9_1
  - giflib=5.1.4=h470a237_1
  - glib=2.55.0=h464dc38_2
  - gnuplot=5.2.3=0
  - graphite2=1.3.12=hfc679d8_1
  - gst-plugins-base=1.12.5=hde13a9d_0
  - gstreamer=1.12.5=h61a6719_0
  - harfbuzz=1.7.6=0
  - icu=58.2=hfc679d8_0
  - jpeg=9c=h470a237_1
  - ldc=1.9.0=h93ae710_0
  - libffi=3.2.1=hfc679d8_5
  - libgcc-ng=7.2.0=hdf63c60_3
  - libgd=2.2.5=3
  - libiconv=1.15=h470a237_3
  - libpng=1.6.34=ha92aebf_2
  - libstdcxx-ng=7.2.0=hdf63c60_3
  - libtiff=4.0.9=he6b73bb_2
  - libwebp=0.5.2=7
  - libxcb=1.13=h470a237_2
  - libxml2=2.9.8=h422b904_5
  - ncurses=5.9=10
  - openssl=1.0.2p=h470a237_1
  - pango=1.40.14=0
  - pcre=8.41=hfc679d8_3
  - perl=5.26.2=h470a237_0
  - pixman=0.34.0=h470a237_3
  - pthread-stubs=0.4=h470a237_1
  - qt=5.6.2=7
  - readline=7.0=0
  - sqlite=3.20.1=2
  - xorg-libxau=1.0.8=h470a237_6
  - xorg-libxdmcp=1.1.2=h470a237_7
  - xz=5.2.4=h470a237_1
  - zlib=1.2.11=h470a237_3
  - openjdk=8.0.152=h46b5887_1

marmot_assembly_chromium/unitigging/5-consensus/consensus.000001.out

$ cat consensus.000001.out 

Found perl:
   /projects/karsanlab/Kieran/miniconda3/envs/canu/bin/perl
   This is perl 5, version 26, subversion 2 (v5.26.2) built for x86_64-linux-thread-multi

Found java:
   /projects/karsanlab/Kieran/miniconda3/envs/canu/bin/java
   openjdk version "1.8.0_152-release"

Found canu:
   /projects/karsanlab/Kieran/miniconda3/envs/canu/libexec/bin/canu
   Canu snapshot (snapshot)

Running job 1 based on command line options.
-- Opening seqStore '../Marmota_flaviventris.ctgStore/partitionedReads.seqStore' partition 1.
-- Opening tigStore '../Marmota_flaviventris.ctgStore' version 1.
-- Opening output results file './ctgcns/0001.cns.WORKING'.
--
-- Computing consensus for b=0 to e=315187 with errorRate 0.2000 (max 0.4000) and minimum overlap 40
--
utgcns: overlapInCore/libedlib/edlib.C:163: EdlibAlignResult edlibAlign(const char*, int, const char*, int, EdlibAlignConfig): Assertion `queryLength > 0' failed.
                           ----------CONTAINED READS----------  -DOVETAIL  READS-
  tigID    length   reads      used coverage  ignored coverage      used coverage
------- --------- -------  -------- -------- -------- --------  -------- --------
      2     45879      16        15    3.12x        0    0.00x         1    1.00x
      4    554619    1222      1164   25.37x        0    0.00x        58    4.28x
      5     70054     189       186   21.22x        0    0.00x         3    1.69x
      8    254466     167       140    6.16x        0    0.00x        27    3.49x
     14    563028     198       164    3.29x        0    0.00x        34    2.43x
     17     64688      17        14    1.90x        0    0.00x         3    1.61x
     21    337618     238       208    7.13x        0    0.00x        30    3.21x
     25     57342      14        12    1.89x        0    0.00x         2    1.07x
     29     33282       5         3    0.57x        0    0.00x         2    1.50x
     41     53068      24        21    2.59x        0    0.00x         3    2.04x
     44     93507      63        53    5.57x        0    0.00x        10    2.94x
     47     56342      78        71   13.06x        0    0.00x         7    3.77x
     48     65702      21        18    2.14x        0    0.00x         3    1.32x
     54     78541      35        31    2.47x        0    0.00x         4    1.61x
     55     78539      98        92   12.45x        0    0.00x         6    3.08x
     64    205728     142       120    6.36x        0    0.00x        22    3.79x
     70     67374      23        18    1.89x        0    0.00x         5    2.22x
     72     70165      18        14    1.83x        0    0.00x         4    1.88x
     89    228629      92        73    3.24x        0    0.00x        19    2.74x
     90     91915      19        12    2.49x        0    0.00x         7    2.06x
    103     43733      29        25    4.68x        0    0.00x         4    2.72x
    107     56477      40        34    4.51x        0    0.00x         6    2.39x
    110     30618       4         2    0.42x        0    0.00x         2    1.49x
    112    296919     225       193    6.79x        0    0.00x        32    3.88x
    113     40628       9         6    0.89x        0    0.00x         3    1.78x
    118    293110     152       121    4.44x        0    0.00x        31    3.34x
    121     68639      47        41    4.89x        0    0.00x         6    2.58x
    123    222612     266       245   12.39x        0    0.00x        21    3.85x
    124    179269     111       101    3.68x        0    0.00x        10    1.91x
    127     37571      36        32    5.93x        0    0.00x         4    2.35x
    128    217261     129       104    3.90x        0    0.00x        25    3.56x
    131     58177      28        25    2.81x        0    0.00x         3    1.98x
    138     80929     233       228   19.22x        0    0.00x         5    1.88x
    140     26200      51        49    9.14x        0    0.00x         2    1.83x
    141     62483      52        46    5.11x        0    0.00x         6    2.91x
    142     92265      35        30    3.53x        0    0.00x         5    1.94x
    143    331843      75        59    2.12x        0    0.00x        16    1.89x
    147     34741       3         1    0.03x        0    0.00x         2    1.50x
    148     38049       7         5    1.25x        0    0.00x         2    1.78x
    150     53527       9         6    0.89x        0    0.00x         3    1.81x
    153     31430       3         1    0.36x        0    0.00x         2    1.66x
    166    164481     183       169    7.90x        0    0.00x        14    3.08x
    182    159624     114       113    4.62x        0    0.00x         1    1.00x
    189     44339      40        36    2.82x        0    0.00x         4    1.82x
    198    157284     152       144    4.93x        0    0.00x         8    1.48x
    202     56775      20        14    1.39x        0    0.00x         6    1.96x
    208     87619     128       125    4.50x        0    0.00x         3    1.08x
    222     59457      29        26    1.38x        0    0.00x         3    1.61x
    225    102850      59        55    4.48x        0    0.00x         4    1.53x
    226     26478      11         9    0.94x        0    0.00x         2    1.78x
    229    283641      66        44    1.85x        0    0.00x        22    2.51x
    231     87160      49        40    3.23x        0    0.00x         9    2.70x
    241     99274      18        12    1.49x        0    0.00x         6    2.16x
    257    107599      16        10    1.37x        0    0.00x         6    1.79x
    260     93438      87        82    6.24x        0    0.00x         5    2.23x
    261    105463      23        14    1.30x        0    0.00x         9    2.60x
    263    185315      45        25    1.39x        0    0.00x        20    2.84x
    265    278067      95        73    3.09x        0    0.00x        22    2.65x
    266     65373      34        30    6.19x        0    0.00x         4    2.38x
    271    223180      52        32    1.48x        0    0.00x        20    2.70x
    277     24122      10         8    0.85x        0    0.00x         2    1.73x
    278     34391       6         4    1.13x        0    0.00x         2    1.54x
    282    317582     171       151    4.14x        0    0.00x        20    2.17x
    288     56827      11         7    2.08x        0    0.00x         4    2.30x
    292    222902      45        27    1.22x        0    0.00x        18    2.39x
    293     73780     118       111    9.16x        0    0.00x         7    2.66x
    302     63568       8         4    0.79x        0    0.00x         4    1.68x
    303     73572       9         5    0.30x        0    0.00x         4    1.71x
    305     63567      17        11    1.43x        0    0.00x         6    2.10x
    308    201733     118       100    5.42x        0    0.00x        18    3.48x
    312    256692     131       110    4.58x        0    0.00x        21    3.02x
    314     84504      19        16    1.22x        0    0.00x         3    1.73x
    315    298490     162       143    2.84x        0    0.00x        19    1.96x
    316     52519      21        17    1.77x        0    0.00x         4    2.41x
    320     58953      16        10    1.29x        0    0.00x         6    2.96x
    327     43686       9         7    1.70x        0    0.00x         2    1.62x
    338    166303      91        73    3.22x        0    0.00x        18    2.83x
    344     22337      71        69    8.56x        0    0.00x         2    1.03x
    345     61561      48        45    6.19x        0    0.00x         3    1.47x
    346     45673       3         1    0.11x        0    0.00x         2    1.36x
    356    220758      39        22    1.22x        0    0.00x        17    2.46x
    360    265337      80        60    2.54x        0    0.00x        20    2.45x
    364     52988      11         7    2.00x        0    0.00x         4    2.52x
    368     60119       5         2    0.33x        0    0.00x         3    1.84x
    379     19763       4         2    0.15x        0    0.00x         2    1.30x
    384    127098      32        17    2.20x        0    0.00x        15    3.18x
    388     30426      65        62   10.66x        0    0.00x         3    2.84x
    398     34454      15        13    1.97x        0    0.00x         2    1.53x
    405    145693      24         8    0.32x        0    0.00x        16    2.87x
    406    218878      45        29    1.69x        0    0.00x        16    2.25x
    409    215052      42        26    1.24x        0    0.00x        16    2.56x
    412    226711     123       105    4.78x        0    0.00x        18    2.68x
    414    257276      45        30    1.48x        0    0.00x        15    1.80x
    415    180801      36        20    1.53x        0    0.00x        16    2.77x
    417    157192      67        51    3.02x        0    0.00x        16    2.93x
    420     47171      28        25    2.88x        0    0.00x         3    1.88x
    428     60116      40        37    5.02x        0    0.00x         3    1.77x
    441     90267     106       103    3.91x        0    0.00x         3    1.40x
    449    354616     107        90    4.33x        0    0.00x        17    1.89x
    451    249098      53        38    1.76x        0    0.00x        15    2.42x
    452    196176      58        42    1.66x        0    0.00x        16    2.31x
    456     83650      38        30    3.86x        0    0.00x         8    2.74x
    459    119842     128       115    4.46x        0    0.00x        13    1.79x
    464    219312      40        25    1.34x        0    0.00x        15    2.20x
    465    197730      36        21    1.25x        0    0.00x        15    2.19x
    470    369151      84        69    2.54x        0    0.00x        15    1.79x
    472     77967     121       111    7.74x        0    0.00x        10    3.93x
    473    171091      36        20    1.67x        0    0.00x        16    2.69x
    474    247668      44        28    1.43x        0    0.00x        16    2.33x
    475    169060      41        25    1.05x        0    0.00x        16    2.37x
    477    214328      31        17    1.02x        0    0.00x        14    2.38x
    482    122943     160       144    8.51x        0    0.00x        16    3.20x
    483     80064      13         9    0.71x        0    0.00x         4    1.45x
    484     41238       6         3    0.99x        0    0.00x         3    2.35x
    488    135721      26        22    1.71x        0    0.00x         4    1.39x
    492     41786       7         4    0.37x        0    0.00x         3    1.92x
    495    107660      27        21    2.50x        0    0.00x         6    1.90x
    497    102002      30        22    1.71x        0    0.00x         8    2.31x
    500     26884       4         2    0.68x        0    0.00x         2    1.22x
    508     96973      32        26    3.83x        0    0.00x         6    2.55x
    511     75167     193       184   10.68x        0    0.00x         9    2.94x
    515     97618      46        32    3.69x        0    0.00x        14    3.68x
    516     28734       3         1    0.19x        0    0.00x         2    1.43x
    518    137543      28        14    0.80x        0    0.00x        14    2.75x
    519     66168      23        18    2.00x        0    0.00x         5    2.11x
    520    160518      27        13    1.15x        0    0.00x        14    2.71x
    522    155003      26        12    0.66x        0    0.00x        14    2.98x
    524    240899      37        21    1.17x        0    0.00x        16    2.38x
    525    192570      39        25    1.28x        0    0.00x        14    2.09x
    528    150499      39        25    1.87x        0    0.00x        14    2.91x
    532    164254      32        18    1.14x        0    0.00x        14    2.38x
    533     65439      23        19    0.94x        0    0.00x         4    1.67x
    536    259156      61        49    2.79x        0    0.00x        12    2.26x
    538    163367      34        19    1.29x        0    0.00x        15    2.43x
    541     33040       9         6    1.54x        0    0.00x         3    1.90x
    542     44535      12         7    1.05x        0    0.00x         5    1.77x
    545     59361      24        21    2.34x        0    0.00x         3    1.66x
    548    150716      28        14    0.78x        0    0.00x        14    2.03x
    555    177803      27        13    0.62x        0    0.00x        14    2.09x
    558    122322     170       163    7.63x        0    0.00x         7    1.62x
    559    176532      86        71    2.99x        0    0.00x        15    1.85x
    565     81204      20        13    1.61x        0    0.00x         7    2.36x
    566    134702      26        13    0.82x        0    0.00x        13    2.57x
    567     33531      21        18    2.88x        0    0.00x         3    2.39x
    570    147415      40        25    1.18x        0    0.00x        15    2.08x
    573     36922      24        21    3.54x        0    0.00x         3    1.97x
    576    224513      43        30    2.13x        0    0.00x        13    1.96x
    585     72811       6         2    0.14x        0    0.00x         4    1.38x
    589    124769      23        10    0.65x        0    0.00x        13    2.63x
    590    186667      32        18    1.52x        0    0.00x        14    2.43x
    593    200250      38        25    1.41x        0    0.00x        13    2.27x
    595    105622      28        15    1.07x        0    0.00x        13    2.69x
    601    176922      39        25    1.56x        0    0.00x        14    2.47x
    602     79941      25        19    3.24x        0    0.00x         6    2.31x
    604    106608      19         6    0.34x        0    0.00x        13    2.63x
    605     15059       7         4    1.29x        0    0.00x         3    1.62x
    608    227476     150       137    4.43x        0    0.00x        13    1.96x
    610     42292       8         4    1.46x        0    0.00x         4    1.58x
    612    100197      19        12    1.60x        0    0.00x         7    2.03x
    614    171757      35        22    1.21x        0    0.00x        13    2.59x
    616    162726      31        16    1.09x        0    0.00x        15    2.72x
    617    105142      19        14    1.25x        0    0.00x         5    1.81x
    620    179397      35        22    1.72x        0    0.00x        13    2.37x
    622    110013      19         5    0.47x        0    0.00x        14    3.56x
    624     48057       3         1    0.41x        0    0.00x         2    1.44x
    628     26457       4         2    1.37x        0    0.00x         2    1.35x
    631    175844      34        21    1.56x        0    0.00x        13    2.41x
    634    148420      30        17    1.38x        0    0.00x        13    2.59x
    635    106489      50        41    2.92x        0    0.00x         9    2.60x
    637     31348       4         2    0.29x        0    0.00x         2    1.62x
    640    218013      30        17    1.00x        0    0.00x        13    1.91x
    641    134570      28        14    0.98x        0    0.00x        14    2.68x
    646     40627      14        12    2.28x        0    0.00x         2    1.52x
    649     49113       4         2    0.56x        0    0.00x         2    1.38x
    655    161331      39        26    1.86x        0    0.00x        13    2.93x
    664    192108      22         9    0.75x        0    0.00x        13    2.45x
    667     29633     205       202   35.92x        0    0.00x         3    1.65x
    678    389218      49        40    0.68x        0    0.00x         9    1.35x

Failed with 'Aborted'; backtrace (libbacktrace):
utility/system-stackTrace.C::89 in _Z17AS_UTL_catchCrashiP7siginfoPv()
(null)::0 in (null)()
(null)::0 in (null)()
(null)::0 in (null)()
(null)::0 in (null)()
(null)::0 in (null)()
overlapInCore/libedlib/edlib.C::163 in _Z10edlibAlignPKciS0_i16EdlibAlignConfig()
utgcns/libcns/unitigConsensus.C::446 in _Z22generateTemplateStitchP8abAbacusP10tgPositionjdb()
utgcns/libcns/unitigConsensus.C::786 in _ZN15unitigConsensus13generatePBDAGEP5tgTigcPSt3mapIjP6sqReadSt4lessIjESaISt4pairIKjS4_EEEPS2_IjP10sqReadDataS6_SaIS7_IS8_SE_EEE()
utgcns/utgcns.C::522 in main()
(null)::0 in (null)()
(null)::0 in (null)()
./consensus.sh: line 100: 139657 Aborted                 (core dumped) $bin/utgcns -S ../Marmota_flaviventris.${tag}Store/partitionedReads.seqStore -T ../Marmota_flaviventris.${tag}Store 1 $jobid -O ./${tag}cns/$jobid.cns.WORKING -maxcoverage 40 -e 0.2 -pbdagcon -edlib -threads 8
skoren commented 5 years ago

This is probably the same cause as #1080 but that one went away with a version update so we couldn't reproduce/fix it. If you can package the data (@brianwalenz can you give the commands to package), we can try to reproduce fix/it.

oneillkza commented 5 years ago

Thanks -- I'll check whether I'm allowed to share the data. It's non-human, so should be OK ethics-wise, but also unpublished.

oneillkza commented 5 years ago

@brianwalenz How much / which parts of the data do you need?

brianwalenz commented 5 years ago

I need just the one contig that fails, contig number 678, of length 389218 bp (the last line in the table output).

From within the unitigging/ directory, generate a dump of the data for this contig with:

utgcns \
  -S Marmota_flaviventris.ctgStore/partitionedReads.seqStore \
  -T Marmota_flaviventris.ctgStore 1 1 \
  -tig 678 \
  -export contig678.export

test that it's still failing:

utgcns -e 0.2 -import contig678.export

then upload to the FTP listed in the FAQ.

oneillkza commented 5 years ago

Thanks -- yes, that reproduces the core dump.

I'm still confirming from the project leads whether it's OK to share the data. I'm sure it will be, considering how small it is, but I have to go through the formality.

oneillkza commented 5 years ago

OK -- unfortunately we're prohibited from running non-secure ftp over here, and sftp with username anonymous / password blank didn't work, but the file is pretty small, so I've just gzipped and attached it here.

brianwalenz commented 5 years ago

Thanks! I removed the link from the comment. I'll try to get this fixed tomorrow.

oneillkza commented 5 years ago

Perfect! Thank you!

brianwalenz commented 5 years ago

Well, not so perfect. There's little I can do to fix this. The first "read" in this contig has 10% N's, and unfortunately, about 18,000 of those are on the end of the read. These are preventing consensus from finding an alignment between the first and second read.

The read in question is Canu ID 462617, of length 292928 bp. Look in *.seqStore/readNames.txt for a mapping to the original read name. I suspect that your Chromium contigs are actually scaffolds!

Looking at the contig size and coverage in the logging above, I'm concerned about the sanity of the result -- the coverage in contigs is all over the place. Some are ~3x, some are ~10x, some are up to 30x. Nothing seems to have really assembled.

How were the nanopore corrected reads generated? How much coverage are we talking about in these? I assume the Chromium contigs are about 1x coverage. There might not be enough coverage to get good corrected reads. Then to get any assembly in unique regions, allowed error in overlaps would need to be high, which would make a mess of the repeats, which would break the assembly.

With some effort, we can probably bash this assembly through to completion by just ignoring the bad contig. I'd have to figure out how to (easily) do that though.

brianwalenz commented 5 years ago

I've managed to fix the problem, but you'll need to install the unreleased 'clone or download' version from github.

oneillkza commented 5 years ago

Thanks @brianwalenz

Yeah, on my cursory browse through that file I did wonder if all the Ns weren't doing it.

The nanopore corrected reads were from a prior run of Canu. I also ran them through porechop prior to that, although I have a hunch Canu does adapter detection itself so that may not have been necessary? Originally they were from a single MinION run. We're not sure of the size of the genome we're assembling, but going from an estimate of 2-3Gbp, at best we have ~4X coverage from the nanopore reads.

The 10X contigs were generated by Supernova from raw 10X reads with ~100X coverage. As such, they're likely to be of reasonably high quality. My understanding of the wider project is that it is primarily one of building genomes using 10X data, but there was a desire to mix in some MinION data for a handful of species to see if it could improve scaffolding.

For this run, I was trying to trick Canu into using the contigs (in FASTA form) as "nanopore corrected reads". Unfortunately, as I've since realised, it isn't possible to turn off the trimming stage. I haven't checked, but am fairly certain that large parts of the genome will only have coverage from the 10X data, which Canu would be seeing as being 1X (since it's contigs).

My one thought was to try duplicating all the 10X contigs (ie just cat the FASTA onto the end of itself) to try and trick Canu into thinking they have 2X coverage.

My other thought was that this whole project is somewhat outside of what Canu was built for! The alternate plan, which we are also trying, is to take the trimmed and corrected reads from running Canu on the nanopore data alone, and pass these to LINKS along with the 10X draft assembly.

Anyway, thanks so much for your time and input! I think we should be able to continue from here. (But I'm also happy to brainstorm further.)

skoren commented 5 years ago

You can definitely turn of trimming, just specify canu -assemble but you might not want to turn off trimming for the nanopore data. As for the 1x issue, there is a long history of making faux long reads from the assembly (see for example https://www.ncbi.nlm.nih.gov/pmc/articles/PMC1544072/) so you could take that strategy and generate 10kb reads from your assembly but as you said this isn't really what canu was designed for.

Given you only have 4x of nanopore data you aren't going to get much corrected/trimmed data so you could instead try using it to gap fill the 10x assembly.

oneillkza commented 5 years ago

Thanks! That's useful to know. And yes, my plan had been to run Canu once on the nanopore reads, take those post-trimming/correction, and then feed them into a second assembly-only run alongside the 10X.

But yeah, we're almost certainly going to be taking the other approach of just using it to gapfill the 10x. (We'll run this with corrected reads and without and see if it makes much difference.)