plot(mon1)
example(monmonier)
rm(monmonier)
rm(plot.monmonier)
save.image()
example(monmonier)
?monmonier
     plot(mon1,x1,met="greylevel",csize=.6)

     data(sim2pop)

     gab <- chooseCN(sim2pop@other$xy,ask=FALSE,type=2)

     pca1 <- dudi.pca(sim2pop@tab,scale=FALSE, scannf=FALSE, nf=1)

     gab <- chooseCN(sim2pop@other$xy,ask=FALSE,type=2)

     mon1 <- monmonier(sim2pop@other$xy,dist(pca1$l1[,1]),gab,scanthres=FALSE)

plot(mon1,var=pca1$l1[,1])
    
plot(mon1,var=pca1$l1[,1])
     temp <- sim2pop@pop
     levels(temp) <- c(17,19)
     temp <- as.numeric(as.character(temp))
     plot(mon1)
     points(sim2pop@other$xy,pch=temp,cex=2)
     legend("topright",leg=c("Pop A", "Pop B"),pch=c(17,19))

  xy <- matrix(runif(120,0,10), ncol=2)
     x1 <- rnorm(60)
     x1[xy[,2] > 5] <- x1[xy[,2] > 5]+3
     cn1 <- chooseCN(xy,type=1,ask=FALSE)
     mon1 <- optimize.monmonier(xy,dist(x1)^2,cn1,ntry=10)

     # graphics
     plot(mon1,x1,met="greylevel",csize=.6)

10
plot(mon1)
     mon1 <- optimize.monmonier(xy,dist(x1)^2,cn1,ntry=10)

d
plot(mon1)
plot(mon1,x1)
 x2 <- rnorm(60)
     sel <- (xy[,1]>3.5 & xy[,2]>3.5 & xy[,1]<6.5 & xy[,2]<6.5)
     x2[sel] <- x2[sel]+4
     cn2 <- chooseCN(xy,type=1,ask=FALSE)
     mon2 <- optimize.monmonier(xy,dist(x2)^2,cn2,ntry=10)

     # graphics
     plot(mon2,x2,method="greylevel",add.arr=FALSE,bwd=6,col="red",csize=.5)
     ## End(Not run)
d
     plot(mon2,x2,method="greylevel",add.arr=FALSE,bwd=6,col="red",csize=.5)

 x2 <- rnorm(60)
     sel <- (xy[,1]>3.5 & xy[,2]>3.5 & xy[,1]<6.5 & xy[,2]<6.5)
     x2[sel] <- x2[sel]+4
   
     mon2 <- optimize.monmonier(xy,dist(x2)^2,cn2,ntry=10)

d
     plot(mon2,x2,method="greylevel",add.arr=FALSE,bwd=6,col="red",csize=.5)

q()
y
plot(mon1,x1)
orig_coords <- read.table("/home/master/dev/adegenet/pkg/misc/bug-report.1.2-2.03/boot_coord.7.input")
numpops <- length(orig_coords[,1])

coords <- orig_coords
numpops <- length(coords[,1])
Da <- read.table("/home/master/dev/adegenet/pkg/misc/bug-report.1.2-2.03/boot_dist.7.input")
Da <- as.dist(Da)

	# Calc monmonier barrier
	cn <- chooseCN(coords, ask=FALSE, type=1)
	mon <- monmonier(coords, Da, cn, threshold=0, nrun=1, skip.local.diff = rep(1, 1)) #threshold is arbitrarily set at 0
plot(mon)
plot(mon,add.arr=FALSE)
	mon <- optimize.monmonier(coords, Da, cn, threshold=0)

q()
n
boot_coord_filename <- "boot_coord.21.input"
boot_dist_filename <- "boot_dist.21.input"


library(spdep)
library(ade4)
library(adegenet)
library(gplots)
install.packages("gplots")

coords <- read.table(boot_coord_filename)
Da <- read.table(boot_dist_filename)
Da <- as.dist(Da)
cn <- chooseCN(coords, ask=FALSE, type=1, plot.nb = FALSE)

mon <- monmonier(coords, Da, cn, threshold=NULL, scanthres = 0, nrun=1) #threshold is arbitrarily set at 0

save.image()
?debug
debug(checkNext)
traceback()
traceback(monmonier)
mon <- monmonier(coords, Da, cn, threshold=NULL, scanthres = 0, nrun=1) #threshold is arbitrarily set at 0

traceback()
source("/home/master/dev/adegenet/pkg/R/monmonier.R")
mon <- monmonier(coords, Da, cn, threshold=NULL, scanthres = 0, nrun=1) #threshold is arbitrarily set at 0

debug(monmonier)
mon <- monmonier(coords, Da, cn, threshold=NULL, scanthres = 0, nrun=1) #threshold is arbitrarily set at 0

> debug(checkNext)
mon <- monmonier(coords, Da, cn, threshold=NULL, scanthres = 0, nrun=1) #threshold is arbitrarily set at 0

mon <- monmonier(coords, Da, cn, threshold=NULL, scanthres = 0, nrun=1) #threshold is arbitrarily set at 0

debug(checkNext)
allSeg
s1
curDir
prevSeg
debug(checkNext)
?ifelse
ifelse(1==1,1,2)
ifelse(2==1,1,2)
ifelse(2==1,1,2)
curDir=1L
curDir
is.integer(curDir)
otherDir <- ifelse(curDir==1L, 2, 1)
paste("dir",otherDir,"1-2",sep="")
curDir=2L
otherDir <- ifelse(curDir==1L, 2, 1)
paste("dir",otherDir,"1-2",sep="")
source("/home/master/dev/adegenet/pkg/R/monmonier.R")
paste("dir",otherDir,"1-2",sep="")
undebug(monmonier)
mon <- monmonier(coords, Da, cn, threshold=NULL, scanthres = 0, nrun=1) #threshold is arbitrarily set at 0
p
source("/home/master/dev/adegenet/pkg/R/monmonier.R")
mon <- monmonier(coords, Da, cn, threshold=NULL, scanthres = 0, nrun=1) #threshold is arbitrarily set at 0
plot(mon)
example(monmonier)
?monmonier
     data(sim2pop)

 gab <- chooseCN(sim2pop@other$xy,ask=FALSE,type=2)

     # filter random noise 
     pca1 <- dudi.pca(sim2pop@tab,scale=FALSE, scannf=FALSE, nf=1)

     mon1 <- monmonier(sim2pop@other$xy,dist(pca1$l1[,1]),gab,scanthres=FALSE)

     pca1 <- dudi.pca(sim2pop@tab,scale=FALSE, scannf=FALSE, nf=1)

     mon1 <- monmonier(sim2pop@other$xy,dist(pca1$l1[,1]),gab,scanthres=FALSE)

plot(mon1)
 plot(mon1,var=pca1$l1[,1])
     temp <- sim2pop@pop
     levels(temp) <- c(17,19)
     temp <- as.numeric(as.character(temp))
     plot(mon1)
     points(sim2pop@other$xy,pch=temp,cex=2)
     legend("topright",leg=c("Pop A", "Pop B"),pch=c(17,19))

 xy <- matrix(runif(120,0,10), ncol=2)
     x1 <- rnorm(60)
     x1[xy[,2] > 5] <- x1[xy[,2] > 5]+3
     cn1 <- chooseCN(xy,type=1,ask=FALSE)
     mon1 <- optimize.monmonier(xy,dist(x1)^2,cn1,ntry=10)

d
plot(mon1,x1)
  x2 <- rnorm(60)
     sel <- (xy[,1]>3.5 & xy[,2]>3.5 & xy[,1]<6.5 & xy[,2]<6.5)
     x2[sel] <- x2[sel]+4
     cn2 <- chooseCN(xy,type=1,ask=FALSE)
     mon2 <- optimize.monmonier(xy,dist(x2)^2,cn2,ntry=10)

d
     plot(mon2,x2,method="greylevel",add.arr=FALSE,bwd=6,col="red",csize=.5)

 plot(mon2,x2,method="greylevel",bwd=6,col="red",csize=.5)
 load(system.file("files/mondata2.rda",package="adegenet"))
     cn2 <- chooseCN(mondata2$xy,type=1,ask=FALSE)
     mon2 <- monmonier(mondata2$xy,dist(mondata2$x2),cn2,threshold=2)
     plot(mon2,mondata2$x2,method="greylevel",add.arr=FALSE,bwd=6,col="red",csize=.5)

 load(system.file("files/mondata2.rda",package="adegenet"))
     cn2 <- chooseCN(mondata2$xy,type=1,ask=FALSE)
     mon2 <- monmonier(mondata2$xy,dist(mondata2$x2),cn2,threshold=2)
     plot(mon2,mondata2$x2,method="greylevel",bwd=6,col="red",csize=.5)
  cn2 <- chooseCN(xy,type=1,ask=FALSE)
 mon2 <- optimize.monmonier(xy,dist(x2)^2,cn2,ntry=10)
d
plot(mon2)
q()
y
