Title: | An R Wrapper for Bowtie2 and AdapterRemoval |
---|---|
Description: | This package provides an R wrapper of the popular bowtie2 sequencing reads aligner and AdapterRemoval, a convenient tool for rapid adapter trimming, identification, and read merging. The package contains wrapper functions that allow for genome indexing and alignment to those indexes. The package also allows for the creation of .bam files via Rsamtools. |
Authors: | Zheng Wei [aut, cre], Wei Zhang [aut] |
Maintainer: | Zheng Wei <[email protected]> |
License: | GPL (>= 3) |
Version: | 2.13.0 |
Built: | 2024-10-31 04:25:26 UTC |
Source: | https://github.com/bioc/Rbowtie2 |
Function that makes a system call for the bowtie binaries. Note it is not intended to be used outside of the package.
.callbinary( bin1, args1, op = NULL, bin2 = NULL, args2 = NULL, path = NULL, lang = NULL )
.callbinary( bin1, args1, op = NULL, bin2 = NULL, args2 = NULL, path = NULL, lang = NULL )
bin1 |
|
args1 |
|
op |
|
bin2 |
|
args2 |
|
path |
|
lang |
|
The output of the system call or the path provided.
Zheng Wei
Print available arguments for adapterremoval. Note that some arguments to the adapterremoval are invalid if they are already handled as explicit function arguments.
adapterremoval_usage()
adapterremoval_usage()
AdapterRemoval available arguments and their usage.
Zheng Wei
Schubert, Lindgreen, and Orlando (2016). AdapterRemoval v2: rapid adapter trimming, identification, and read merging. BMC Research Notes, 12;9(1):88.
adapterremoval_usage()
adapterremoval_usage()
Print version information of adapterremoval
adapterremoval_version()
adapterremoval_version()
An invisible Integer
of call status.
The value is 0 when there is not any mistakes
Zheng Wei
Schubert, Lindgreen, and Orlando (2016). AdapterRemoval v2: rapid adapter trimming, identification, and read merging. BMC Research Notes, 12;9(1):88.
adapterremoval_version()
adapterremoval_version()
This function can be use to call wrapped bowtie2
binary.
bowtie2( bt2Index, samOutput, seq1, ..., seq2 = NULL, interleaved = FALSE, overwrite = FALSE )
bowtie2( bt2Index, samOutput, seq1, ..., seq2 = NULL, interleaved = FALSE, overwrite = FALSE )
bt2Index |
|
samOutput |
|
seq1 |
|
... |
Additional arguments to be passed on to the binaries. See below for details. |
seq2 |
|
interleaved |
|
overwrite |
|
All additional arguments in ... are interpreted as
additional parameters to be passed on to
bowtie2. All of them should be Character
or
Numeric
scalar. You can put all aditional
arguments in one Character
(e.g. "–threads 8 –no-mixed")
with white space splited just like command line,
or put them in different Character
(e.g. "–threads","8","–no-mixed"). Note that some
arguments("-x","–interleaved","-U","-1","-2","-S") to the
bowtie2 are invalid if they are already handled as explicit
function arguments. See the output of
bowtie2_usage()
for details about available parameters.
An invisible Integer
of call
status. The value is 0 when there is not any mistakes
Otherwise the value is non-zero.
Zheng Wei
Langmead, B., & Salzberg, S. L. (2012). Fast gapped-read alignment with Bowtie 2. Nature methods, 9(4), 357-359.
td <- tempdir() ## Building a bowtie2 index refs <- dir(system.file(package="Rbowtie2", "extdata", "bt2","refs"), full=TRUE) bowtie2_build(references=refs, bt2Index=file.path(td, "lambda_virus"), "--threads 4 --quiet",overwrite=TRUE) ## Alignments reads_1 <- system.file(package="Rbowtie2", "extdata", "bt2", "reads", "reads_1.fastq") reads_2 <- system.file(package="Rbowtie2", "extdata", "bt2", "reads", "reads_2.fastq") if(file.exists(file.path(td, "lambda_virus.1.bt2"))){ cmdout<-bowtie2(bt2Index = file.path(td, "lambda_virus"), samOutput = file.path(td, "result.sam"), seq1=reads_1,seq2=reads_2,overwrite=TRUE,"--threads 3");cmdout head(readLines(file.path(td, "result.sam"))) }
td <- tempdir() ## Building a bowtie2 index refs <- dir(system.file(package="Rbowtie2", "extdata", "bt2","refs"), full=TRUE) bowtie2_build(references=refs, bt2Index=file.path(td, "lambda_virus"), "--threads 4 --quiet",overwrite=TRUE) ## Alignments reads_1 <- system.file(package="Rbowtie2", "extdata", "bt2", "reads", "reads_1.fastq") reads_2 <- system.file(package="Rbowtie2", "extdata", "bt2", "reads", "reads_2.fastq") if(file.exists(file.path(td, "lambda_virus.1.bt2"))){ cmdout<-bowtie2(bt2Index = file.path(td, "lambda_virus"), samOutput = file.path(td, "result.sam"), seq1=reads_1,seq2=reads_2,overwrite=TRUE,"--threads 3");cmdout head(readLines(file.path(td, "result.sam"))) }
Calling bowtie2_build_usage() prints the available arguments that can be passed to the ... argument of the bowtie2_build() function of the package. Note that some arguments are invalid if they are already handled as explicit function arguments.
bowtie2_build_usage()
bowtie2_build_usage()
Information about available arguments that can be passed to bowtie2_build()
Zheng Wei
Langmead B, Salzberg S. Fast gapped-read alignment with Bowtie 2. Nature Methods. 2012, 9:357-359.
bowtie2_build_usage()
bowtie2_build_usage()
This function can be use to call the bowtie2 wrapper which wraps
the bowtie2-align-s
and the bowtie2-align-l
binaries.
bowtie2_samtools( bt2Index, output, outputType = "sam", seq1 = NULL, seq2 = NULL, bamFile = NULL, ..., interleaved = FALSE, overwrite = FALSE )
bowtie2_samtools( bt2Index, output, outputType = "sam", seq1 = NULL, seq2 = NULL, bamFile = NULL, ..., interleaved = FALSE, overwrite = FALSE )
bt2Index |
|
output |
|
outputType |
|
seq1 |
|
seq2 |
|
bamFile |
|
... |
Additional arguments to be passed on to the bowtie2 wrapper. See below for details. |
interleaved |
|
overwrite |
|
All additional arguments in ... are interpreted as
additional parameters to be passed to bowtie2 wrapper.
All of them should be Character
or Numeric
scalar.
You can put all additional arguments in one Character
(e.g. "–threads 8 –no-mixed") with white space separation,
or put them in different Character
(e.g. "–threads","8","–no-mixed").
Note that some arguments ("-x","–interleaved","-U","-1","-2","-b","-S") are
invalid if they are already handled as explicit function arguments.
See the output of bowtie2_usage()
for details about available parameters.
An invisible Integer
of call
status. The value is 0 when there is not any mistakes
Otherwise the value is non-zero.
Zheng Wei
Langmead, B., & Salzberg, S. L. (2012). Fast gapped-read alignment with Bowtie 2. Nature methods, 9(4), 357-359.
td <- tempdir() ## Building a bowtie2 index refs <- dir(system.file(package="Rbowtie2", "extdata", "bt2","refs"), full=TRUE) bowtie2_build(references=refs, bt2Index=file.path(td, "lambda_virus"),"--threads 4 --quiet",overwrite=TRUE) ## Alignments reads_1 <- system.file(package="Rbowtie2", "extdata", "bt2", "reads", "reads_1.fastq") reads_2 <- system.file(package="Rbowtie2", "extdata", "bt2", "reads", "reads_2.fastq") ## Sam file created bowtie2_samtools(bt2Index = file.path(td,"lambda_virus"), output = file.path(td,"example"), seq1 = reads_1, seq2 = reads_2, overwrite = TRUE) ## Bam file created bowtie2_samtools(bt2Index = file.path(td,"lambda_virus"), output = file.path(td,"example"), outputType = "bam", seq1 = reads_1, seq2 = reads_2, overwrite = TRUE)
td <- tempdir() ## Building a bowtie2 index refs <- dir(system.file(package="Rbowtie2", "extdata", "bt2","refs"), full=TRUE) bowtie2_build(references=refs, bt2Index=file.path(td, "lambda_virus"),"--threads 4 --quiet",overwrite=TRUE) ## Alignments reads_1 <- system.file(package="Rbowtie2", "extdata", "bt2", "reads", "reads_1.fastq") reads_2 <- system.file(package="Rbowtie2", "extdata", "bt2", "reads", "reads_2.fastq") ## Sam file created bowtie2_samtools(bt2Index = file.path(td,"lambda_virus"), output = file.path(td,"example"), seq1 = reads_1, seq2 = reads_2, overwrite = TRUE) ## Bam file created bowtie2_samtools(bt2Index = file.path(td,"lambda_virus"), output = file.path(td,"example"), outputType = "bam", seq1 = reads_1, seq2 = reads_2, overwrite = TRUE)
Calling bowtie2_usage() prints the available arguments that can be passed to the ... argument of the bowtie2() function of the package. Note that some arguments are invalid if they are already handled as explicit function arguments.
bowtie2_usage()
bowtie2_usage()
Information about available arguments that can be passed to bowtie2().
Zheng Wei
Langmead, B., & Salzberg, S. L. (2012). Fast gapped-read alignment with Bowtie 2. Nature methods, 9(4), 357-359.
bowtie2_usage()
bowtie2_usage()
Calling bowtie2_version() prints the version information of the bowtie package used.
bowtie2_version()
bowtie2_version()
An invisible Integer
of call status.
The value is 0 when there is not any mistakes
Otherwise the value is non-zero.
Zheng Wei
Langmead, B., & Salzberg, S. L. (2012). Fast gapped-read alignment with Bowtie 2. Nature methods, 9(4), 357-359.
bowtie2_version()
bowtie2_version()
This function can be use to call the bowtie2-build wrapper which
wraps the bowtie2-build-s
and the bowtie2-build-l
binaries.
bowtie2_build(references, bt2Index, ..., overwrite = FALSE)
bowtie2_build(references, bt2Index, ..., overwrite = FALSE)
references |
|
bt2Index |
|
... |
Additional arguments to be passed on to the binaries. See below for details. |
overwrite |
|
All additional arguments in ... are interpreted as additional
parameters to be passed on to bowtie2_build wrapper. All of them should be
Character
or Numeric
scalar. You can put all additional
arguments in one Character
(e.g. "–threads 8 –quiet") with white
space separation, or put them in different Character
(e.g. "–threads","8","–quiet"). See the output of bowtie2_build_usage()
for details about available parameters.
An invisible Integer
of call status.
The value is 0 when there is not any mistakes
Otherwise the value is non-zero.
Zheng Wei
Langmead, B., & Salzberg, S. L. (2012). Fast gapped-read alignment with Bowtie 2. Nature methods, 9(4), 357-359.
td <- tempdir() ## Building a bowtie2 index refs <- dir(system.file(package="Rbowtie2", "extdata", "bt2","refs"), full=TRUE) bowtie2_build(references=refs, bt2Index=file.path(td, "lambda_virus"), "--threads 4 --quiet",overwrite=TRUE) ## Use additional arguments in another way bowtie2_build(references=refs, bt2Index=file.path(td, "lambda_virus"), "--threads",4,"--quiet",overwrite=TRUE) ## The function will print the output during the process without "--quiet" argument. bowtie2_build(references=refs, bt2Index=file.path(td, "lambda_virus"), overwrite=TRUE)
td <- tempdir() ## Building a bowtie2 index refs <- dir(system.file(package="Rbowtie2", "extdata", "bt2","refs"), full=TRUE) bowtie2_build(references=refs, bt2Index=file.path(td, "lambda_virus"), "--threads 4 --quiet",overwrite=TRUE) ## Use additional arguments in another way bowtie2_build(references=refs, bt2Index=file.path(td, "lambda_virus"), "--threads",4,"--quiet",overwrite=TRUE) ## The function will print the output during the process without "--quiet" argument. bowtie2_build(references=refs, bt2Index=file.path(td, "lambda_virus"), overwrite=TRUE)
This is an internal function that is not meant to be used outside of the package. It determines whether the file at the end of the path can be created.
checkFileCreatable(filePath, argname, overwrite)
checkFileCreatable(filePath, argname, overwrite)
filePath |
|
argname |
|
overwrite |
|
Indicates whether the file can be created at the path given.
Zheng Wei
This is an internal function that is not meant to be used outside of the package. It determines whether a specific file exists at the end of the path given to the function.
checkFileExist(filePath, argname)
checkFileExist(filePath, argname)
filePath |
|
argname |
|
Stops the function if the file does not exist.
Zheng Wei
This is an internal function that is not meant to be used outside of the package. It determines whether the given index library comprises of small indexes (.bt2) or large indexes (.bt2l).
checkIndexType(filePath)
checkIndexType(filePath)
filePath |
|
The function first tries to determine whether path_to_index_dir/index_basename.1.bt2 exists and if it doesn't exist then it tries to determine whether path_to_index_dir/index_basename.1.bt2l exists. If neither of those files exist then there is an issue with the index files that must be addressed.
Character
scalar. Returns either "SMALL" if the .bt2 file is found,
"LARGE" if the .bt2l file is found, or "ERROR" if neither the .bt2 nor .bt2l file
is found.
This is an internal function that is not meant to be used outside of the package. It determines whether the path passed to the function exists.
checkPathExist(filePath, argname)
checkPathExist(filePath, argname)
filePath |
|
argname |
|
Stops the function if the path does not exist.
Zheng Wei
This is an internal function that is not meant to be used outside of the package. It checks whether samtools exists on the system.
checkSamtoolsExists()
checkSamtoolsExists()
Returns TRUE if samtools exists on the system, else FALSE
This function can be use to call wrapped AdapterRemoval
binary for adapters identifying.
identify_adapters(file1, file2, ..., basename = NULL, overwrite = FALSE)
identify_adapters(file1, file2, ..., basename = NULL, overwrite = FALSE)
file1 |
|
file2 |
|
... |
Additional arguments to be passed on to the binaries. See below for details. |
basename |
|
overwrite |
|
All additional arguments in ... are interpreted as
additional parameters to be passed on to
identify_adapters. All of them should be Character
or
Numeric
scalar. You can put all aditional
arguments in one Character
(e.g. "–threads 8") with white
space splited just like command line,
or put them in different Character
(e.g. "–threads","8").
Note that some arguments("–identify-adapters",
"–file1","–file2","–basename") to the
identify_adapters are invalid if they are already handled as
explicit function arguments. See the output of
adapterremoval_usage()
for details about available parameters.
An invisible Character
vector of adapters for each mate.
Zheng Wei
Schubert, Lindgreen, and Orlando (2016). AdapterRemoval v2: rapid adapter trimming, identification, and read merging. BMC Research Notes, 12;9(1):88.
td <- tempdir() reads_1 <- system.file(package="Rbowtie2", "extdata", "adrm", "reads_1.fq") reads_2 <- system.file(package="Rbowtie2", "extdata", "adrm", "reads_2.fq") adapters <- identify_adapters(file1=reads_1,file2=reads_2, basename = file.path(td,"reads") ,"--threads 2",overwrite=TRUE) adapters
td <- tempdir() reads_1 <- system.file(package="Rbowtie2", "extdata", "adrm", "reads_1.fq") reads_2 <- system.file(package="Rbowtie2", "extdata", "adrm", "reads_2.fq") adapters <- identify_adapters(file1=reads_1,file2=reads_2, basename = file.path(td,"reads") ,"--threads 2",overwrite=TRUE) adapters
This function can be use to call wrapped AdapterRemoval
binary.
remove_adapters( file1, ..., adapter1 = NULL, output1 = NULL, file2 = NULL, adapter2 = NULL, output2 = NULL, basename = NULL, interleaved = FALSE, overwrite = FALSE )
remove_adapters( file1, ..., adapter1 = NULL, output1 = NULL, file2 = NULL, adapter2 = NULL, output2 = NULL, basename = NULL, interleaved = FALSE, overwrite = FALSE )
file1 |
|
... |
Additional arguments to be passed on to the binaries. See below for details. |
adapter1 |
|
output1 |
|
file2 |
|
adapter2 |
|
output2 |
|
basename |
|
interleaved |
|
overwrite |
|
All additional arguments in ... are interpreted as additional
parameters to be passed on to
remove_adapters. All of them should be Character
or Numeric
scalar. You can put all aditional
arguments in one Character
(e.g. "–threads 8") with white space
splited just like command line,
or put them in different Character
(e.g. "–threads","8").
Note that some arguments(
"–file1","–file2","–adapter1","–adapter2","–output1","–output2",
"–basename","–interleaved") to the
identify_adapters are invalid if they are already handled as explicit
function arguments. See the output of
adapterremoval_usage()
for details about available parameters.
An invisible Integer
of call status.
The value is 0 when there is not any mistake.
Otherwise the value is non-zero.
Zheng Wei
Schubert, Lindgreen, and Orlando (2016). AdapterRemoval v2: rapid adapter trimming, identification, and read merging. BMC Research Notes, 12;9(1):88.
td <- tempdir() # Identify adapters reads_1 <- system.file(package="Rbowtie2", "extdata", "adrm", "reads_1.fq") reads_2 <- system.file(package="Rbowtie2", "extdata", "adrm", "reads_2.fq") adapters <- identify_adapters(file1=reads_1,file2=reads_2, basename=file.path(td,"reads"), "--threads 3",overwrite=TRUE) # Remove adapters cmdout<-remove_adapters(file1=reads_1,file2=reads_2,adapter1 = adapters[1], adapter2 = adapters[2], output1=file.path(td,"reads_1.trimmed.fq"), output2=file.path(td,"reads_2.trimmed.fq"), basename=file.path(td,"reads.base"),overwrite=TRUE,"--threads 3");cmdout
td <- tempdir() # Identify adapters reads_1 <- system.file(package="Rbowtie2", "extdata", "adrm", "reads_1.fq") reads_2 <- system.file(package="Rbowtie2", "extdata", "adrm", "reads_2.fq") adapters <- identify_adapters(file1=reads_1,file2=reads_2, basename=file.path(td,"reads"), "--threads 3",overwrite=TRUE) # Remove adapters cmdout<-remove_adapters(file1=reads_1,file2=reads_2,adapter1 = adapters[1], adapter2 = adapters[2], output1=file.path(td,"reads_1.trimmed.fq"), output2=file.path(td,"reads_2.trimmed.fq"), basename=file.path(td,"reads.base"),overwrite=TRUE,"--threads 3");cmdout