[adegenet-commits] r817 - in pkg: R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Feb 21 19:17:19 CET 2011


Author: jombart
Date: 2011-02-21 19:17:19 +0100 (Mon, 21 Feb 2011)
New Revision: 817

Modified:
   pkg/R/SNPbin.R
   pkg/man/SNPbin.Rd
   pkg/man/genlight.Rd
Log:
Added doc for rbind, c, cbind procedures for SNPbin and genlight objects.


Modified: pkg/R/SNPbin.R
===================================================================
--- pkg/R/SNPbin.R	2011-02-21 16:26:14 UTC (rev 816)
+++ pkg/R/SNPbin.R	2011-02-21 18:17:19 UTC (rev 817)
@@ -660,6 +660,7 @@
     res <- new("genlight",res)
 
     ## handle loc.names, alleles, etc. ##
+    indNames(res) <- indNames(myList[[1]])
     locNames(res) <- unlist(lapply(myList, locNames))
     alleles(res) <- unlist(lapply(myList, alleles))
     pop(res) <- pop(myList[[1]])

Modified: pkg/man/SNPbin.Rd
===================================================================
--- pkg/man/SNPbin.Rd	2011-02-21 16:26:14 UTC (rev 816)
+++ pkg/man/SNPbin.Rd	2011-02-21 18:17:19 UTC (rev 817)
@@ -18,6 +18,8 @@
 \alias{NA.posi,SNPbin-method}
 \alias{,SNPbin-method}
 \alias{,SNPbin-method}
+\alias{cbind.SNPbin}
+\alias{c.SNPbin}
 % \alias{,SNPbin-method}
 % \alias{,SNPbin-method}
 % \alias{,SNPbin-method}
@@ -45,13 +47,13 @@
   
   \describe{
     \item{\code{snp}}{a vector of integers or numeric giving numbers of
-    copies of the second alleles for each locus. If only one unnamed
-    argument is provided to 'new', it is considered as this one.}
+      copies of the second alleles for each locus. If only one unnamed
+      argument is provided to 'new', it is considered as this one.}
     \item{\code{ploidy}}{an integer indicating the ploidy of the
-    genotype; if not provided, will be guessed from the data (as the
-    maximum from the 'snp' input vector).}
+      genotype; if not provided, will be guessed from the data (as the
+      maximum from the 'snp' input vector).}
     \item{\code{label}}{an optional character string serving as a label
-    for the genotype.}
+      for the genotype.}
   }
 }
 \section{Slots}{
@@ -64,19 +66,19 @@
     \item{\code{n.loc}:}{an integer indicating the number of SNPs of the
       genotype.}
     \item{\code{NA.posi}:}{a vector of integer giving the position of
-    missing data.}
+      missing data.}
     \item{\code{label}:}{an optional character string serving as a label
       for the genotype..}
     \item{\code{ploidy}:}{an integer indicating the ploidy of the genotype.}
+  }
 }
-}
 \section{Methods}{
   Here is a list of methods available for \code{SNPbin} objects. Most of
-    these methods are accessors, that is, functions which are used to
-    retrieve the content of the object. Specific manpages can exist for
-    accessors with more than one argument. These are indicated by a '*'
-    symbol next to the method's name. This list also contains methods
-    for conversion from \code{SNPbin} to other classes.
+  these methods are accessors, that is, functions which are used to
+  retrieve the content of the object. Specific manpages can exist for
+  accessors with more than one argument. These are indicated by a '*'
+  symbol next to the method's name. This list also contains methods
+  for conversion from \code{SNPbin} to other classes.
   \describe{
     \item{[}{\code{signature(x = "SNPbin")}: usual method to subset
       objects in R. The argument indicates how SNPs are to be
@@ -90,17 +92,21 @@
     \item{nLoc}{\code{signature(x = "SNPbin")}: returns the number of
       SNPs in the object.}
     \item{names}{\code{signature(x = "SNPbin")}: returns the names of
-    the slots of the object.}
+      the slots of the object.}
     \item{ploidy}{\code{signature(x = "SNPbin")}: returns the ploidy of
-    the genotype.}
+      the genotype.}
     \item{as.integer}{\code{signature(x = "SNPbin")}: converts a
-    \code{SNPbin} object to a vector of integers. The S4 method 'as' can
-    be used as well (e.g. as(x, "integer")).}
+      \code{SNPbin} object to a vector of integers. The S4 method 'as' can
+      be used as well (e.g. as(x, "integer")).}
+    \item{cbind}{\code{signature(x = "SNPbin")}: merges genotyping of
+      the same individual at different SNPs (all stored as
+      \linkS4class{SNPbin} objects) into a single \linkS4class{SNPbin}.}
+    \item{c}{\code{signature(x = "SNPbin")}: same as cbind.SNPbin.}
   }
 }
 \author{Thibaut Jombart (\email{t.jombart at imperial.ac.uk})}
 \seealso{
- Related class:\cr
+  Related class:\cr
   -  \code{\linkS4class{genlight}}, for storing multiple binary SNP
   genotypes. \cr
   -  \code{\linkS4class{genind}}, for storing other types of genetic markers. \cr
@@ -139,5 +145,17 @@
 print(object.size(dat), unit="auto")
 print(object.size(x), unit="auto")
 object.size(dat)/object.size(x) # EFFICIENCY OF CONVERSION
+
+
+#### c, cbind ####
+a <- new("SNPbin", c(1,1,1,1,1))
+b <- new("SNPbin", c(0,0,0,0,0))
+a
+b
+ab <- c(a,b)
+ab
+identical(c(a,b),cbind(a,b))
+as.integer(ab)
+
 }
 \keyword{classes}

Modified: pkg/man/genlight.Rd
===================================================================
--- pkg/man/genlight.Rd	2011-02-21 16:26:14 UTC (rev 816)
+++ pkg/man/genlight.Rd	2011-02-21 18:17:19 UTC (rev 817)
@@ -32,6 +32,8 @@
 \alias{as,genlight,list-method}
 \alias{coerce,genlight,list-method}
 \alias{as.list.genlight}
+\alias{cbind.genlight}
+\alias{rbind.genlight}
 % \alias{,genlight-method}
 % \alias{,genlight-method}
 % \alias{,genlight-method}
@@ -56,7 +58,6 @@
 \section{Objects from the class genlight}{
   \code{genlight} objects can be created by calls to \code{new("genlight",
     ...)}, where '...' can be the following arguments:
-  
   \describe{
     \item{\code{gen}}{input genotypes, where each genotype is coded as a
       vector of numbers of the second allele. If a list, each slot of the
@@ -157,6 +158,12 @@
       \code{genlight} object into a list of genotypes coded as vector of
       integers (numbers of second allele). The S4 method 'as' can be
       used as well (e.g. as(x, "list")).}
+    \item{cbind}{\code{signature(x = "genlight")}: merges several
+      \linkS4class{genlight} objects by column, i.e. regroups data of
+      identical individuals genotyped for different SNPs.}
+    \item{rbind}{\code{signature(x = "genlight")}: merges several
+      \linkS4class{genlight} objects by row, i.e. regroups data of
+      different individuals genotyped for the same SNPs.}
   }
 }
 \author{Thibaut Jombart (\email{t.jombart at imperial.ac.uk})}
@@ -207,5 +214,17 @@
 x
 print(object.size(x), unit="au") # size of the genlight object
 object.size(dat)/object.size(x) # conversion efficiency
+
+
+#### cbind, rbind ####
+a <- new("genlight", list(toto=rep(1,10), tata=rep(c(0,1), each=5), titi=c(NA, rep(1,9)) ))
+
+ara <- rbind(a,a)
+ara
+as.matrix(ara)
+
+aca <- cbind(a,a)
+aca
+as.matrix(aca)
 }
 \keyword{classes}



More information about the adegenet-commits mailing list