-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Hi Martin - I've run into an error which has me a little stumped, apologies if I am missing something obvious. I've created a minimal example on the basis that I think this relates to decomposing characters with polymorphisms, and then running any form of implied weights analysis on them. Here is a (zipped to allow upload) two taxon matrix:
This script loads it (assuming the above file is in the wd, and TreeTools and TreeSearch packages are loaded) and orders the characters from a dataframe column (implemented as such as the other column, "characterStates" , is used to calculate weightings for reweighting downstream - not included here). It does a quick check to ensure the change in character number, and then creates an EW addition tree with no error, but fails under implied weights (at least, this is true on 3 of my systems, all running Linux and the development version of TreeTools to implement the handy Reweight function you created, but otherwise the versions of all required packages from CRAN):
# Load required libraries
library("TreeTools")
library("TreeSearch")
#Character number function
NumberOfChars <- function(x) sum(attr(x, "weight"))
#Load data from matrix
datasetInapplicables <- ReadAsPhyDat("Garwood_Morphy_error.nex")
NumberOfChars(datasetInapplicables)
#Decompose ordered characters
orderedCharacters<-data.frame("characterNumber"=c(155,151,148,48,42,12,5,1),"characterStates"=c(3,5,9,8,3,3,3,10))
datasetInapplicablesDecomposed<-Decompose(datasetInapplicables,orderedCharacters$characterNumber)
NumberOfChars(datasetInapplicablesDecomposed)
#No error
startTree <- AdditionTree(datasets[[i]], concavity = Inf)
#Error
startTree <- AdditionTree(datasets[[i]], concavity = 10)
From what I can see it fails when preparing the data for the IW analysis, specifically in the function MorphyErrorCheck, when it calls mpl_attach_rawdata, however I can't actually find the error code returned (ERR_DIMENS_OVER) in the morphy source code. I guess this implies that the reweighting has messed with the character numbers, and perhaps that this originates in TreeSearch, or that I don't have access to the latest version of the required Morphy code?
Any assistance much appreciated...