From 0eb732cf743bc38c934b860fc6df60aa248b3034 Mon Sep 17 00:00:00 2001 From: paradis Date: Sun, 8 Jun 2008 06:46:38 +0000 Subject: [PATCH] adding del.gaps() git-svn-id: https://svn.mpl.ird.fr/ape/dev/ape@32 6e262413-ae40-0410-9e79-b911bd7a66b7 --- Changes | 10 ++++++++++ DESCRIPTION | 4 ++-- R/DNA.R | 23 ++++++++++++++++++++++- man/corPagel.Rd | 2 +- man/del.gaps.Rd | 31 +++++++++++++++++++++++++++++++ 5 files changed, 66 insertions(+), 4 deletions(-) create mode 100644 man/del.gaps.Rd diff --git a/Changes b/Changes index 05cbfab..4aa9a91 100644 --- 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 diff --git a/DESCRIPTION b/DESCRIPTION index c4bf8f7..6b2d89a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 2482511..e51f252 100644 --- 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) diff --git a/man/corPagel.Rd b/man/corPagel.Rd index 7248f65..4509b44 100644 --- a/man/corPagel.Rd +++ b/man/corPagel.Rd @@ -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 index 0000000..3a22424 --- /dev/null +++ b/man/del.gaps.Rd @@ -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} -- 2.39.2