josephwb/turboMEDUSA — pull request #4 by SimonGreenhill (2013-06-26 01:11:19+00:00)
Title: getThreshold calls prepareData with resolveTree set to FALSE

If the input tree is not binary (i.e. polytomous) then this will fail with the
following error:

Error in prepareData(phy = phy, richness = richness, verbose = FALSE, :
WARNING: input tree is not binary (i.e. contains one or more polytomies).
If you wish to randomly resolve the tree, re-run MEDUSA with option "resolveTree=TRUE".

Stopping analysis.

The attached patch fixes this by setting the call to resolveTree in getThreshold
to TRUE by default.

I did it this way rather than changing the function signature of getThreshold to
include resolveTree because (a) it's less invasive and (b) if the user's tree is
indeed non-binary, then the call to prepareData on Line 31 of MEDUSA.R will still
raise the desired error message.

However, the next problem is the next checks in prepareData.R lines 40-43,
do the following:

if (any(phy$edge.length == 0)) {
cat("\nWARNING: input tree contains ", length(which(phy$edge.length == 0)), " zero-length branches.\n", sep="");
stop("Stopping analysis.\n");
}

... so even if the tree is resolved arbitrarily with multi2di, this will create
zero-length branches, and will always fail. Is it safe to remove the call to
`stop`?