Hi Elizabeth,
Thanks for the report. Apparently, it's enough to add:
if (is.null(p)) p <- 1L
after:
p <- ncol(x)
Best wishes,
Emmanuel
Le 23/05/2017 à 20:31, Elizabeth Purdom a écrit :
Hello,
I am writing to the R-sig-phylo mailing list regarding what seems to be
a bug in the `phydataplot` function in `ape`.
Specifically, if the style is `mosaic` but the data is a vector or
1-column matrix, the function fails.
The following code is from the examples (that obviously works):
> tr <- rtree(n <- 30)
> p <- 5
> x <- matrix(sample(3, size = n*p, replace = TRUE), n, p)
> dimnames(x) <- list(paste0("t", 1:n), LETTERS[1:p])
> plot(tr, x.lim = 35, align.tip = TRUE, adj = 1)
> phydataplot(x, tr, "m", 2)
However, if I instead use only 1 column of x (either vector or force to
remain a matrix):
> phydataplot(x[,1],tr,"m",2)
Error in seq.default(x0, x1, width) : invalid (to - from)/by in seq(.)
> phydataplot(x[,1,drop=FALSE],tr,"m",2)
Error in seq.default(x0, x1, width) : invalid (to - from)/by in seq(.)
This appears to be because of the following code within the function:
p <- ncol(x)
if (is.null(width)) {
x1 <- lastPP$x.lim[2]
width <- (x1 - x0)/p
} else x1 <- x0 + width * p
xx <- seq(x0, x1, width)
Since `x` is the output of `.matchDataPhylo(x, phy)`, it is always a
vector, even if original x is a 1-column matrix, so that ncol(x) is
NULL. Probably if there is a catch for when x is a vector to set p=1,
then it would fix the problem, though I haven’t tested whether there are
any further problems that come up.
All of the best,
Elizabeth Purdom
Here is my session info:
> sessionInfo()
R version 3.3.0 beta (2016-04-04 r70420)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.10.5 (Yosemite)
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] parallel stats4 stats graphics grDevices utils datasets
methods base
other attached packages:
[1] clusterExperiment_1.3.1 ape_4.1
SummarizedExperiment_1.4.0
[4] Biobase_2.34.0 GenomicRanges_1.26.4
GenomeInfoDb_1.10.3
[7] IRanges_2.8.2 S4Vectors_0.12.2
BiocGenerics_0.20.0
[10] devtools_1.12.0
loaded via a namespace (and not attached):
[1] nlme_3.1-131 bitops_1.0-6 matrixStats_0.52.2
bold_0.4.0 doParallel_1.0.10
[6] RColorBrewer_1.1-2 progress_1.1.2 httr_1.2.1
prabclus_2.2-6 tools_3.3.0
[11] R6_2.2.0 DBI_0.6-1 lazyeval_0.2.0
colorspace_1.3-2 ade4_1.7-6
[16] trimcluster_0.1-2 nnet_7.3-12 withr_1.0.2
gridExtra_2.2.1 prettyunits_1.0.2
[21] xml2_1.1.1 pkgmaker_0.22 diptest_0.75-7
scales_0.4.1 DEoptimR_1.0-8
[26] mvtnorm_1.0-6 robustbase_0.92-7 NMF_0.20.6
commonmark_1.2 stringr_1.2.0
[31] digest_0.6.12 XVector_0.14.1 limma_3.30.13
howmany_0.3-1 jsonlite_1.4
[36] mclust_5.2.3 dendextend_1.5.2 dplyr_0.5.0
RCurl_1.95-4.8 magrittr_1.5
[41] modeltools_0.2-21 Matrix_1.2-10 Rcpp_0.12.10
munsell_0.4.3 abind_1.4-5
[46] viridis_0.4.0 stringi_1.1.5 whisker_0.3-2
MASS_7.3-47 zlibbioc_1.20.0
[51] flexmix_2.3-14 MAST_1.0.5 plyr_1.8.4 grid_3.3.0
crayon_1.3.2
[56] rncl_0.8.2 lattice_0.20-35 splines_3.3.0 uuid_0.1-2
taxize_0.8.4
[61] fpc_2.1-10 rngtools_1.2.4 reshape2_1.4.2
codetools_0.2-15 XML_3.98-1.7
[66] RNeXML_2.0.7 data.table_1.10.4 foreach_1.4.3
testthat_1.0.2 locfdr_1.1-8
[71] gtable_0.2.0 tidyr_0.6.2 reshape_0.8.6
kernlab_0.9-25 assertthat_0.2.0
[76] ggplot2_2.2.1 gridBase_0.4-7 phylobase_0.8.4
xtable_1.8-2 roxygen2_6.0.1
[81] class_7.3-14 viridisLite_0.2.0 tibble_1.3.0
iterators_1.0.8 registry_0.3
[86] memoise_1.1.0 cluster_2.0.6
>
Pour nous remonter une erreur de filtrage, veuillez vous rendre ici
<http://f.security-mail.net/803CxvOn8RA>
_______________________________________________
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/