]> git.donarmstrong.com Git - ape.git/blob - R/ewLasso.R
final commit for ape 3.0-8
[ape.git] / R / ewLasso.R
1 ## ewLasso.R (2013-04-02)
2
3 ##   Lasso Tree
4
5 ## Copyright 2013 Andrei-Alin Popescu
6
7 ## This file is part of the R-package `ape'.
8 ## See the file ../COPYING for licensing issues.
9
10 ewLasso <- function(X, phy)
11 {
12     if (is.matrix(X)) X <- as.dist(X)
13     X[is.na(X)] <- -1
14     X[X < 0] <- -1
15     X[is.nan(X)] <- -1
16
17     if (is.rooted(phy)) {
18         phy <- unroot(phy)
19         warning("'phy' is rooted: it was unrooted for this operation")
20     }
21
22     N <- attr(X, "Size")
23     labels <- attr(X, "Labels")
24     if (is.null(labels)) labels <- as.character(1:N)
25     ans <- .C("ewLasso", as.double(X), as.integer(N),
26               as.integer(phy$edge[, 1]), as.integer(phy$edge[, 2]),
27               DUP = FALSE, NAOK = TRUE, PACKAGE = "ape")
28 }