Tip | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||
Use our summer school reservation (CoreNGS ) when submitting batch jobs to get higher priority on the idev -m 180 -N 1 -A OTH21164 -r CoreNGS-Thu ls6 normal queue.
Note that the reservation name (CoreNGS) is different from the TACC allocation/project for this class, which is OTH21164. |
Table of Contents |
---|
Overview
...
Code Block | ||||
---|---|---|---|---|
| ||||
idev -m 180 -N 1 -A OTH21164 -r CoreNGS-Thu |
Then stage the sample datasets and references we will use.
...
Reference | Species | Base Length | Contig Number | Source | Download |
---|---|---|---|---|---|
hg19 | Human | 3.1 Gbp | 25 (really 93) | UCSC | UCSC GoldenPath |
sacCer3 | Yeast | 12.2 Mbp | 17 | UCSC | UCSC GoldenPath |
mirbase v20 | Human subset | 160 Kbp | 1908 | miRBase | miRBase Downloads |
vibCho (O395) | Vibrio cholerae | ~4 Mbp | 2 | GenBank | GenBank Downloads |
...
We've discovered a pattern (also known as a regular expression) to use in searching, and the command line tool that does regular expression matching is grep (general regular expression parser). (Read more about grep and regular expressions)
Regular expressions are so powerful that nearly every modern computer language includes a "regex" module of some sort. There are many online tutorials for regular expressions, and several slightly different "flavors" of them. But the most common is the Perl style (http://perldoc.perl.org/perlretut.html), which was one of the fist and still the most powerful (there's a reason Perl was used extensively when assembling the human genome). We're only going to use simple regular expressions here, but learning more about them will pay handsome dividends for you in the future.
...
- The -P option tells grep to Perl-style regular expression patterns.
- This makes including special characters like Tab ( \t ), carriage return ( \r ) or linefeed ( \n ) much easier that the default POSIX paterns.
- While it is not required here, it generally doesn't hurt to include this option.
'^>' is the regular expression describing the pattern we're looking for (described below)
- sacCer3.fa is the file to search.
- lines with text that match our pattern will be written to standard output
- non matching lines will be omitted
- We pipe to more just in case there are a lot of contig names.
...
As we have seen, during command line parsing and evaluation the shell will often look for special metacharacters on the command line that mean something to it (for example, the $ in front of an environment variable name, like in $SCRATCH). Well, regular expressions treat the $ specially too – but in a completely different way! Those single quotes tell the shell "don't look inside here for special characters – treat this as a literal string and pass it to the program". The shell will obey, will strip the single quotes off the string, and will pass the actual pattern, ^>, to the grep program. (Read more about about Literal characters and metacharacters and Quoting in the shell)
So what does ^> mean to grep? We know that contig name lines always start with a > character, so > is a literal for grep to use in its pattern match.
...
alignment type | aligner options | pro's | con's |
---|---|---|---|
global with bwa | single end reads:
paired end reads:
|
|
|
global with bowtie2 | bowtie2 |
|
|
local with bwa | bwa mem |
|
|
local with bowtie2 | bowtie2 --local |
|
|
...
We're going to skip the trimming step for now and see how it goes. We'll perform steps 2 - 5 now and leave , leaving samtools for a later exercise since steps 6 - 10 are common to nearly all post-alignment workflows.
...
Code Block | ||||
---|---|---|---|---|
| ||||
idev -m 180 -N 1 -A OTH21164 -r CoreNGS-Thu # or -A TRA23004 idev -m 90120 -N 1 -A OTH21164 -p development # or -A TRA23004 |
Code Block | ||
---|---|---|
| ||
module load biocontainers # takes a while module load bwa bwa |
...
Expand | |||||
---|---|---|---|---|---|
| |||||
The last few lines of bwa's execution output should look something like this:
So the R2 alignment took ~78 ~85 seconds (~1.3 4 minutes). |
Since you have your own private compute node, you can use all its resources. It has 128 cores, so re-run the R2 alignment asking for 60 execution threads.
...
Expand | |||||
---|---|---|---|---|---|
| |||||
The last few lines of bwa's execution output should look something like this:
So the R2 alignment took only ~5 ~8 seconds (real time), or 1510+ times as fast as with only one processing thread. Note, though, that the CPU time with 60 threads was greater (142.8 ~180 sec) than with only 1 thread (77.6 ~85 sec). That's because of the thread management overhead when using multiple threads. |
...
Code Block | ||||
---|---|---|---|---|
| ||||
tail yeast_pe.sam | cut -f 3 |
By default cut assumes the field delimiter is Tab, which is the delimiter used in the majority of NGS file formats. You can specify a different delimiter with the -d option.
...
Code Block | ||||
---|---|---|---|---|
| ||||
grep -v -P '^@' yeast_pe.sam | cut -f 3 | grep -v '*' | wc -l |
Read more at Some Linux commands: Advanced commands
Exercise: About how many records represent aligned sequences? What alignment rate does this represent?
Expand | |||||||
---|---|---|---|---|---|---|---|
| |||||||
The expression above returns 612,968. There were 1,184,360 records total, so the percentage is:
or about 51%. Not great. Note we perform this calculation in awk's BEGIN block, which is always executed, instead of the body block, which is only executed for lines of input. And here we call awk without piping it any input. See Linux fundamentals: cut,sort,uniq,grep,awk |
Exercise: What might we try in order to improve the alignment rate?
...
Expand | |||||||
---|---|---|---|---|---|---|---|
| |||||||
|
Code Block | ||
---|---|---|
| ||
# If not already loaded module load biocontainers # takes a while module load samtools samtools |
...
Exercise: What samtools view option will include the header records in its output? Which option would show only the header records?
Expand | ||
---|---|---|
| ||
Note that samtools (like bwa) writes its help to standard error, but less and more only accept input on standard input. So the syntax redirecting standard error to standard input must be used before the pipe to less or more. samtools view 2>&1 | less then search for "header" ( /header ) |
Expand | ||
---|---|---|
| ||
samtools view -h shows header records along with alignment records. samtools view -H shows header records only. |
...
Here we use the tee command which reports its standard input outputto standard output before also writing it to the specified file.
...