[adegenet-commits] r613 - pkg/R pkg/man www
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed May 5 17:25:33 CEST 2010
Author: jombart
Date: 2010-05-05 17:25:33 +0200 (Wed, 05 May 2010)
New Revision: 613
Modified:
pkg/R/chooseCN.R
pkg/man/chooseCN.Rd
www/download.html
Log:
Patch to chooseCN.
Modified: pkg/R/chooseCN.R
===================================================================
--- pkg/R/chooseCN.R 2010-05-04 12:40:24 UTC (rev 612)
+++ pkg/R/chooseCN.R 2010-05-05 15:25:33 UTC (rev 613)
@@ -8,6 +8,7 @@
if(ncol(xy) != 2) stop("xy does not have two columns.")
if(any(is.na(xy))) stop("NA entries in xy.")
result.type <- tolower(result.type)
+ if(is.null(type) & !ask) stop("Non-interactive mode but no graph chosen; please provide a value for 'type' argument.")
if(!require(spdep, quiet=TRUE)) stop("spdep library is required.")
@@ -38,16 +39,14 @@
}
## check for uniqueness of coordinates
- x <- xy[,1]
- y <- xy[,2]
- temp <- table(x,y)
- if(any(temp>1) & (!is.null(type) && !type %in% c(5,7))){ # coords need not be unique if type==5 or 7
- xy <- jitter(xy)
- warning("Random noise was added to xy as duplicated coordinates existed.")
+ if(any(xyTable(xy)$number>1)){ # if duplicate coords
+ DUPLICATE.XY <- TRUE
+ } else {
+ DUPLICATE.XY <- FALSE
}
- if(is.null(type) & !ask) { type <- 1 }
+ ## if(is.null(type) & !ask) { type <- 1 }
### begin large while ###
chooseAgain <- TRUE
@@ -74,10 +73,22 @@
type <- as.integer(readLines(n = 1))
temp <- type < 1 |type > 7
if(temp) cat("\nWrong answer\n")
+
+ if(type %in% 1:4 & DUPLICATE.XY){
+ cat("\n\n== PROBLEM DETECTED ==")
+ cat("\nDuplicate locations detected\nPlease choose another graph (5-7) or add random noise to locations (see ?jitter).\n")
+ temp <- TRUE
+ }
+
} # end while
}
##
+ ## warning about duplicate xy coords
+ if(type %in% 1:4 & DUPLICATE.XY){
+ stop("Duplicate locations detected and incompatible with graph type 1-4.\nPlease choose another graph (5-7) or add random noise to locations (see ?jitter).")
+ }
+
## graph types
## type 1: Delaunay
if(type==1){
Modified: pkg/man/chooseCN.Rd
===================================================================
--- pkg/man/chooseCN.Rd 2010-05-04 12:40:24 UTC (rev 612)
+++ pkg/man/chooseCN.Rd 2010-05-05 15:25:33 UTC (rev 613)
@@ -7,7 +7,8 @@
from 6 types of graph and one additional weighting scheme.
\code{chooseCN} calls functions from appropriate packages, handles
non-unique coordinates and returns a connection network either with
- classe \code{nb} or \code{listw}.
+ classe \code{nb} or \code{listw}. For graph types 1-4, duplicated
+ locations are not accepted and will issue an error.
}
\usage{
chooseCN(xy, ask = TRUE, type = NULL, result.type = "nb", d1 = NULL,
@@ -53,7 +54,11 @@
neighbours, but the spatial weights are directly proportional to the
inversed spatial distances.\cr
Also not that in this case, the output of the function is always a
- \code{listw} object, even if \code{nb} was requested.
+ \code{listw} object, even if \code{nb} was requested.\cr
+
+ The choice of the connection network has been discuted on the adegenet
+ forum. Please search the archives from adegenet website (section
+ 'contact') using 'graph' as keyword.
}
\value{Returns a connection network having the class \code{nb} or
\code{listw}. The xy coordinates are passed as attribute to the
Modified: www/download.html
===================================================================
--- www/download.html 2010-05-04 12:40:24 UTC (rev 612)
+++ www/download.html 2010-05-05 15:25:33 UTC (rev 613)
@@ -45,11 +45,20 @@
type <span style="font-family: monospace;">source("[your-patch-file.R]")</span>
to
use
-a patch.<br>
+a
+patch.<br>
- <a href="files/patches/loadingplot.R"><span
style="font-family: monospace;">loadingplot.R</span></a>: a few checks
added when the 'at' argument the specified<br>
+- <a href="files/patches/chooseCN.R"><span
+ style="font-family: monospace;"><span
+ style="text-decoration: underline;">chooseCN</span></span></a><a
+ href="files/patches/chooseCN.R"><span style="font-family: monospace;">.R</span></a>:
+new checks
+about duplicated locations, which are problematic with some types of
+graph<br>
<br>
+<br>
<img alt="" src="images/bullet.png" style="width: 10px; height: 10px;">
<span style="font-weight: bold;">Older
versions</span>:<br>
More information about the adegenet-commits
mailing list