Collapse by range id

Collapse by range id

Introduction

COLLAPSE template are used to collapse branches.

Typically, The user merges branches A and B by folding them at their most recent common ancestor (MRCA). However, it is normally hard for users to declare the MRCA node directly. The node name is usually generated automatically by software rather than specified by the user when building the phylogenetic tree. Some programs do not even generate the node name.

This section has taken these complicated cases into account, and provide the corresponding solution, so that users can easily prepare the input data.

Range ID

This basic grammar for range id is written as: branch_A|branch_B.

This section provides an example of how to collapse branches using dataset 1 (refer to the Dataset for detail information) document for detailed information). Users can download the data locally from the provided link above. The files are read using a relative path in this document, so please adjust the path based on actual situation.

The first step is to load the newick format tree file tree_of_itol_templates.tree and its corresponding metadata template_groups.

library(itol.toolkit)
tree <- system.file("extdata",
                    "tree_of_itol_templates.tree",
                    package = "itol.toolkit")
data("template_groups")

Suppose that the user wants to collapse DATASET_SIMPLEBAR and DATASET_MULTIBAR into one branch; DATASET_TEXT and LABELS into another branch;DATASET_ALIGNMENT, DATASET_CONNECTIONS, DATASET_IMAGE and POPUP_INFO which belong to advanced visualization into one branch:

range_ids <- c("DATASET_SIMPLEBAR|DATASET_MULTIBAR",
               "DATASET_TEXT|LABELS",
               "DATASET_CONNECTIONS|POPUP_INFO")
unit_1 <- create_unit(data = range_ids, 
                      key = "E001_collapse_1", 
                      type = "COLLAPSE", 
                      tree = tree)
write_unit(unit_1,
           paste0(getwd(),"/E001_collapse_1.txt"))

While the first two sets of folded branches are relatively simple to define because no other branches exist between them, the third set of folded branches is slightly complex, requiring the user to select the two branches with the longest spacing among the four to accurately describe the extent to be folded. Writing the code as DATASET_ALIGNMENT | POPUP_INFO may result in the omission of the DATASET_CONNECTIONS branch, because the branch does not belong to MCRA of DATASET_ALIGNMENT and POPUP_INFO.

Because the process of defining branches is very cumbersome and requires manual judgment, this function is not used frequently in the 23 templates in iTOL v6.

Visit

# collapse