Skip to content

Commit

Permalink
Add check for all samples failing QC; remove interactive from example
Browse files Browse the repository at this point in the history
  • Loading branch information
HannahVMeyer committed Jul 4, 2019
1 parent 101e74e commit 0464224
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions R/applyQC.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
#'
#' # Create new dataset of indiviudals and markers passing QC
#' ids_all <- cleanData(indir=indir, qcdir=qcdir, name=name, macTh=15,
#' interactive=FALSE, verbose=TRUE, path2plink=path2plink, filterAncestry=TRUE,
#' verbose=TRUE, path2plink=path2plink, filterAncestry=FALSE,
#' filterRelated=TRUE)
#' }

Expand Down Expand Up @@ -115,6 +115,9 @@ cleanData <- function(indir, name, qcdir=indir,

# Remove remove.IDs file if already existing
removeIDs <- NULL
IDs <- data.table::fread(paste(prefix, ".fam", sep=""),
data.table=FALSE, stringsAsFactors=FALSE,
header=FALSE)
if (any(sampleFilter)) {
if (filterRelated) {
if (!file.exists(paste(out, ".fail-IBD.IDs", sep=""))){
Expand Down Expand Up @@ -202,6 +205,10 @@ cleanData <- function(indir, name, qcdir=indir,
}
# ensure unique IDs in remove.IDs
removeIDs <- removeIDs[!duplicated(removeIDs),]
if (nrow(removeIDs) == nrow(IDs)) {
stop("All samples are flagged as .fail.IDs ",
"no samples remaining to generate the QCed dataset.")
}
if (verbose) message("Write file with remove IDs")
write.table(removeIDs, paste(out, ".remove.IDs", sep=""),
col.names=FALSE, row.names=FALSE, quote=FALSE)
Expand All @@ -212,9 +219,7 @@ cleanData <- function(indir, name, qcdir=indir,
remove <- c("--remove", paste(out, ".remove.IDs", sep=""))
fail_samples <- nrow(removeIDs)
} else {
keepIDs <- data.table::fread(paste(prefix, ".fam", sep=""),
data.table=FALSE, stringsAsFactors=FALSE,
header=FALSE)
keepIDs <- IDs
removeIDs <- NULL
remove <- NULL
fail_samples <- 0
Expand Down

0 comments on commit 0464224

Please sign in to comment.