R: Identify vertices retained when leaves are dropped

KeptVerts {TreeTools} | R Documentation

## Identify vertices retained when leaves are dropped

### Description

Identify vertices retained when leaves are dropped

### Usage

    KeptVerts(tree, keptTips, tipLabels = TipLabels(tree))

    ## S3 method for class 'phylo'
    KeptVerts(tree, keptTips, tipLabels = TipLabels(tree))

    ## S3 method for class 'numeric'
    KeptVerts(tree, keptTips, tipLabels = TipLabels(tree))

### Arguments

`tree` | Original tree of class `phylo`, in `Preorder`.
`keptTips` | Either: a logical vector stating whether each leaf should be retained, in a sequence corresponding to `tree[["tip.label"]]`; or a character vector listing the leaf labels to retain; or a numeric vector listing the indices of leaves to retain.
`tipLabels` | Optional character vector naming the leaves of `tree`, if `keptTips` is not logical. Inferred from `tree` if unspecified.

### Author(s)

Martin R. Smith (martin.smith@durham.ac.uk)

### See Also

Other tree manipulation: `AddTip()`, `CollapseNode()`, `ConsensusWithout()`, `DropTip()`, `EnforceOutgroup()`, `ImposeConstraint()`, `KeptPaths()`, `LeafLabelInterchange()`, `MakeTreeBinary()`, `RenumberTips()`, `RenumberTree()`, `Renumber()`, `RootTree()`, `SingleTaxonTree()`, `SortTree()`, `Subtree()`

### Examples

    master <- BalancedTree(12)
    master <- Preorder(master) # Nodes must be listed in Preorder sequence
    plot(master)
    nodelabels()

    allTips <- master[["tip.label"]]
    keptTips <- sample(allTips, 8)
    plot(KeepTip(master, keptTips))
    kept <- KeptVerts(master, allTips %in% keptTips)

    map <- which(kept)
    # Node `i` in the reduced tree corresponds to node `map[i]` in the original.

[Package TreeTools version 1.7.2 Index]