liamrevell / phytools

GNU General Public License v3.0
198 stars 56 forks source link

mcmMk should set likelihood to "fitMk" when data input is matrix #154

Closed rdiaz02 closed 3 weeks ago

rdiaz02 commented 2 months ago

Currently, if data input is matrix and geiger is installed, mcmcMk fails. This is the error

likelihood="fitDiscrete" doesn't work for data input as matrix.
Setting likelihood method to "fitMk".

Error in LIK(makeq(Q, index.matrix), root = "given", root.p = pi) : 
  could not find function "LIK"

It seems that the solution is to have, right after line 56 https://github.com/liamrevell/phytools/blob/544c3c597f9849a7484698b78b1a0b42f4874372/R/mcmcMk.R#L56, a likelihood <- "fitMk" as is done in line 52 https://github.com/liamrevell/phytools/blob/544c3c597f9849a7484698b78b1a0b42f4874372/R/mcmcMk.R#L52 immediately above. That this will work is evidenced by the fact that, without geiger installed, things run just fine.

Right now, however, in line 121 https://github.com/liamrevell/phytools/blob/544c3c597f9849a7484698b78b1a0b42f4874372/R/mcmcMk.R#L121 LIK is assigned the value of fitDiscrete and that assignment is made because, not having set likelihood <- "fitMk", we still have likelihood == fitDiscrete.

P.S. I can make a pull request with this one-line change if deemed appropriate.

liamrevell commented 3 weeks ago

Fixed. Will push shortly.