Skip to content

Commit

Permalink
Merge branch 'main' of github.com:waldronlab/taxPPro
Browse files Browse the repository at this point in the history
  • Loading branch information
sdgamboa committed Dec 13, 2023
2 parents be5d2bc + 227a8e9 commit 9389fc3
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 2 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ export(inh2)
export(ltp)
export(ltp3)
export(mpa)
export(roundDec)
export(scores2Freq)
export(taxPool)
19 changes: 18 additions & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ myFun <- function(x, adjF = 0.1) {

#' Clean node
#'
#' {cleanNode} deletes the `attribute_tbl` slot in a data.tree node.
#' \code{cleanNode} deletes the `attribute_tbl` slot in a data.tree node.
#'
#' @param node A node in a data.tree object.
#'
Expand All @@ -140,3 +140,20 @@ myFun <- function(x, adjF = 0.1) {
cleanNode <- function(node) {
node$attribute_tbl <- NULL
}

#' Round up to nearest decimal
#'
#' \code{roundDec} rounds up to next decimal. Meant to be used for
#' establishing a threhold for filtering attributes.
#' @param A character vector (of attributes).
#' @return A double.
#' @export
#'
roundDec <- function(x) {
n <- x |>
unique() |>
{\(y) y[!is.na(y)]}() |>
length()
ceiling(((1 / n) + 1e-06) * 10) / 10
}

2 changes: 1 addition & 1 deletion man/cleanNode.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions man/roundDec.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 55 additions & 0 deletions vignettes/articles/internal_nodes.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,61 @@ plot(ace3, args.plotTree = list(direction = "upwards"))
```


A single value

```{r}
mat <- matrix(rep(0, (Ntip(t3) * 2)), ncol = 2)
colnames(mat) <- LETTERS[1:2]
rownames(mat) <- t3$tip.label
mat[] <- 0.5
mat[grep('Macaca_gn1', rownames(mat)),] <- c(1, 0)
fitX <- fitMk(
tree = t3, x = mat, model = myMod, pi = myPi, lik.func = "pruning",
logscale = TRUE
)
aceX <- ancr(fitX, tips=TRUE)
plot(aceX, args.plotTree = list(direction = "upwards"))
```


```{r}
mat2 <- matrix(rep(0, (Ntip(t3) * 2)), ncol = 2)
colnames(mat2) <- LETTERS[1:2]
rownames(mat2) <- t3$tip.label
mat2[,1] <- 0
mat2[,2] <- 1
mat2[grep('Macaca_gn1', rownames(mat2)),] <- c(1, 0)
mat2[grep('Cercopithecus_petaurista', rownames(mat2)),] <- c(1, 0)
fitY <- fitMk(
tree = t3, x = mat2, model = 'ER', pi = myPi, lik.func = "pruning",
logscale = TRUE
)
aceY <- ancr(fitY, tips=TRUE)
plot(aceY, args.plotTree = list(direction = "upwards"))
```


```{r}
mat2 <- matrix(rep(0, (Ntip(t3) * 2)), ncol = 2)
colnames(mat2) <- LETTERS[1:2]
rownames(mat2) <- t3$tip.label
mat2[] <- 0.5
mat2[grep('Macaca_gn1', rownames(mat2)),] <- c(1, 0)
mat2[grep('Cercopithecus_petaurista', rownames(mat2)),] <- c(0, 1)
fitY <- fitMk(
tree = t3, x = mat2, model = 'ARD', pi = myPi, lik.func = "pruning",
logscale = TRUE
)
aceY <- ancr(fitY, tips=TRUE)
plot(aceY, args.plotTree = list(direction = "upwards"))
```

# Session information

Expand Down

0 comments on commit 9389fc3

Please sign in to comment.