[adegenet-commits] r448 - in pkg: R misc/bug-report.1.2-3.02
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Oct 14 12:32:15 CEST 2009
Author: jombart
Date: 2009-10-14 12:32:14 +0200 (Wed, 14 Oct 2009)
New Revision: 448
Added:
pkg/misc/bug-report.1.2-3.02/code.R
Modified:
pkg/R/propShared.R
Log:
Fixed an issue with propShared : failure when alleles not coded as integers.
Was part of bug 1.2-3.02.
Modified: pkg/R/propShared.R
===================================================================
--- pkg/R/propShared.R 2009-10-14 09:51:58 UTC (rev 447)
+++ pkg/R/propShared.R 2009-10-14 10:32:14 UTC (rev 448)
@@ -8,6 +8,9 @@
propShared <- function(obj){
x <- obj
+ ## convert alleles to integers (alleles may be characters)
+ x at all.names <- lapply(x at all.names, function(v) 1:length(v))
+
## check that this is a valid genind
if(!inherits(x,"genind")) stop("obj must be a genind object.")
invisible(validObject(x))
@@ -42,6 +45,7 @@
alleleSize <- max(apply(temp,1:2,nchar))/2
mat1 <- apply(temp, 1:2, substr, 1, alleleSize)
mat2 <- apply(temp, 1:2, substr, alleleSize+1, alleleSize*2)
+
matAll <- cbind(mat1,mat2)
matAll <- apply(matAll,1:2,as.integer)
matAll[is.na(matAll)] <- 0
Added: pkg/misc/bug-report.1.2-3.02/code.R
===================================================================
--- pkg/misc/bug-report.1.2-3.02/code.R (rev 0)
+++ pkg/misc/bug-report.1.2-3.02/code.R 2009-10-14 10:32:14 UTC (rev 448)
@@ -0,0 +1,20 @@
+## PROBLEM 1: ISSUE WITH NON-NUMERIC ALLELES
+
+## This simple example already triggers a problem
+df=matrix(c('a/b','a/a','a/b','x/x','NA','x/y'),nrow=2)
+colnames(df)=paste("locus",1:3,sep=".")
+rownames(df)=1:2
+df # looks ok
+
+toto=df2genind(df, sep="/", ploidy=2)
+toto
+
+## here is the issue
+propShared(toto)
+genind2df(toto,sep="/")
+
+
+
+
+
+## PROBLEM 2:...
More information about the adegenet-commits
mailing list