File: ewLasso.R

package info (click to toggle)
r-cran-ape 5.8-1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,676 kB
  • sloc: ansic: 7,676; cpp: 116; sh: 17; makefile: 2
file content (28 lines) | stat: -rw-r--r-- 703 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
## ewLasso.R (2013-04-02)

##   Lasso Tree

## Copyright 2013 Andrei-Alin Popescu

## This file is part of the R-package `ape'.
## See the file ../COPYING for licensing issues.

ewLasso <- function(X, phy)
{
    if (is.matrix(X)) X <- as.dist(X)
    X[is.na(X)] <- -1
    X[X < 0] <- -1
    X[is.nan(X)] <- -1

    if (is.rooted(phy)) {
        phy <- unroot(phy)
        warning("'phy' is rooted: it was unrooted for this operation")
    }

    N <- attr(X, "Size")
    labels <- attr(X, "Labels")
    if (is.null(labels)) labels <- as.character(1:N)
    ans <- .C(C_ewLasso, as.double(X), as.integer(N),
              as.integer(phy$edge[, 1]), as.integer(phy$edge[, 2]),
              NAOK = TRUE)
}