Skip to content

Commit

Permalink
add markdown for phytools
Browse files Browse the repository at this point in the history
  • Loading branch information
sdgamboa committed Sep 7, 2023
1 parent 94a1497 commit 043c94c
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions vignettes/articles/phytools.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
title: "phytools"
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```

```{r setup, message=FALSE}
library(phytools)
```

Load data:

```{r}
data("primate.tree")
data("primate.data")
tree <- primate.tree
data <- primate.data
rm(primate.tree)
rm(primate.data)
activity <- data$Activity_pattern
names(activity) <- rownames(data)
m <- to.matrix(activity, levels(activity))
m[,] <- rep(1/ncol(m), ncol(m))
labs <- rownames(m)[which(grepl('Galago', rownames(m)))]
for (i in seq_along(labs)) {
m[labs[i],] <- c(0, 0, 1)
}
fit <- fitMk(
tree = tree, x = m, model = 'ARD', pi = "fitzjohn", logscale = TRUE,
lik.func = "pruning"
)
ace <- ancr(fit, tips = TRUE)
res <- ace$ace
```






```{r}
plot(ace, args.plotTree = list(direction = "upwards"))
tips <- sapply(labs, function(x, y) which(y == x), y = tree$tip.label)
add.arrow(tree, tips, arrl = 3, offset = 2, lwd = 2, col = palette()[4])
```

0 comments on commit 043c94c

Please sign in to comment.