Skip to content

Commit

Permalink
Changed win.ia and samp.ia to use bitwise.IA by default.
Browse files Browse the repository at this point in the history
  • Loading branch information
JonahBrooks committed Jul 27, 2015
1 parent ffffaca commit ef81e7b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 42 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: poppr
Type: Package
Title: Genetic Analysis of Populations with Mixed Reproduction
Version: 2.0.0.99-68
Version: 2.0.0.99-69
Date: 2015-07-27
Authors@R: c(person(c("Zhian", "N."), "Kamvar", role = c("cre", "aut"),
email = "kamvarz@science.oregonstate.edu"),
Expand Down
54 changes: 13 additions & 41 deletions R/bitwise.r
Original file line number Diff line number Diff line change
Expand Up @@ -424,36 +424,20 @@ win.ia <- function(x, window = 100L, min.snps = 3L, threads = 1L, quiet = FALSE)
} else {
xpos <- seq(nLoc(x))
}
diploid <- TRUE # Use this line when bitwise.IA works all(ploidy(x) == 2)
missing <- FALSE # any(vapply(x@gen, function(i) length(i@NA.posi) > 0, logical(1)))
nwin <- ceiling(max(xpos)/window)
winmat <- matrix(window*1:nwin, nrow = nwin, ncol = 2)
winmat[, 1] <- winmat[, 1] - window + 1
res_mat <- vector(mode = "numeric", length = nwin)
if (!quiet) progbar <- txtProgressBar(style = 3)
if (missing || !diploid){
for (i in seq(nwin)){
posns <- which(xpos %in% winmat[i, 1]:winmat[i, 2])
if (length(posns) < min.snps){
res_mat[i] <- NA
} else {
res_mat[i] <- snpia(x[, posns], threads = threads)
}
if (!quiet){
setTxtProgressBar(progbar, i/nwin)
}
for (i in seq(nwin)){
posns <- which(xpos %in% winmat[i, 1]:winmat[i, 2])
if (length(posns) < min.snps){
res_mat[i] <- NA
} else {
res_mat[i] <- bitwise.IA(x[, posns], threads = threads)
}
} else {
for (i in seq(nwin)){
posns <- which(xpos %in% winmat[i, 1]:winmat[i, 2])
if (length(posns) < min.snps){
res_mat[i] <- NA
} else {
res_mat[i] <- bitwise.IA(x[, posns], threads = threads)
}
if (!quiet){
setTxtProgressBar(progbar, i/nwin)
}
if (!quiet){
setTxtProgressBar(progbar, i/nwin)
}
}
return(res_mat)
Expand Down Expand Up @@ -514,23 +498,11 @@ samp.ia <- function(x, n.snp = 100L, reps = 100L, threads = 1L, quiet = FALSE){
nloc <- nLoc(x)
res_mat <- vector(mode = "numeric", length = reps)
if (!quiet) progbar <- txtProgressBar(style = 3)
diploid <- FALSE # Use this line when bitwise.IA works all(ploidy(x) == 2)
missing <- TRUE # any(vapply(x@gen, function(i) length(i@NA.posi) > 0, logical(1)))
if (missing || !diploid){
for (i in seq(reps)){
posns <- sample(nloc, n.snp)
res_mat[i] <- snpia(x[, posns], threads = threads)
if (!quiet){
setTxtProgressBar(progbar, i/reps)
}
}
} else {
for (i in seq(reps)){
posns <- sample(nloc, n.snp)
res_mat[i] <- bitwise.IA(x[, posns], threads = threads)
if (!quiet){
setTxtProgressBar(progbar, i/reps)
}
for (i in seq(reps)){
posns <- sample(nloc, n.snp)
res_mat[i] <- bitwise.IA(x[, posns], threads = threads)
if (!quiet){
setTxtProgressBar(progbar, i/reps)
}
}
return(res_mat)
Expand Down

0 comments on commit ef81e7b

Please sign in to comment.