Error in if (sum(TF) > 0) { : missing value where TRUE/FALSE needed

879 views
Skip to first unread message

Chauncey Gadek

unread,
Feb 8, 2018, 11:02:44 PM2/8/18
to BioGeoBEARS
Hi all,

I have successfully run several time-stratified analysis with 9 areas. Now I want to run an analysis with only 5 areas. I have modified my areas allowed and time periods text files accordingly but now I obtain the following error when applying time slices to my tree: 

BioGeoBEARS_run_object = section_the_tree(inputs=BioGeoBEARS_run_object, make_master_table=TRUE, plot_pieces=FALSE)
1- top: 0, bot: 5, rel_bot: 5
Error in if (sum(TF) > 0) { : missing value where TRUE/FALSE needed.

I have quadruple checked my areas allowed and time periods files for hidden characters and incorrect formatting, made sure all nodes are within the earliest time period, and I'm running source() commands each time I run the script. I imagine my error is hiding somewhere else in plain sight. Any help is appreciated!

My areas allowed and time periods files are attached.

Thanks,
Chauncey Gadek


areas_allowedCG1Fur_5Areas.txt
timeperiodsCG1Fur_5Areas.txt

Nick Matzke

unread,
Feb 8, 2018, 11:16:59 PM2/8/18
to bioge...@googlegroups.com
Ack! I put up a bug check today but must have added a bug, I'll fix shortly.

Thanks for the report.

Nick

--
You received this message because you are subscribed to the Google Groups "BioGeoBEARS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to biogeobears+unsubscribe@googlegroups.com.
To post to this group, send email to bioge...@googlegroups.com.
Visit this group at https://groups.google.com/group/biogeobears.
To view this discussion on the web visit https://groups.google.com/d/msgid/biogeobears/a46afa12-1580-41cf-aa3c-618b33818f0f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nick Matzke

unread,
Feb 8, 2018, 11:26:33 PM2/8/18
to bioge...@googlegroups.com
It should be fixed now, this is the code that was added today, it checks for negative branchlengths coming from the chainsaw2 function that chops up the tree during time-stratified analyses.  Just now I added "TF[is.na(TF)] = FALSE" to stop the NA that occurs if e.g. there is no branchlength below the root node.

===================
#######################################################
# Error check
#######################################################
tmp_trtable = prt(tree_to_chainsaw, printflag=FALSE)
brlens = tmp_trtable$edge.length
TF = brlens <= 0
TF[is.na(TF)] = FALSE
if (sum(TF) > 0)
{
nodenums = (1:nrow(tmp_trtable))[TF]
nodenums
txt = paste0("STOP ERROR in chainsaw2(): the post-chainsaw tree had ", sum(TF), " negative branchlengths. READ THE FOLLOWING ERROR MESSAGE SLOWLY AND CAREFULLY AND YOU MAY FIND A SOLUTION. This error seems to sometimes occur with large cuts on trees with many fossil tips (i.e., non-contemporaneous tips). I'm not sure what causes the bug, except that chainsaw-ing an APE phylo object is quite complex, and it is even more complex for a tree with many non-contemporaneous tips. Imagine a phylogeny made of cardboard, then cutting it at various timepoints, then keeping track of all of the pieces.  Anyway, until I fix it, your best bet is to chainsaw2() in stages, using smaller cuts than the one that caused the error.  Or if you are using BioGeoBEARS and doing a time-stratified analysis, create extra time-strata (perhaps repeating the same settings for several time bins), so that the usage of chainsaw2() within section_the_tree() does not cause an error.")
cat("\n\n")
cat(txt)
cat("\n\n")
stop(txt)
} # END if (sum(TF) > 0)
===================

Cheers, Nick

jonas...@gmail.com

unread,
Mar 22, 2018, 11:22:38 AM3/22/18
to BioGeoBEARS
Hello, I am still getting this error after updating BioGeoBEARS and using the out of the box script from the website using my own range and tree files. I subset a clade from my original Newick file which ran fine and so I don't think it has a branch length below the node, but I also tried manually adding it and got the same error.
Error in if (sum(blren_equal_below_0_TF) > 0) { : 
  missing value where TRUE/FALSE needed
I'm still learning R and not sure where to go from here, I have attached my Newick and range files, any help would be greatly appreciated.
Thank you,
Jonas
===================

Cheers, Nick




To unsubscribe from this group and stop receiving emails from it, send an email to biogeobears...@googlegroups.com.
Polypodium_sensustricto_newick.txt
Polypodiumss_ranges.txt

Nick Matzke

unread,
Mar 26, 2018, 1:54:42 AM3/26/18
to bioge...@googlegroups.com
Hi -- that's a new one!  Thanks for sending the files. Perhaps because you clipped this out of some other tree, this Newick string has extra brackets in it, which APE reads as branches with NA for branchlengths. R drops a hint when the script plots the tree (and it plots the tree without branchlengths):

=============
> # Look at your phylogeny:
> tr = read.tree(trfn)
> tr

Phylogenetic tree with 35 tips and 38 internal nodes.

Tip labels:
Pleurosoriopsis, subpetiolatum, plesiosorum, rhodopleuron, colpodes, martensii, ...

Rooted; includes branch lengths.
> plot(tr)
Warning message:
In plot.phylo(tr) :
  3 branch length(s) NA(s): branch lengths ignored in the plot
=============


I looked at the Newick file:

=======================
(((((Pleurosoriopsis:24.773126232303042,((subpetiolatum:11.383175889712598,((plesiosorum:2.378678639105292,(rhodopleuron:1.1959614632108544,colpodes:1.1959614632108544):1.182717175894438):6.34866428324539,martensii:8.727342922350688):2.655832967361894):9.209581201914686,(((macaronesicum:3.7169649580983966,(cambricum_8787:0.6424977892103643,cambricum_8786:0.6424977892103643):3.074467168888031):8.202951044606586,(pellucidium:5.493341495630409,(scouleri_7216:0.6667704467547895,scouleri_7251:0.6667704467547895):4.826571048875622):6.42657450707457):1.6760549321540719,((fauriei:8.806652616052684,((glycyrrhiza_8161:1.291222128458476,((glycyrrhiza_8523:0.5464998071567838,glycyrrhiza_8009:0.5464998071567838):0.48741712836619533,((glycyrrhiza_7781:0.3992311664855398,glycyrrhiza_7783:0.3992311664855387):0.39215005520403245,(glycyrrhiza_7537:0.34280424726817754,glycyrrhiza_7768:0.34280424726817815):0.44857697442139416):0.24253571383340788):0.25730519293549636):1.225694028498135,(californicum_7249:0.30849264478491684,californicum_3829:0.30849264478491684):2.208423512171699):6.28973645909605):3.871972167763994,((((sibricium_9145:0.5845198214743779,(((appalachianum_7630:0.14726483383087902,appalachianum_7533:0.1472648338308793):0.3024116834983529,appalachianum_8029:0.4496765173292321):0.060829413676610544,amorphum_7771:0.5105059310058426):0.07401389046853535):0.5306420814798452,((sibricium_8010:0.2737274338425286,amorphum_6951:0.2737274338425284):0.4848276024514466,(amorphum_8210:0.402383727809889,(amorphum_8499:0.22024872436159834,amorphum_7773:0.2202487243615985):0.18213500344829067):0.3561713084840863):0.356606866660248):0.15098061555180364,appalachianum_8045:1.2661425185060278):0.9153653645018542,(sibricium_8039:1.1538442992113962,sibricium_8008:1.1538442992113975):1.0276635837964863):10.497116900808756):0.917346151042393):6.9967861567682235):4.180369140675754):14.236999025489428))));

=======================

...and removed four leading/trailing brackets:


=======================
(Pleurosoriopsis:24.773126232303042,((subpetiolatum:11.383175889712598,((plesiosorum:2.378678639105292,(rhodopleuron:1.1959614632108544,colpodes:1.1959614632108544):1.182717175894438):6.34866428324539,martensii:8.727342922350688):2.655832967361894):9.209581201914686,(((macaronesicum:3.7169649580983966,(cambricum_8787:0.6424977892103643,cambricum_8786:0.6424977892103643):3.074467168888031):8.202951044606586,(pellucidium:5.493341495630409,(scouleri_7216:0.6667704467547895,scouleri_7251:0.6667704467547895):4.826571048875622):6.42657450707457):1.6760549321540719,((fauriei:8.806652616052684,((glycyrrhiza_8161:1.291222128458476,((glycyrrhiza_8523:0.5464998071567838,glycyrrhiza_8009:0.5464998071567838):0.48741712836619533,((glycyrrhiza_7781:0.3992311664855398,glycyrrhiza_7783:0.3992311664855387):0.39215005520403245,(glycyrrhiza_7537:0.34280424726817754,glycyrrhiza_7768:0.34280424726817815):0.44857697442139416):0.24253571383340788):0.25730519293549636):1.225694028498135,(californicum_7249:0.30849264478491684,californicum_3829:0.30849264478491684):2.208423512171699):6.28973645909605):3.871972167763994,((((sibricium_9145:0.5845198214743779,(((appalachianum_7630:0.14726483383087902,appalachianum_7533:0.1472648338308793):0.3024116834983529,appalachianum_8029:0.4496765173292321):0.060829413676610544,amorphum_7771:0.5105059310058426):0.07401389046853535):0.5306420814798452,((sibricium_8010:0.2737274338425286,amorphum_6951:0.2737274338425284):0.4848276024514466,(amorphum_8210:0.402383727809889,(amorphum_8499:0.22024872436159834,amorphum_7773:0.2202487243615985):0.18213500344829067):0.3561713084840863):0.356606866660248):0.15098061555180364,appalachianum_8045:1.2661425185060278):0.9153653645018542,(sibricium_8039:1.1538442992113962,sibricium_8008:1.1538442992113975):1.0276635837964863):10.497116900808756):0.917346151042393):6.9967861567682235):4.180369140675754):14.236999025489428;
=======================

...and it seems to work now.

Cheers,
Nick

To unsubscribe from this group and stop receiving emails from it, send an email to biogeobears+unsubscribe@googlegroups.com.

To post to this group, send email to bioge...@googlegroups.com.
Visit this group at https://groups.google.com/group/biogeobears.

jonas...@gmail.com

unread,
Mar 26, 2018, 3:01:04 PM3/26/18
to BioGeoBEARS
knew it'd be a trivial little edit. It worked, thanks a bunch Nick!
-Jonas
Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
Message has been deleted
0 new messages