SamueleSoraggi/HMMploidy

hiddenMarkovPloidyShell.R error

Closed this issue · 7 comments

Hi,

I've been trying to run the hiddenMarkovPloidyShell.R script on a set of genomes. The species has a genome size that's relatively small, ~ 20Mbp. The data is around 20X coverage. When I run the script with pretty much default parameters I get the following error:

Error in seq.default(loci[1], loci[length(loci) - 1], minSize) :
  'to' must be a finite number
Calls: windowsBuilder -> seq -> seq.default
Execution halted

I tried running the example generated through using the simulation script and the script finished successfully so I assume that I might be doing something incorrectly in either generating the mpileups or the way these pileups are being handled by the genotypelikelihood script? Anyway, please let me know if additional info would be useful in troubleshooting this error.

Hi Samuele,

Thank you for getting back to me about this. First, a few lines from one of the genolikes files:

contig-0001     23      1       C       7       C       G       4       3       -29.546180618212716     -38.47318403662433      -29.546180618212716     -4.852929694697231      -38.47318403662433      -29.546180618212716     -4.9185838524274095     -5.611531933164633      -38.47318403662433      -29.546180618212716     -5.310387976793086      -4.852929694697231
      -6.408646329792864      -38.47318403662433      -29.546180618212716     -5.721530332894191      -4.7930919521503155     -5.198446446799095      -7.107327002251342      -38.47318403662433      -29.54618061821271      -6.105063111625855      -4.9185838524274095     -4.85292969469723       -5.611531933164631      -7.71386401875268       -38.473184036624325
contig-0001     29      1       A       9       A       G       5       4       -37.322551304877244     -48.09262088789451      -37.322551304877244     -6.240238097597288      -48.09262088789451      -37.322551304877244     -6.423298994489124      -7.116746181486449      -48.09262088789451      -37.322551304877244     -6.984596963043472      -6.240238097597288
      -8.083742434773168      -48.09262088789451      -37.322551304877244     -7.553932064314514      -6.22104144719094       -6.6266732457640645     -8.940975964098984      -48.09262088789451      -37.32255130487724      -8.07854938879952       -6.423298994489124      -6.240238097597287      -7.116746181486446      -9.688946379262964      -48.092620887894505
contig-0001     31      1       A       10      A       G       5       5       -47.63140083908785      -48.32257282443038      -47.63140083908785      -6.933112259052867      -48.32257282443038      -47.63140083908785      -7.521723263333335      -7.5219215117477365     -48.32257282443038      -47.63140083908785      -8.370799660803966      -6.933112259052867
      -8.371152044062107      -48.32257282443038      -47.63140083908785      -9.16337743209813       -7.137098807541013      -7.137208952846703      -9.163872880800266      -48.32257282443038      -47.63140083908785      -9.87041647522448       -7.521723263333335      -6.933112259052867      -7.521921511747735      -9.871050529882384      -48.322572824430374
contig-0001     33      1       C       11      C       T       6       5       -48.33815223623277      -53.565441823043464     -48.33815223623277      -7.63661735785008       -53.565441823043464     -48.33815223623277      -7.940351708691136      -8.625500433637177      -53.565441823043464     -48.33815223623277      -8.672669849735 -7.63661735785008       -9.757094021923859      -53.565441823043464     -48.33815223623277      -9.401287785987362      -7.660129815767198      -8.06114740121917       -10.767678320638774     -53.565441823043464     -48.338152236232766     -10.067904908549696     -7.940351708691136      -7.63661735785008       -8.625500433637175      -11.65192946185854      -53.56544182304346
contig-0001     39      1       T       11      T       C       6       5       -48.32209518430984      -59.09164604622917      -48.32209518430984      -7.62594107745112       -59.09164604622917      -48.32209518430984      -7.926988626791763      -8.620176403201075      -59.09164604622917      -48.32209518430984      -8.658409576226054      -7.62594107745112
       -9.757094021923859      -59.09164604622917      -48.32209518430984      -9.386578617541662      -7.64766312897736       -8.053150792006544      -10.772974428808197     -59.09164604622917      -48.32209518430983      -10.052926307317119     -7.926988626791763      -7.62594107745112       -8.620176403201071      -11.662494048516582     -59.09164604622916
contig-0001     50      1       G       12      G       A       6       6       -54.02587765896604      -59.11684608920717      -54.02587765896604      -8.335816190673084      -59.11684608920717      -54.02587765896604      -9.033929240292911      -9.046596358880086      -59.11684608920717      -54.02587765896604      -10.044703937345947     -8.335816190673084
      -10.067143968185691     -59.11684608920717      -54.02587765896604      -10.987758299152956     -8.57647300373345       -8.58352026825414       -11.019193130545975     -59.11684608920717      -54.025877658966024     -11.828238249420412     -9.033929240292911      -8.335816190673082      -9.046596358880084      -11.868315366439166     -59.116846089207144
contig-0001     53      1       A       13      A       T       7       6       -59.10423403376158      -64.56508882890974      -59.10423403376158      -9.020609583060734      -64.56508882890974      -59.10423403376158      -9.441585438763886      -10.128391402981455     -64.56508882890974      -59.10423403376158      -10.343639542034946     -9.020609583060734
      -11.430998298465838     -64.56508882890974      -59.104234033761585     -11.230794372017206     -9.084578802281758      -9.486518536680169      -12.601293841607855     -64.56508882890974      -59.104234033761564     -12.0388809419415       -9.441585438763886      -9.020609583060732      -10.128391402981453     -13.628141495350123     -64.56508882890972
contig-0001     102     1       G       23      A       G       14      9       -86.3360340808479       -136.03808097096726     -86.3360340808479       -15.945550652201419     -136.03808097096726     -86.3360340808479       -15.566954016959196     -19.03236574964768      -136.03808097096726     -86.3360340808479       -16.506596807572443     -15.945550652201419
     -21.999081950736244     -136.03808097096726     -86.3360340808479       -17.610741216982337     -15.40129897144415      -17.42844441719852      -24.541402603931715     -136.03808097096726     -86.3360340808479       -18.679489130314295     -15.566954016959196     -15.945550652201412     -19.032365749647678     -26.725641361225346     -136.03808097096726
contig-0001     142     1       T       24      G       C       14      10      -96.24913443302742      -124.75588369414069     -96.24913443302742      -16.681890270495344     -124.75588369414069     -96.24913443302742      -16.71946552262098      -19.459548338037965     -124.75588369414069     -96.24913443302742      -17.95026801261409      -16.681890270495344
     -22.28718148266006      -124.75588369414069     -96.24913443302742      -19.2792190683389       -16.36793959365432      -17.971709353474264     -24.743872918251885     -124.75588369414069     -96.24913443302742      -20.531224690273557     -16.71946552262098      -16.68189027049534      -19.459548338037965     -26.86641152759799      -124.75588369414066
contig-0001     292     1       A       22      A       T       13      9       -85.64462068195719      -128.03243076471173     -85.64462068195719      -15.252456350899335     -128.03243076471173     -85.64462068195719      -15.161196343692524     -17.934138579161925     -128.03243076471173     -85.64462068195719      -16.21834775310332      -15.252456350899335
     -20.613425178936808     -128.03243076471173     -85.64462068195719      -17.386774134578545     -14.890335766617389     -16.512392619897216     -22.932834781100308     -128.03243076471173     -85.64462068195719      -18.496094728431533     -15.161196343692524     -15.252456350899333     -17.934138579161925     -24.93497647335705      -128.0324307647117
contig-0001     356     1       A       32      A       C       16      16      -151.13099690274137     -155.5090349408413      -151.13099690274137     -22.187146148192063     -155.5090349408413      -151.13099690274137     -24.07008849386364      -24.071651983505177     -155.5090349408413      -151.13099690274137     -26.786525010268026     -22.187146148192063
     -26.78930363124344      -155.5090349408413      -151.13099690274137     -29.322167659463968     -22.839595525863942     -22.840464245810832     -29.326073679312515     -155.5090349408413      -151.13099690274137     -31.584087479402925     -24.07008849386364      -22.187146148192063     -24.071651983505173     -31.589085308384956     -155.50903494084127
contig-0001     362     1       C       32      C       T       18      14      -130.28378740078176     -172.46472406234133     -130.28378740078176     -22.202324345922378     -172.46472406234133     -130.28378740078176     -22.69182515676477      -25.476486359671547     -172.46472406234133     -130.28378740078176     -24.590148707124015     -22.202324345922378
     -29.005980805926256     -172.46472406234133     -130.28378740078176     -26.54328722977472      -22.040287547111795     -23.66886488374324      -32.118413050727796     -172.46472406234133     -130.28378740078176     -28.351837482633172     -22.69182515676477      -22.202324345922378     -25.47648635967154      -34.82776368426879      -172.46472406234133
contig-0001     367     1       G       33      A       G       17      16      -153.89945185499536     -156.60524982047804     -153.89945185499536     -22.882262903367923     -156.60524982047804     -153.89945185499536     -24.47921498421295      -25.17004973498719      -156.60524982047804     -153.89945185499536     -27.078964532716984     -22.882262903367923
     -28.173467275609177     -156.60524982047804     -153.89945185499536     -29.55101522213106      -23.353385455343723     -23.757565700037542     -30.931532760264908     -156.60524982047804     -153.89945185499533     -31.772999378532795     -24.47921498421295      -22.882262903367923     -25.170049734987188     -33.37504590654982      -156.605249820478

The snp density is relatively high in the sample. I tried increasing window size but the error remains the same. One thing I want to note in case it's the basis of the problem is I've generated a genolike file for each individual rather than a combine genolike file for all individuals. Could this be the cause of the problem?

Cheers
Peter

The specific command is:

Rscript ~/popgen/HMMploidy/hiddenMarkovPloidyShell.R fileList=pop.filelist wind=100000

R version 3.4.4 and Rcpp_1.0.1 data.table_1.12.2 pracma_2.2.5

Would it be better to generate a pileup and genotype likelihood for all individuals that the test is to be run on?

Sure. Do you have an email address I could send a link to you for a google drive folder?

The problem was due to the presence of multiple contigs in the same file. HMMploidy used to assume analysis on a single chromosome at a time, but now an automatic parser to work with multiple contigs in the same file has been implemented, so that

  1. windows of loci are not overlapping on two or more contigs,
  2. contigs with no SNPs are removed,
  3. contigs shorter than the window size are automatically considered as an entire window of reduced size.

The output plot in pdf format will show, on the x axis, positions for each contig in at least two points. This is done only with at most 50 labels for the x axis, that will otherwise have no text, since it would anyway be unreadable.

Feel free to open another issue if new problems pop up.
Cheers.