KlausVigo / phangorn

Phylogenetic analysis in R
http://klausvigo.github.io/phangorn/
202 stars 38 forks source link

pratchet function - Error in f$pscore_nni(INDEX[, 1L:4L]) : Not a matrix. #117

Closed fulviodan13 closed 3 years ago

fulviodan13 commented 3 years ago

Hi, I got an error when using pratchet function. Please could you help me to fix it? Thank you.

> session_info("phangorn") Session info setting value
version R version 4.0.3 (2020-10-10) os macOS Big Sur 10.16
system x86_64, darwin17.0
ui RStudio
language (EN)
collate en_US.UTF-8
ctype en_US.UTF-8
tz America/New_York
date 2021-05-14

Packages package version date lib source
ape
5.5 2021-04-25 [1] CRAN (R 4.0.2) fastmatch 1.1-0 2017-01-28 [1] CRAN (R 4.0.2) igraph 1.2.6 2020-10-06 [1] CRAN (R 4.0.2) lattice 0.20-41 2020-04-02 [1] CRAN (R 4.0.3) magrittr 2.0.1 2020-11-17 [1] CRAN (R 4.0.2) Matrix 1.3-2 2021-01-06 [1] CRAN (R 4.0.2) nlme 3.1-152 2021-02-04 [1] CRAN (R 4.0.2) phangorn 2.7.0 2021-05-03 [1] CRAN (R 4.0.2) pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.0.2) quadprog 1.5-8 2019-11-20 [1] CRAN (R 4.0.2) Rcpp 1.0.6 2021-01-15 [1] CRAN (R 4.0.2)

[1] /Library/Frameworks/R.framework/Versions/4.0/Resources/library

> head(vaf_bin) Normal G95E G95F G95I 1 0 1 1 1 2 0 1 1 1 3 0 1 1 1 4 0 1 1 1 5 0 1 1 1 6 0 1 1 1

> phydat <- phyDat(vaf_bin, type = "USER", levels = c(0, 1)) > njtree <- NJ(dist.hamming(phydat)) > partree <- pratchet(phydat, trace = F) Error in f$pscore_nni(INDEX[, 1L:4L]) : Not a matrix.

KlausVigo commented 3 years ago

Hi @fulviodan13, Have you tried the development version on github? It should be fixed there.

remotes::install_github("KlausVigo/phangorn")

Regards, Klaus

fulviodan13 commented 3 years ago

Hi Klaus,

Thank you for your quick reply.

I am trying with the dev version as you suggested, but now I get another error with acctran function.

> phydat <- phyDat(vaf_bin, type = "USER", levels = c(0, 1))
> njtree <- NJ(dist.hamming(phydat))
> partree <- pratchet(phydat, trace = F)
> partree <- acctran(partree, phydat)
Error in f$acctran_traverse(tmp) : Not a matrix.

Thanks for your support.

Fulvio

KlausVigo commented 3 years ago

Hi @fulviodan13 , can you lease send me your data set where you experience this problem to reproduce it the error. Thanks, Klaus

fulviodan13 commented 3 years ago

Hi Klaus,

Please find here the dataset I am analyzing.

Thank you.

Best,

Fulvio

KlausVigo commented 3 years ago

Hi Fulvio @fulviodan13 , this should be fixed now, too! Thanks for reporting! Best, Klaus

fulviodan13 commented 3 years ago

Thank you @KlausVigo ! Just one more request. Could you fix the fuction pratchet to give correct lables to the nodes?

> partree

Phylogenetic tree with 4 tips and 2 internal nodes.

Tip labels:
  Normal, G95E, G95F, G95I
Node labels:
  NA, 0.5

Unrooted; includes branch lengths.
KlausVigo commented 3 years ago

Hi @fulviodan13, the node labels should be correct. Try

plot(partree, show.node.label=TRUE)

There should be no value plotted at the root, that's why there is a NA. pratchet makes now use of the fact that perturbation = "ratchet" implicitly computes bootstrap samples. You might want to run partree <- pratchet(phydat, trace = FALSE, minit=100) to ensure you have at least 100 bootstrap samples. Cheers, Klaus

fulviodan13 commented 3 years ago

Thank you @KlausVigo ! Best, Fulvio