]> git.donarmstrong.com Git - ape.git/commitdiff
adding del.gaps()
authorparadis <paradis@6e262413-ae40-0410-9e79-b911bd7a66b7>
Sun, 8 Jun 2008 06:46:38 +0000 (06:46 +0000)
committerparadis <paradis@6e262413-ae40-0410-9e79-b911bd7a66b7>
Sun, 8 Jun 2008 06:46:38 +0000 (06:46 +0000)
git-svn-id: https://svn.mpl.ird.fr/ape/dev/ape@32 6e262413-ae40-0410-9e79-b911bd7a66b7

Changes
DESCRIPTION
R/DNA.R
man/corPagel.Rd
man/del.gaps.Rd [new file with mode: 0644]

diff --git a/Changes b/Changes
index 05cbfab4053462414807edd72283904d7d2d8097..4aa9a918f92a3056f6a3ee439cd2b64a76f2042c 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,3 +1,13 @@
+               CHANGES IN APE VERSION 2.2-1
+
+
+NEW FEATURES
+
+    o The new function del.gaps() removes insertion gaps ("-") in a
+      set of DNA sequences.
+
+
+
                CHANGES IN APE VERSION 2.2
 
 
index c4bf8f7d03107a3cbd01802cda7f5e52a82aea23..6b2d89a65ac76fcabe030301a23776dcc8de3caa 100644 (file)
@@ -1,6 +1,6 @@
 Package: ape
-Version: 2.2
-Date: 2008-05-07
+Version: 2.2-1
+Date: 2008-06-08
 Title: Analyses of Phylogenetics and Evolution
 Author: Emmanuel Paradis, Ben Bolker, Julien Claude, Hoa Sien Cuong,
   Richard Desper, Benoit Durand, Julien Dutheil, Olivier Gascuel,
diff --git a/R/DNA.R b/R/DNA.R
index 2482511079bbb47748730709306285784997abbc..e51f252eb7b77421fad835d13ae7671ddae32d00 100644 (file)
--- a/R/DNA.R
+++ b/R/DNA.R
@@ -1,4 +1,4 @@
-## DNA.R (2008-04-24)
+## DNA.R (2008-06-08)
 
 ##   Manipulations and Comparisons of DNA Sequences
 
@@ -7,6 +7,27 @@
 ## This file is part of the R-package `ape'.
 ## See the file ../COPYING for licensing issues.
 
+del.gaps <- function(x)
+{
+    deleteGaps <- function(x) {
+        i <- which(x == 4)
+        x[-i]
+    }
+
+    if (class(x) != "DNAbin") x <- as.DNAbin(x)
+    if (is.matrix(x)) {
+        n <- dim(x)[1]
+        y <- vector("list", n)
+        for (i in 1:n) y[[i]] <- x[i, ]
+        x <- y
+        rm(y)
+    }
+    if (!is.list(x)) return(deleteGaps(x))
+    x <- lapply(x, deleteGaps)
+    class(x) <- "DNAbin"
+    x
+}
+
 as.alignment <- function(x)
 {
     if (is.list(x)) n <- length(x)
index 7248f65f25ef36afa1f43e88715b050a30aa9517..4509b4493ef0c7dc358aacb11f2801cc7d27795e 100644 (file)
@@ -35,7 +35,7 @@ corPagel(value, phy, form = ~1, fixed = FALSE)
 \value{
   an object of class \code{"corPagel"}, the coefficients from an object
   of this class, or the correlation matrix of an initialized object of
-  this class. In most situations, only \code{corPagel()} will be called
+  this class. In most situations, only \code{corPagel} will be called
   by the user.
 }
 \author{Emmanuel Paradis}
diff --git a/man/del.gaps.Rd b/man/del.gaps.Rd
new file mode 100644 (file)
index 0000000..3a22424
--- /dev/null
@@ -0,0 +1,31 @@
+\name{del.gaps}
+\alias{del.gaps}
+\title{
+  Delete Alignment Gaps in DNA Sequences
+}
+\usage{
+del.gaps(x)
+}
+\arguments{
+  \item{x}{a matrix, a list, or a vector containing the DNA sequences.}
+}
+\description{
+  This function removes the insertion gaps (\code{"-"}) in a sample of
+  DNA sequences.
+}
+\details{
+  The sequences can be either in \code{"DNAbin"} or in character format,
+  but the returned object is always of class \code{"DNAbin"}. If
+  \code{x} is a vector, then a vector is returned; if it is a list or a
+  matrix, then a list is returned.
+}
+\value{
+  A vector (if there is only one input sequence) or a list of class
+  \code{"DNAbin"}.
+}
+\author{Emmanuel Paradis \email{Emmanuel.Paradis@ird.fr}}
+\seealso{
+  \code{\link{base.freq}}, \code{\link{GC.content}},
+  \code{\link{theta.s}}, \code{\link{nuc.div}}, \code{\link{seg.sites}}
+}
+\keyword{univar}