pos2fastq: Convert read positions to fastq records

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

View source: R/nucSim.R

Description

Convert read positions for a single chromosome (both strands) into read sequences + qualities and write them to file

Usage

1
2
3
pos2fastq(readPos, names, quality, sequence, qualityFun, errorFun, 
	readLen = 36, file, 
	qualityType = c("Illumina", "Sanger", "Solexa"), ...)

Arguments

readPos

A list of two numeric vectors (one per strand)

names

List of names to use for reads in fastq file. Has to be of same shape as name.

quality

Passed on as argument to qualityFun.

sequence

Reference sequence (a DNAString object).

qualityFun

Function to generate quality scores.

errorFun

Function to introduce sequencing errors.

readLen

Read length to generate.

file

Output file (either file name or connection).

qualityType

Encoding to use for read quality scores.

...

Further arguments (see Details).

Details

Arguments passed as part of ... will be passed on to qualityFun, except an argument called prob which is passed on to errorFun instead if present.

Value

Invisibly returns the number of records that were written.

Author(s)

Peter Humburg

See Also

See readError for a possible choice of errorFun and readQualitySample for a simple qualityFun.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
set.seed(1)

## a function to generate random read qualities (in Sanger format)
randomQuality <- function(read, ...){
	paste(sample(unlist(strsplit(rawToChar(as.raw(33:126)),"")), 
		length(read), replace = TRUE), collapse="")
} 

## generate a reference sequence
chromosome <- DNAString(paste(sample(c("A", "C", "G", "T"), 
	1e5, replace = TRUE), collapse = ""))

## and a few read positions
reads <- list(sample(100:9900, 5), sample(100:9900, 5))
names <- list(paste("read", 1:5, sep="_"), paste("read", 6:10, sep="_"))

## convert to fastq format
pos2fastq(reads, names, sequence=chromosome, qualityFun=randomQuality, 
	errorFun=readError, file="")

ChIPsim documentation built on Nov. 8, 2020, 8:09 p.m.