dosreislab / mcmc3r

mcmc3r: an R package for MCMCTree
MIT License
2 stars 2 forks source link

Morpho #2

Closed sabifo4 closed 6 years ago

sabifo4 commented 6 years ago

Changes:

NOTES: I added importFrom("stats", "var") in the NAMESPACE file to avoid warning when devtools::check().

The file morpho.R now contains three functions: write.morpho(), array2matrix(), and matrix2array(). The former is the one that generates the alignment file in phylip format. Now, this function also scales the data if a vector with variances is provided (parameter "popvar") and transforms the data if a correlation matrix is provided (parameter "R") applying either the eigendecomposition (parameter method = "eigen") or the Cholesky decomposition (parameter method = "chol"). It takes also a new argument to write the name of the output file (parameter "filename").

The function array2matrix() takes an array of format p x k x n ('p' landmark points of 'n' specimens in 'k' dimension landmarks) and transforms it into a matrix with 'n' rows and 'p' columns. This function is used inside write.morpho() when flattening a 3D array, if the user provides a 3D array as argument for parameter "proc".

The function matrix2array() takes a matrix of format n x p ('n' rows for 'n' specimens and 'p' columns for 'p' coordinates) and transforms it into an array of format p x k x n ('k' is the dimension of the landmark points, 3D or 2D).