Skip to content

Commit

Permalink
Merge pull request #80 from green-striped-gecko/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
green-striped-gecko committed Jun 14, 2019
2 parents ca4f761 + 09848e3 commit 3f9eebd
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 2 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Expand Up @@ -2,8 +2,8 @@ Package: dartR
Type: Package
Title: Importing and Analysing SNP and Silicodart Data Generated by Genome-Wide
Restriction Fragment Analysis
Version: 1.3.3
Date: 2019-06-06
Version: 1.3.4
Date: 2019-06-14
Authors@R: c(
person("Bernd", "Gruber", email="bernd.gruber@canberra.edu.au", role=c("aut","cre")),
person("Arthur", "Georges", email="georges@aerg.edu.au", role="aut"),
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Expand Up @@ -20,6 +20,7 @@ export(gl.drop.pop)
export(gl.edit.recode.ind)
export(gl.edit.recode.pop)
export(gl.filter.callrate)
export(gl.filter.callrate.loc.pop)
export(gl.filter.cloneid)
export(gl.filter.hamming)
export(gl.filter.heterozygosity)
Expand Down
23 changes: 23 additions & 0 deletions R/gl.filter.callrate.loc.pop.r
@@ -0,0 +1,23 @@
#' Filter loci in a genlight adegenet object based on call rate and population level.
#'
#' This funciton is a convenience function that filters callrate for the set threshold for each population and then returns a genlight object where each loci of every population passes the threshold of the call rate filter. For more details on call rates see gl.filter.callrate.
#' @param x - genlight object to be filtered
#' @param threshold threshold on call rate for loci for each population (see gl.filter.callrate for details.)
#' @return The filtered genlight or genind object
#' @export
#' @examples
#' gg <- gl.filter.callrate.loc.pop(testset.gl, 0.9)

gl.filter.callrate.loc.pop <- function(x, threshold){

pops <- seppop(x)
ll <- lapply(pops, function(x) locNames(gl.filter.callrate(x, method = "loc", threshold = threshold, verbose = 0)))
locall <- Reduce(intersect, ll)
index <- which(locNames(x) %in% locall)
x <- x[ , locall]
x@other$loc.metrics <- x@other$loc.metrics[locall,]
#add to history
nh <- length(x@other$history)
x@other$history[[nh + 1]] <- match.call()
return(x)
}
22 changes: 22 additions & 0 deletions man/gl.filter.callrate.loc.pop.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3f9eebd

Please sign in to comment.