Description Usage Arguments Value Note Examples
This a function for aligning CRISPR barcode reads to library, or similar problems using hamming distance to evaluate the distance between a read and a barcode for the error toleration.
1 2 | bcSeq_hamming(sampleFile, libFile, outFile, misMatch=2, tMat = NULL,
numThread = 4, count_only = TRUE, detail_info = FALSE)
|
sampleFile |
(string) sample filename, needs to be a fastq file |
libFile |
(string) library filename, needs to be a fasta or fastq file. |
outFile |
(string) output filename. |
misMatch |
(integer) the number of maximum mismatches or indels allowed in the alignment. |
tMat |
(two column dataframe) prior probability of a mismatch given a sequence. The first column is the prior sequence, the second column is the error rate. The default value for all prior sequences is 1/3. |
numThread |
(integer) the number of threads for parallel computing, default 4. |
count_only |
(bool) option for function returns, default to be
|
detail_info |
(bool) option for controlling function returns, default to
be |
default |
No objects are returned to R, instead, a csv count table is created and written to files. The .csv file contains two columns, the first column is the sequences of the barcodes, and the second columns is the number of reads that aligned to the barcodes. |
count_only = FALSE |
If set to |
The user need to perform the removing of any adaptor sequence before and after the barcode for the fastq file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #### Generate barcodes
lFName <- "./libFile.fasta"
bases <- c(rep('A', 4), rep('C',4), rep('G',4), rep('T',4))
numOfBars <- 40
Barcodes <- rep(NA, numOfBars*2)
for (i in 1:numOfBars){
Barcodes[2*i-1] <- paste0(">barcode_ID: ", i)
Barcodes[2*i] <- paste(sample(bases, length(bases)), collapse = '')
}
write(Barcodes, lFName)
#### Generate reads and phred score
rFName <- "./readFile.fastq"
numOfReads <- 800
Reads <- rep(NA, numOfReads*4)
for (i in 1:numOfReads){
Reads[4*i-3] <- paste0("@read_ID_",i)
Reads[4*i-2] <- Barcodes[2*sample(1:numOfBars,1,
replace=TRUE, prob=seq(1:numOfBars))]
Reads[4*i-1] <- "+"
Reads[4*i] <- paste(rawToChar(as.raw(
33+sample(20:30, length(bases),replace=TRUE))),
collapse='')
}
write(Reads, rFName)
#### perform alignment
outFile <- "./count_hamming.csv"
#res <- bcSeq_hamming(rFName, lFName, outFile, misMatch = 2,
# tMat = NULL, numThread = 1, count_only = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.