Learn R Programming

ggDNAvis (version 0.3.2)

read_fastq: Read sequence and quality information from FASTQ

Description

This function simply reads a FASTQ file into a dataframe containing columns for read ID, sequence, and quality scores. Optionally also contains a column of sequence lengths.

See fastq_quality_scores for an explanation of quality.

Resulting dataframe can be written back to FASTQ via write_fastq(). To read/write a modified FASTQ containing modification information (SAM/BAM MM and ML tags) in the header lines, use read_modified_fastq() and write_modified_fastq().

Usage

read_fastq(filename = file.choose(), calculate_length = TRUE)

Value

dataframe. A dataframe with read, sequence, quality, and optionally sequence_length columns.

Arguments

filename

character. The file to be read. Defaults to file.choose() to select a file interactively.

calculate_length

logical. Whether or not sequence_length column should be calculated and included.

Examples

Run this code
## Locate file
fastq_file <- system.file("extdata",
                          "example_many_sequences_raw.fastq",
                          package = "ggDNAvis")

## View file
for (i in 1:16) {
    cat(readLines(fastq_file)[i], "\n")
}

## Read file to dataframe
read_fastq(fastq_file, calculate_length = FALSE)
read_fastq(fastq_file, calculate_length = TRUE)

Run the code above in your browser using DataLab