Closed xiangpin closed 1 year ago
as.treedata for tbl_df do not work well This pr fixed it.
as.treedata
tbl_df
https://github.com/YuLab-SMU/tidytree/issues/35
library(purrr) library(tidytree) library(treeio) phy <- rtree(20, br = runif) nodedata <- tibble(node = 21:39, nodeinfo = letters[1:19]) tipdata <- tibble(node = 1:20, tipinfo = LETTERS[1:20]) phytbl <- as_tibble(phy) %>% left_join(nodedata, by = "node") %>% left_join(tipdata, by = "node") %>% mutate(label = paste(label, tipinfo)) as.treedata(phytbl)@phylo # Exactly as expected phytbl <- phytbl %>% dplyr::mutate(branchinfo = as.character(NA)) %>% dplyr::group_split(branch.length > 0.6) %>% modify_at(2, ~ mutate(., branchinfo = "info")) %>% dplyr::bind_rows() # phytbl is a tbl_df class trda <- phytbl %>% as.treedata(branch.length, label)
Description
as.treedata
fortbl_df
do not work well This pr fixed it.Related Issue
https://github.com/YuLab-SMU/tidytree/issues/35
Example