thej022214 / corHMM

Fits a generalized form of the covarion model that allows different transition rate classes on different portions of a phylogeny by treating rate classes as “hidden” states in a Markov process.
11 stars 13 forks source link

error when combining ambiguities and a custom rate matrix #26

Closed santiagombv closed 3 years ago

santiagombv commented 3 years ago

Hi there, I obtain an error "arguments imply differing number of rows" only when combining data with ambiguities and a custom rate matrix. I am rerunning a routine and this error was not present some months ago. Here is a reproducible example (taken from the vignette)

library(corHMM) #v 2.7
set.seed(1985)

data(primates)
phy <- primates[[1]]
phy <- multi2di(phy)
data <- primates[[2]]
data2 <- data[, c(1,3)]
data2[c(1,7,19), 2] <- "0&1" # manually adding some ambiguities

RateCat1 <- getStateMat4Dat(data2)$rate.mat
RateCat1 <- equateStateMatPars(RateCat1, c(1:4))
RateCat2 <- getStateMat4Dat(data2)$rate.mat 
RateClassMat <- getRateCatMat(2) 
StateMats <- list(RateCat1, RateCat2)
FullMat <- getFullMat(StateMats, RateClassMat)
FullMat

HMM_sym_ard_ard <- corHMM(phy = phy, data = data2, rate.cat = 2, rate.mat = FullMat,
                                                    node.states = "none")
HMM_sym_ard_ard

This does not happen when I do not include a custom matrix

HMM_ard_ard_ard <- corHMM(phy = phy, data = data2, rate.cat = 2, model = "ARD",
                                                   node.states = "none")
HMM_ard_ard_ard

(however, a warning is popping out in all models that I run now): Error in names(UserStates) <- sort(unique(x$data.legend[, 2])) : el atributo 'names' [3] debe tener la misma longitud que el vector [2] (some of my errors are in Spanish ;)

Thanks!

jboyko commented 3 years ago

Hi Santiagio,

Sorry for the delay. I wasn't able to replicate the error that you specified exactly, but I did find a couple bugs associated with the ambiguity handling and custom rate matrices. Could you try installing the newest github version devtools:::install_github("thej022214/corHMM") and let me know if that fixes the issue or any issues that pop up?

Best, James

santiagombv commented 3 years ago

Hi James, now it works fine! thank you so much

jboyko commented 3 years ago

Awesome, that's great to hear!