R: Calculate path lengths from the tree root

getPathLengths {alakazam} | R Documentation

## Calculate path lengths from the tree root

### Description

`getPathLengths` calculates the unweighted (number of steps) and weighted (distance) path lengths from the root of a lineage tree.

### Usage

    getPathLengths(graph, root = "Germline", field = NULL,
      exclude = NULL)

### Arguments

`graph` | igraph object containing an annotated lineage tree.
`root` | name of the root (germline) node.
`field` | annotation field to use for exclusion of nodes from step count.
`exclude` | annotation values specifying which nodes to exclude from step count. If `NULL` consider all nodes. This does not affect the weighted (distance) path length calculation.

### Value

A data.frame with columns:

- `NAME`: node name

- `STEPS`: path length as the number of nodes traversed

- `DISTANCE`: path length as the sum of edge weights

### See Also

See buildPhylipLineage for generating input trees.

### Examples

    # Define example graph
    graph <- ExampleTrees[[24]]

    # Consider all nodes
    getPathLengths(graph, root="Germline")

    # Exclude nodes without an isotype annotation from step count
    getPathLengths(graph, root="Germline", field="ISOTYPE", exclude=NA)

[Package alakazam version 0.3.0 Index]