Learn R Programming

pctax (version 0.1.7)

drop_tips_update: Drop Tips and Update a Phylogenetic Tree

Description

This function iteratively removes specified tips (or tips matching a pattern) from a phylogenetic tree without collapsing internal nodes or singleton nodes.

Usage

drop_tips_update(tr, drop_name, pattern = NULL)

Value

A phylo object with specified tips removed.

Arguments

tr

A phylogenetic tree of class phylo.

drop_name

A character vector of tip or node names to drop. If missing and pattern is provided, names matching the pattern will be dropped.

pattern

An optional regular expression pattern to match tip or node labels for dropping.

Examples

Run this code
if (requireNamespace("ape")) {
  library(ape)
  tr <- rtree(10)
  plot(tr)
  # Drop tips containing "t1" or "t2" in their label
  tr2 <- drop_tips_update(tr, pattern = "t1|t2")
  plot(tr2)

  # Alternatively, specify tips directly
  tr3 <- drop_tips_update(tr, drop_name = c("t3", "t5"))
  plot(tr3)
}

Run the code above in your browser using DataLab