Skip to content

Instantly share code, notes, and snippets.

@tgirke
Last active May 31, 2016 02:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tgirke/bc83fbf57304649775c9a79ccc0a7469 to your computer and use it in GitHub Desktop.
Save tgirke/bc83fbf57304649775c9a79ccc0a7469 to your computer and use it in GitHub Desktop.
#####################################
## Quality Trimming of FASTQ Reads ##
#####################################
## Author: Thomas Girke
## Last update: May 30, 2016
## Usage of below function combined with preprocessReads form systemPipeR:
# qcTrim <- "qualityTrimming(fq, phred_cutoff=20, cutoff_occurrences=1, N_cutoff=1, minreadlength=100)"
# preprocessReads(args=args, Fct=qcTrim, batchsize=100000, overwrite=TRUE, compress=TRUE)
## Arguments:
## phred_cutoff: min Phred score to trigger tail trimming
## cutoff_occurences: min number of Phred score cutoff violations to trigger tail trimming
## N_cutoff: after tail trimming reads with >=N_cutoff Ns are entirely removed
## minreadlength: reads below the assigned length threshold are removed
qualityTrimming <- function(fq, phred_cutoff, cutoff_occurrences, N_cutoff, minreadlength) {
fq <- trimTails(fq, k=cutoff_occurrences, a=rawToChar(as.raw(phred_cutoff+33)), successive=FALSE)
fq <- fq[width(fq)>=minreadlength] # Read length filter
filter <- compose(nFilter(threshold=N_cutoff))
fq <- fq[filter(fq)]
return(fq)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment