qual2prob: Convert FASTQ quality scores to base probability

Description Usage Arguments Value Author(s) Examples

View source: R/qual2prob.R

Description

Converts FASTQ quality scores encoded as ASCII characters to numeric probability that base was correctly called.

Usage

1
qual2prob(x, phred.scale = c("+33", "+64"), simplify = TRUE)

Arguments

x

a vector of quality scores represented as ASCII characters from ! to ~. Each element in x can be a string of characters or a single character.

phred.scale

scale of PHRED encoding. Can be : "+33" = range of 0:93 (e.g., Sanger, Illumina 1.8+), or "+64" = range of -31:62 (e.g., Solexa, Illumina 1.3+, 1.5+)

simplify

if there is only one set of quality scores, simplify resulting list to a vector?

Value

List of probabilities that each base represented by the characters in x was correctly called. List has one element for each set of quality scores in x.

Author(s)

Eric Archer eric.archer@noaa.gov

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# each element is a single quality score
quality.1 <- sapply(sample(33:126, 15, rep = TRUE), intToUtf8)
prob.1 <- qual2prob(quality.1)

quality.1
prob.1

# each element is a string of quality scores
quality.2 <- replicate(5, {
  num.sites <- sample(5:10, 1)
  chars <- sapply(sample(33:126, num.sites, rep = TRUE), intToUtf8)
  paste(chars, collapse = "")
}, simplify = "vector")
prob.2 <- qual2prob(quality.2)

quality.2
prob.2 

EricArcher/swfscGenetics documentation built on May 25, 2021, 3:46 a.m.