[adegenet-commits] r361 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Jun 4 14:16:13 CEST 2009


Author: jombart
Date: 2009-06-04 14:16:12 +0200 (Thu, 04 Jun 2009)
New Revision: 361

Modified:
   pkg/R/haploSim.R
Log:
Corrected some bugs. 
Still stightly broken


Modified: pkg/R/haploSim.R
===================================================================
--- pkg/R/haploSim.R	2009-06-04 11:51:50 UTC (rev 360)
+++ pkg/R/haploSim.R	2009-06-04 12:16:12 UTC (rev 361)
@@ -26,7 +26,9 @@
     ## AUXILIARY FUNCTIONS ##
     ## generate sequence from scratch
     gen.seq <- function(){
-        return(sample(NUCL, size=seq.length, replace=TRUE))
+        res <- list(sample(NUCL, size=seq.length, replace=TRUE))
+        class(res) <- "DNAbin"
+        return(res)
     }
 
     ## create substitutions for defined SNPs
@@ -97,7 +99,8 @@
         nbDes <- length(newDates)
         if(nbDes==0) return(NULL) # stop if no suitable date
         newSeq <- lapply(1:nbDes, function(i) seq.dupli(seq)) # generate new sequences
-        newSeq <- Reduce(rbind, newSeq) # list DNAbin -> matrix DNAbin with nbDes rows
+        class(newSeq) <- "DNAbin" # lists of DNAbin vectors must also have class "DNAbin"
+        newSeq <- as.matrix(newSeq) # list DNAbin -> matrix DNAbin with nbDes rows
         rownames(newSeq) <- seqname.gen(nbDes) # find new labels for these new sequences
         res$seq <<- rbind(res$seq, newSeq) # append to general output
         res$dates <<- c(res$dates, newDates) # append to general output



More information about the adegenet-commits mailing list