You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use ancThresh to do ancestral state reconstruction but when I pass my data to ancThresh I keep getting errors related to the format of the data and I'm not sure how to change the input to fix this.
Some code to recreate the errors is given below:
### MWE
### Create some data
# Define the row names and column values
row_names <- c('Mastixiodendron pachyclados', 'Aphanocarpus steyermarkii', 'Perama dichotoma')
values <- c(0, 0, 1)
df <- data.frame(`Binary_Var` = values, row.names = row_names)
simulated_tree <- ape::rtree(3)
simulated_tree$tip.label <- row_names # Assign tip names to the simulated tree
### The following give:
### Error in apply(X, 1, sum) : dim(X) must have a positive length
mcmc<-phytools::ancThresh(simulated_tree,df,sequence = c(0,1))
mcmc<-phytools::ancThresh(simulated_tree,as.matrix(df),sequence = c(0,1))
### The following give:
### Error in apply(X, 1, rstate) : dim(X) must have a positive length
mcmc<-phytools::ancThresh(simulated_tree,df$Binary_Var,sequence = c(0,1))
mcmc<-phytools::ancThresh(simulated_tree,c(setNames(df$Binary_Var, row_names)),sequence = c(0,1))
R version: 4.2
phytools version: 2.1-1
The text was updated successfully, but these errors were encountered:
I am trying to use
ancThresh
to do ancestral state reconstruction but when I pass my data toancThresh
I keep getting errors related to the format of the data and I'm not sure how to change the input to fix this.Some code to recreate the errors is given below:
R version: 4.2
phytools version: 2.1-1
The text was updated successfully, but these errors were encountered: