This function retrieves the ancestors of a specified node (clone) in a tree structure. It calculates the shortest path from the root node to the target node and returns the names of all ancestor nodes (excluding the target node itself).

get_clone_ancestors(tree, node)

Arguments

tree

An igraph tree object representing the phylogenetic structure

node

The target node for which to find ancestors

Value

A character vector containing the names of the ancestor nodes, ordered from the root to the immediate parent of the target node.

Details

The function:

  1. Identifies the root node (assumes first vertex is root)

  2. Finds shortest path from root to target node

  3. Returns names of all nodes in the path

Note

Assumes the tree is properly rooted with root node as first vertex

Examples

if (FALSE) { # \dontrun{
library(igraph)
# Create a simple tree
tree <- make_tree(3, 2)
V(tree)$name <- c("root", "A", "B")

# Get ancestors of node "B"
ancestors <- get_clone_ancestors(tree, "B")
# Returns: c("root", "B")
} # }