run_bwa: Run the BWA aligner

View source: R/run_bwa.R

run_bwaR Documentation

Run the BWA aligner

Description

Runs the BWA aligner

Usage

run_bwa(
  command = NULL,
  input1 = NULL,
  input2 = NULL,
  index = NULL,
  sample.name = NULL,
  out.dir = NULL,
  threads = 10,
  seed.length = NULL,
  parallel = FALSE,
  cores = 4,
  execute = TRUE,
  bwa = NULL,
  version = FALSE
)

Arguments

command

BWA command to run, at present can choose 'mem', which is most useful fo Illumina, PacBio and Nanopore reads, required

input1

List of the paths to files containing to the forward reads, required

input2

List of the paths to files containing to the reverse reads, required for paired end sequence data

index

Path to the indexed reference genome, required

sample.name

List of sample names, required

out.dir

Name of the directory from the BWA output

threads

Number of threads for BWA to use, default set to 10

seed.length

Minimum seed length

parallel

Run in parallel, default set to FALSE

cores

Number of cores/threads to use for parallel processing, default set to 4

execute

Whether to execute the commands or not, default set to TRUE

bwa

Path to the bwa program, required

version

Returns the version number

Value

A list with the BWA commands

Examples

 ## Not run: 
 path <- "/software/bwa/bwa"

# Get version number
bwa.version <- run_bwa(bwa = path,
                       version = TRUE)
bwa.version[3] # print the line with version number

reads.path <- "/path/to/fastqs"
reads.patt.1 <- "_S\\d{1,2}\\_L001_R1_001.fastq.gz"
reads.patt.2 <- "_S\\d{1,2}\\_L001_R2_001.fastq.gz"

# Organise the samples
sample.dataframe <- prepare_samples(reads.path, c(reads.patt.1,reads.patt.2),trimmed.reads.dir)

input1 <- as.character(sample.dataframe$reads.path.1)
input1.trim <- as.character(sample.dataframe$trimmed.reads.path.1)
# Paired end only
 input2 <- as.character(sample.dataframe$reads.path.2)
 input2.trim <- as.character(sample.dataframe$trimmed.reads.path.2)

sample.names <- as.character(sample.dataframe$sample.names)

genome <- "/path/to/reference/genome"

command <- "mem"
out.dir <- "bwa_alignments"

# Paired end
pe <- run_bwa(command = command,
              input1 = mate1.trim,
              input2 = mate2.trim,
              index = genome,
              threads = 20,
              out.dir = out.dir,
              sample.name = sample.names,
              seed.length = 21,
              bwa = path)

# Single end
se <- run_bwa(command = command,
              input1 = mate1.trim,
              index = genome,
              threads = 20,
              out.dir = out.dir,
              sample.name = sample.names,
              seed.length = 21,
              bwa = path)

## End(Not run)


GrahamHamilton/pipelineTools documentation built on March 5, 2024, 12:23 p.m.