if (FALSE) {
ages_file <- system.file("examples/ages", package = "phylocomr")
phylo_file <- system.file("examples/phylo_bladj", package = "phylocomr")
# from data.frame
ages_df <- data.frame(
a = c('malpighiales','eudicots','ericales_to_asterales','plantaginaceae',
'malvids', 'poales'),
b = c(81, 20, 56, 76, 47, 71)
)
phylo_str <- readLines(phylo_file)
(res <- ph_bladj(ages = ages_df, phylo = phylo_str))
if (requireNamespace("ape")) {
library(ape)
plot(read.tree(text = res))
}
# from files
ages_file2 <- file.path(tempdir(), "ages")
write.table(ages_df, file = ages_file2, row.names = FALSE,
col.names = FALSE, quote = FALSE)
phylo_file2 <- tempfile()
cat(phylo_str, file = phylo_file2, sep = '\n')
(res <- ph_bladj(ages_file2, phylo_file2))
if (requireNamespace("ape")) {
library(ape)
plot(read.tree(text = res))
}
# using a ape phylo phylogeny object
x <- read.tree(text = phylo_str)
if (requireNamespace("ape")) {
library(ape)
plot(x)
}
(res <- ph_bladj(ages_file2, x))
if (requireNamespace("ape")) {
library(ape)
tree <- read.tree(text = res)
plot(tree)
}
}
Run the code above in your browser using DataLab