R: Determine if a set of tips is monophyletic.

is_monophyletic {castor} | R Documentation

## Determine if a set of tips is monophyletic.

### Description

Given a rooted phylogenetic tree and a set of focal tips, this function determines whether the tips form a monophyletic group.

### Usage

    is_monophyletic(tree, focal_tips, check_input=TRUE)

### Arguments

`tree` | A rooted tree of class "phylo". The root is assumed to be the unique node with no incoming edge.
`focal_tips` | Either an integer vector or a character vector, listing the tips to be checked for monophyly. If an integer vector, it should list tip indices (i.e. from 1 to Ntips). If a character vector, it should list tip names; in that case `tree$tip.label` must exist.
`check_input` | Logical, whether to perform basic validations of the input data. If you know for certain that your input is valid, you can set this to `FALSE` to reduce computation time.

### Details

This function first finds the most recent common ancestor (MRCA) of the focal tips, and then checks if all tips descending from that MRCA fall within the focal tip set.

### Value

A logical, indicating whether the focal tips form a monophyletic set.

### Author(s)

Stilianos Louca

### See Also

`get_mrca_of_set`

### Examples

    # generate random tree
    Ntips = 100
    tree  = generate_random_tree(list(birth_rate_intercept=1),max_tips=Ntips)$tree

    # pick a random subset of focal tips
    focal_tips = which(sample.int(2,size=Ntips,replace=TRUE)==1)

    # check if focal tips form a monophyletic group
    is_monophyletic(tree, focal_tips)

[Package castor version 1.3.4 Index]