venelin / PCMFit

An R-package for maximum likelihood inference of Gaussian phylogenetic models with shifts
https://venelin.github.io/PCMFit
4 stars 3 forks source link

run PCMFitMixed with univariate data #11

Open ptitle opened 1 year ago

ptitle commented 1 year ago

Hi,

I'm trying to work out how to run PCMFitMixed() with univariate data.

With the following, the multivariate dataset works, but if I subset it to a single variable (1-row matrix), I get all sorts of errors. Clearly, I'm doing something wrong.

Advice appreciated, thanks!

library(PCMBase)
library(PCMBaseCpp)
library(PCMFit)
library(ape)

tree <- PCMTree(PCMFitDemoObjects$dtSimulated$tree[[1]])
X <- PCMFitDemoObjects$dtSimulated$X[[1]][, seq_len(PCMTreeNumTips(tree))]
dim(X)

test <- PCMFitMixed(
    X = X, tree = tree, metaIFun = PCMInfoCpp,
    maxNumRoundRobins = 2, maxNumPartitionsInRoundRobins = 2,
    doParallel = FALSE)

That seems to run fine.

unidat <- matrix(X[1,], nrow = 1)

test <- PCMFitMixed(
    X = unidat, tree = tree, metaIFun = PCMInfoCpp,
    maxNumRoundRobins = 2, maxNumPartitionsInRoundRobins = 2,
    doParallel = FALSE)

Output:

Initiating tableFits...
Step 1 ( 1671136303 ): Performing fits on 11  clades;  66  model mappings altogether...
 Step 1.1 ( 1671136303 ): Fitting models independently from random starting locations...
Performing ML fit on 'E(tree,81)', partition: (81), mapping: (A)
Error in `[<-`(`*tmp*`, 2, 2, r, value = 1) : subscript out of bounds
Performing ML fit on 'E(tree,81)', partition: (81), mapping: (B)
Error in `[<-`(`*tmp*`, 1, 2, r, value = -0) : subscript out of bounds
Performing ML fit on 'E(tree,81)', partition: (81), mapping: (C)
Error in `[<-`(`*tmp*`, 2, r, value = -1.2) : subscript out of bounds
Performing ML fit on 'E(tree,81)', partition: (81), mapping: (D)
Error in `[<-`(`*tmp*`, 2, r, value = -1.2) : subscript out of bounds
Performing ML fit on 'E(tree,81)', partition: (81), mapping: (E)
Error in `[<-`(`*tmp*`, 2, r, value = -1.2) : subscript out of bounds
Performing ML fit on 'E(tree,81)', partition: (81), mapping: (F)
Error in `[<-`(`*tmp*`, 2, r, value = -1.2) : subscript out of bounds
ERROR in foreach task: no data.table returned: 
 Error in `[<-`(`*tmp*`, 2, 2, r, value = 1) : subscript out of bounds

ERROR in foreach task: no data.table returned: 
 Error in `[<-`(`*tmp*`, 1, 2, r, value = -0) : subscript out of bounds
 ## and it continues...