Read mapping with BWA-MEM
The NGS reads of this project are aligned against the reference genome
sequence using the highly variant tolerant short read aligner BWA-MEM
(Li , 2013; Li et al., 2009). The parameter settings of the aligner are
defined in the bwa.param
file.
args <- systemArgs(sysma="param/bwa.param", mytargets="targets.txt")
sysargs(args)[1] # Command-line parameters for first FASTQ file
Runs the alignments sequentially (e.g. on a single machine)
moduleload(modules(args))
system("bwa index -a bwtsw ./data/tair10.fasta")
bampaths <- runCommandline(args=args)
writeTargetsout(x=args, file="targets_bam.txt", overwrite=TRUE)
Alternatively, the alignment jobs can be submitted to a compute cluster,
here using 72 CPU cores (18 qsub
processes each with 4 CPU cores).
moduleload(modules(args))
system("bwa index -a bwtsw ./data/tair10.fasta")
resources <- list(walltime="1:00:00", ntasks=1, ncpus=cores(args), memory="10G")
reg <- clusterRun(args, conffile=".BatchJobs.R", template="slurm.tmpl", Njobs=18, runid="01",
resourceList=resources)
waitForJobs(reg)
writeTargetsout(x=args, file="targets_bam.txt", overwrite=TRUE)
Check whether all BAM files have been created
file.exists(outpaths(args))
Read and alignment stats
The following generates a summary table of the number of reads in each sample and how many of them aligned to the reference.
read_statsDF <- alignStats(args=args)
write.table(read_statsDF, "results/alignStats.xls", row.names=FALSE, quote=FALSE, sep="\t")
Create symbolic links for viewing BAM files in IGV
The symLink2bam
function creates symbolic links to view the BAM alignment files in a
genome browser such as IGV. The corresponding URLs are written to a file
with a path specified under urlfile
, here IGVurl.txt
.
symLink2bam(sysargs=args, htmldir=c("~/.html/", "projects/gen242/"),
urlbase="http://biocluster.ucr.edu/~tgirke/",
urlfile="./results/IGVurl.txt")

