trim: Trim primer and/or index sequences.

Description Usage Arguments Details Value Author(s) Examples

View source: R/trim.R

Description

This function trims the primer and/or index sequence(s) from a set of DNA sequences.

Usage

1
trim(x, up, down = NULL)

Arguments

x

a "DNAbin" object or a vector of concatenated upper-case character strings, containing the sequences to be trimmed.

up, down

"DNAbin" objects or vectors of concatenated upper-case character strings, representing the primer sequences.

Details

Any sequences not containing the primer(s) in either direction are discarded. Hence this function can also be used to de-multiplex sequences and remove indices, though it will generally be faster to do this on the sequencing platform prior to exporting the FASTQ files.

Value

a "DNAbin" object or a vector of concatenated character strings, depending on the input.

Author(s)

Shaun Wilkinson

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
  ## download and extract example FASTQ file to temporary directory
  td <- tempdir()
  URL <- "https://www.dropbox.com/s/71ixehy8e51etdd/insect_tutorial1_files.zip?dl=1"
  dest <- paste0(td, "/insect_tutorial1_files.zip")
  download.file(URL, destfile = dest, mode = "wb")
  unzip(dest, exdir = td)
  x <- readFASTQ(paste0(td, "/COI_sample2.fastq"))
  ## trim primers from sequences
  mlCOIintF <- "GGWACWGGWTGAACWGTWTAYCCYCC"
  jgHCO2198 <- "TAIACYTCIGGRTGICCRAARAAYCA"
  x <- trim(x, up = mlCOIintF, down = jgHCO2198)

shaunpwilkinson/insect documentation built on Aug. 9, 2021, 5 a.m.