Skip to content

Commit

Permalink
add node labes like n# if no taxa matches a given MRCA
Browse files Browse the repository at this point in the history
  • Loading branch information
sdgamboa committed Sep 11, 2023
1 parent 9a20c1b commit e803ea5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
2 changes: 1 addition & 1 deletion inst/extdata/livingTree.newick

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions inst/scripts/get_living.tree.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ not_missing_anymore_taxa <- taxizedb::name2taxid(missing_taxa, db = 'ncbi')
taxids[which(is.na(taxids))] <- not_missing_anymore_taxa

taxonomy <- taxizedb::classification(unique(taxids), db = 'ncbi')
x <- taxonomy
missing_taxonomy_positions <- which(map_lgl(taxonomy, ~ all(is.na(.x))))
not_missing_anymore_taxonomy <- taxize::classification(
names(missing_taxonomy_positions), db = 'ncbi'
Expand Down Expand Up @@ -99,8 +98,8 @@ mrcas_df <- mrcas_df |>
nodes <- data.frame(node = length(tree$tip.label) + 1:tree$Nnode) |>
left_join(mrcas_df, by = 'node') |>
mutate(
node_label = ifelse(is.na(node_label), '', node_label),
n_labels = ifelse(is.na(n_labels), 0, n_labels)
node_label = ifelse(is.na(node_label), paste0('n', node), node_label),
n_labels = ifelse(is.na(n_labels), 0, n_labels),
)

tree$node.label <- nodes$node_label
Expand Down
9 changes: 2 additions & 7 deletions vignettes/articles/phytools.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,8 @@ phys_data_ready <- left_join(set_with_ids, set_without_ids)



```{r}
tree <- ltp()
system.time(
data_tree <- as.Node(tree, heightName = NULL)
)
```





Expand Down Expand Up @@ -275,4 +271,3 @@ 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 e803ea5

Please sign in to comment.