write: Write sequences to text in FASTA or FASTQ format.

Description Usage Arguments Value Author(s) References See Also Examples

Description

These functions take a list of DNA or amino acid sequences in DNAbin or AAbin format and outputs a text file to a specified directory.

Usage

1
2
3
writeFASTQ(x, file = "", compress = FALSE, append = FALSE)

writeFASTA(x, file = "", compress = FALSE, append = FALSE, wrap = NULL)

Arguments

x

a list of sequences in DNAbin or AAbin format, or a vector of sequences as concatenated upper-case character strings. For writeFASTQ, only DNAbin objects are accepted, and each element should have a vector of quality scores of equal length attributed to the sequence. These vectors are comprised of raw bytes ranging from 00 to 5d (0 to 93 when converted to integers). See readFASTQ for more details.

file

character string giving a valid file path to output the text to. If file = "" (default setting) the text file is written to the console.

compress

logical indicating whether the output file should be gzipped.

append

logical indicating whether the output should be appended to the file.

wrap

integer giving the maximum number of characters on each sequence line. Defaults to NULL (no wrapping).

Value

NULL (invisibly).

Author(s)

Shaun Wilkinson

References

Illumina help page: https://help.basespace.illumina.com/articles/descriptive/fastq-files/

See Also

readFASTQ for reading FASTQ files into R, and write.dna in the ape package for writing DNA to text in FASTA and other formats.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
  ## 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)
  ## quality filter with size selection and singleton removal
  x <- qfilter(x, minlength = 250, maxlength = 350)
  ## output filtered FASTQ file
  writeFASTQ(x, file = paste0(td, "/COI_sample2_filtered.fastq"))
  writeFASTA(x, file = paste0(td, "/COI_sample2_filtered.fasta"))
 

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