Skip to content

Commit

Permalink
update ltp to latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
sdgamboa committed Nov 24, 2023
1 parent 280c980 commit 1087dbf
Show file tree
Hide file tree
Showing 6 changed files with 23,061 additions and 32 deletions.
76 changes: 76 additions & 0 deletions R/trees.R
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,79 @@ ltp2 <- function(remove_zero_tips = TRUE) {
)
}






#' Get living tree project (LTP) tree or data v3
#'
#' \code{ltp3} gets the LTP tree or data.
#'
#' @return A list with a phylo (the ltp tree) and a data.frame (tip_data)
#' objects.
#' @export
#'
ltp3 <- function() {
tree_fname <- system.file(
'extdata', 'LTP_all_08_2023.newick', package = 'taxPPro'
)
tip_data_fname <- system.file(
'extdata', 'LTP_all_08_2023.tip_data', package = 'taxPPro'
)
node_data_fname <- system.file(
'extdata', 'LTP_all_08_2023.node_data', package = 'taxPPro'
)
tree <- ape::read.tree(tree_fname)
tip_data <- utils::read.table(
file = tip_data_fname, header = TRUE, sep = '\t', row.names = NULL
) |>
purrr::modify(as.character) |>
as.data.frame() |>
dplyr::select(-.data$taxname)
rownames(tip_data) <- tip_data$tip_label

node_data <- utils::read.table(
file = node_data_fname, header = TRUE, sep = '\t', row.names = NULL
) |>
purrr::modify(as.character) |>
as.data.frame()

# tip_data <- tip_data |>
# dplyr::group_by(taxid) |>
# dplyr::slice_head(n = 1) |>
# dplyr::ungroup() |>
# as.data.frame()
# ntips4 <- nrow(tip_data)
# tree <- ape::keep.tip(phy = tree, tip = tip_data$tip_label)
# message('Dropping ', ntips3 - ntips4, ' tips because of duplicated taxids.')
# tip_data <- tip_data[tree$tip.label,]
# message('Tips remaining: ', length(tree$tip.label))

# tip_data <- tip_data |>
# dplyr::mutate(
# NCBI_ID = dplyr::case_when(
# .data$Rank == 'genus' ~ paste0('g__', taxid),
# .data$Rank == 'species' ~ paste0('s__', taxid),
# .data$Rank == 'strain' ~ paste0('t__', taxid),
# TRUE ~ NA
# )
# )

list(
tree = tree, tip_data = tip_data, node_data = node_data
)
}













1 change: 1 addition & 0 deletions inst/extdata/LTP_all_08_2023.newick

Large diffs are not rendered by default.

Loading

0 comments on commit 1087dbf

Please sign in to comment.