Title: | R wrapper for BWA-backtrack and BWA-MEM aligners |
---|---|
Description: | Provides an R wrapper for BWA alignment algorithms. Both BWA-backtrack and BWA-MEM are available. Convenience function to build a BWA index from a reference genome is also provided. Currently not supported for Windows machines. |
Authors: | Jean-Philippe Fortin [aut, cre] |
Maintainer: | Jean-Philippe Fortin <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.11.0 |
Built: | 2024-11-18 04:09:12 UTC |
Source: | https://github.com/bioc/Rbwa |
R wrapper to run BWA alignment tool BWA-backtrack.
bwa_aln( type = c("single", "paired"), index_prefix, fastq_files, sai_files, ... )
bwa_aln( type = c("single", "paired"), index_prefix, fastq_files, sai_files, ... )
type |
String specifying type of reads: "single" for single-end reads (default) or "paired" for paired-end reads. |
index_prefix |
String specifying prefix of the BWA index. |
fastq_files |
Character vector specifying paths of fastq files.
If |
sai_files |
Character vector specifying filenames of the BWA
aligmment output files.
If |
... |
Other arguments to pass to the |
No return value. Output files from bwa aln alignment are produced as side effect.
Jean-Philippe Fortin
dir <- tempdir() fasta <- system.file(package="Rbwa", "fasta/chr12.fa") fastq <- system.file(package="Rbwa", "fastq/sequences.fastq") index_prefix <- file.path(dir,"chr12") bwa_build_index(fasta, index_prefix=index_prefix) bwa_aln(index_prefix=index_prefix, fastq_files=fastq, sai_files=file.path(dir, "output.sai"))
dir <- tempdir() fasta <- system.file(package="Rbwa", "fasta/chr12.fa") fastq <- system.file(package="Rbwa", "fastq/sequences.fastq") index_prefix <- file.path(dir,"chr12") bwa_build_index(fasta, index_prefix=index_prefix) bwa_aln(index_prefix=index_prefix, fastq_files=fastq, sai_files=file.path(dir, "output.sai"))
R wrapper to create BWA index files from a FASTA file.
bwa_build_index(fasta, index_prefix = NULL, ...)
bwa_build_index(fasta, index_prefix = NULL, ...)
fasta |
String specifying path to a FASTA file. |
index_prefix |
String specifying prefix of the output BWA index. |
... |
Other arguments to pass to |
No return value. BWA index files are produced as a side-effect.
Jean-Philippe Fortin
dir <- tempdir() fasta <- system.file(package="Rbwa", "fasta/chr12.fa") bwa_build_index(fasta, index_prefix=file.path(dir,"chr12"))
dir <- tempdir() fasta <- system.file(package="Rbwa", "fasta/chr12.fa") bwa_build_index(fasta, index_prefix=file.path(dir,"chr12"))
R wrapper to run BWA alignment tool BWA-MEM.
bwa_mem(type = c("single", "paired"), index_prefix, fastq_files, sam_file, ...)
bwa_mem(type = c("single", "paired"), index_prefix, fastq_files, sam_file, ...)
type |
String specifying type of reads: "single" for single-end reads (default) or "paired" for paired-end reads. |
index_prefix |
String specifying prefix of the BWA index. |
fastq_files |
Character vector specifying paths of fastq files.
If |
sam_file |
String specifying filename of the SAM aligmment output. |
... |
Other arguments to pass to the |
No return value. Output SAM file is produced as side effect.
Jean-Philippe Fortin
dir <- tempdir() fasta <- system.file(package="Rbwa", "fasta/chr12.fa") fastq <- system.file(package="Rbwa", "fastq/sequences.fastq") index_prefix <- file.path(dir,"chr12") bwa_build_index(fasta, index_prefix=index_prefix) bwa_mem(index_prefix=index_prefix, fastq_files=fastq, sam_file=file.path(dir, "output.sam"))
dir <- tempdir() fasta <- system.file(package="Rbwa", "fasta/chr12.fa") fastq <- system.file(package="Rbwa", "fastq/sequences.fastq") index_prefix <- file.path(dir,"chr12") bwa_build_index(fasta, index_prefix=index_prefix) bwa_mem(index_prefix=index_prefix, fastq_files=fastq, sam_file=file.path(dir, "output.sam"))
R wrapper to convert bwa aln output to SAM format.
bwa_sam( type = c("single", "paired"), index_prefix, fastq_files, sai_files, sam_file, ... )
bwa_sam( type = c("single", "paired"), index_prefix, fastq_files, sai_files, sam_file, ... )
type |
String specifying type of reads: "single" for single-end reads (default) or "paired" for paired-end reads. |
index_prefix |
String specifying prefix of the BWA index. |
fastq_files |
Character vector specifying paths of fastq files.
If |
sai_files |
Character vector specifying filenames of the |
sam_file |
String specifying paths of the SAM output file. |
... |
Other arguments to pass to |
No return value. Output SAM files are produced as side effect.
Jean-Philippe Fortin
# Creating index: dir <- tempdir() fasta <- system.file(package="Rbwa", "fasta/chr12.fa") fastq <- system.file(package="Rbwa", "fastq/sequences.fastq") index_prefix <- file.path(dir,"chr12") bwa_build_index(fasta, index_prefix=index_prefix) # Creating alignments: bwa_aln(index_prefix=index_prefix, fastq_files=fastq, sai_files=file.path(dir, "output.sai")) # Generating SAM file: bwa_sam(index_prefix=index_prefix, fastq_files=fastq, sai_files=file.path(dir, "output.sai"), sam_file=file.path(dir, "output.sam")) # Reading in alignments from SAM file: aln <- readLines(file.path(dir, "output.sam")) aln
# Creating index: dir <- tempdir() fasta <- system.file(package="Rbwa", "fasta/chr12.fa") fastq <- system.file(package="Rbwa", "fastq/sequences.fastq") index_prefix <- file.path(dir,"chr12") bwa_build_index(fasta, index_prefix=index_prefix) # Creating alignments: bwa_aln(index_prefix=index_prefix, fastq_files=fastq, sai_files=file.path(dir, "output.sai")) # Generating SAM file: bwa_sam(index_prefix=index_prefix, fastq_files=fastq, sai_files=file.path(dir, "output.sai"), sam_file=file.path(dir, "output.sam")) # Reading in alignments from SAM file: aln <- readLines(file.path(dir, "output.sam")) aln
Unpack multiple alignments stored in BWA output
xa2multi(input_sam_file, output_sam_file)
xa2multi(input_sam_file, output_sam_file)
input_sam_file |
String specifying path of the input SAM file. |
output_sam_file |
String specifying path of the output SAM file. |
Each row in the SAM file produced by bwa_aln
corresponds to the best alignment hit for a given input query
sequence. Other alignments (secondary alignments, or other loci
in case of multiple alignments) are stored in the XA tag.
xa2multi
conveniently extracts the alignments from the XA
tags and represent them as additional rows in the SAM format.
Returns NULL invisibly. SAM file with multiple alignments is produced as a side effect.
Jean-Philippe Fortin
# Creating index: dir <- tempdir() fasta <- system.file(package="Rbwa", "fasta/chr12.fa") fastq <- system.file(package="Rbwa", "fastq/sequences.fastq") index_prefix <- file.path(dir,"chr12") bwa_build_index(fasta, index_prefix=index_prefix) # Creating alignments: bwa_aln(index_prefix=index_prefix, fastq_files=fastq, sai_files=file.path(dir, "output.sai")) # Generating SAM file: bwa_sam(index_prefix=index_prefix, fastq_files=fastq, sai_files=file.path(dir, "output.sai"), sam_file=file.path(dir, "output.sam")) # Generating multiple alignments: xa2multi(input_sam_file=file.path(dir, "output.sam"), output_sam_file=file.path(dir, "output.multi.sam")) #' Reading in: aln <- readLines(file.path(dir, "output.multi.sam")) aln
# Creating index: dir <- tempdir() fasta <- system.file(package="Rbwa", "fasta/chr12.fa") fastq <- system.file(package="Rbwa", "fastq/sequences.fastq") index_prefix <- file.path(dir,"chr12") bwa_build_index(fasta, index_prefix=index_prefix) # Creating alignments: bwa_aln(index_prefix=index_prefix, fastq_files=fastq, sai_files=file.path(dir, "output.sai")) # Generating SAM file: bwa_sam(index_prefix=index_prefix, fastq_files=fastq, sai_files=file.path(dir, "output.sai"), sam_file=file.path(dir, "output.sam")) # Generating multiple alignments: xa2multi(input_sam_file=file.path(dir, "output.sam"), output_sam_file=file.path(dir, "output.multi.sam")) #' Reading in: aln <- readLines(file.path(dir, "output.multi.sam")) aln