Skip to content

groupClade does not function correctly on single branches #51

@jasonbosch

Description

@jasonbosch

I am trying to colour branches on a tree based on their phylogenetic classification. I want to colour all branches from the same level, e.g. Class. I figured I should be able to do that with groupClade but I realised it does not function correctly. For single branches it only labels the last two nodes regardless of the node that is given to the command. I can't imagine this is the intended behaviour.

library(tidytree)
library(ggtree)
nwk <- "(((((((Terriglobusroseus)Terriglobus)Acidobacteriaceae)Acidobacteriales)Acidobacteriae)Acidobacteriota,(((((Corynebacteriumglutamicum)Corynebacterium)Mycobacteriaceae)Mycobacteriales,(((Nocardiopsisdassonvillei)Nocardiopsis)Streptosporangiaceae)Streptosporangiales)Actinomycetia)Actinobacteriota,(((((Echinicolavietnamensis)Echinicola)Cyclobacteriaceae)Cytophagales)Bacteroidia)Bacteroidota,(((((Meiothermus_Bsilvanus)Meiothermus_B)Thermaceae)Deinococcales)Deinococci)Deinococcota,(((((Hungateiclostridiumthermocellum)Hungateiclostridium)Acetivibrionaceae)Acetivibrionales,(((Clostridium_Pperfringens)Clostridium_P)Clostridiaceae)Clostridiales)Clostridia)Firmicutes_A,(((((Desulfosporosinusacidiphilus)Desulfosporosinus)Desulfitobacteriaceae)Desulfitobacteriales)Desulfitobacteriia)Firmicutes_B)Bacteria);"
tree <- read.tree(text=nwk)
tree_grouped <- groupClade(tree, c(35,30))
ggtree(tree_grouped, aes(colour = group)) +
  geom_text(aes(label=node))

As you can see in the example code, labelling is correct for node 35 onwards (two branches) but node 30 is not labelled and labelling starts later at node 33.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions