1 ## coalescent.intervals.R (2002-09-12)
3 ## Constructs objects with information on coalescent intervals
5 ## Copyright 2002 Korbinian Strimmer
7 ## This file is part of the R-package `ape'.
8 ## See the file ../COPYING for licensing issues.
10 coalescent.intervals <- function(x) UseMethod("coalescent.intervals")
12 # set up coalescent interval object (from NH tree)
13 coalescent.intervals.phylo <- function(x)
15 if (class(x) != "phylo") stop("object \"x\" is not of class \"phylo\"")
17 # ensure we have a BINARY tree
18 if (!is.binary.tree(x)) stop("object \"x\" is not a binary tree")
19 # ordered branching times
20 t <- sort(branching.times(x))
26 for (i in 2:lt) w[i] <- t[i] - t[i - 1]
28 l <- (lt+1):2 # number of lineages
35 class(obj) <- "coalescentIntervals"
40 # set up coalescent interval object from vector of interval length
41 coalescent.intervals.default <- function(x)
43 if (!is.vector(x)) stop("argument \"x\" is not a vector of interval lengths")
45 # x = list of the widths of each interval
47 l <- (lt+1):2 # number of lineages at the beginning of each interval
54 class(obj) <- "coalescentIntervals"