File: last-tutorial.txt

package info (click to toggle)
last-align 830-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,240 kB
  • ctags: 3,201
  • sloc: cpp: 40,808; python: 1,910; ansic: 1,188; makefile: 385; sh: 232
file content (260 lines) | stat: -rw-r--r-- 10,243 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
LAST Tutorial
=============

LAST finds similar regions between sequences, and aligns them.

Example 1: Compare the human and fugu mitochondrial genomes
-----------------------------------------------------------

For our first example, we wish to find and align similar regions
between the human and fugu mitochondrial genomes.  You can find these
sequences in the examples directory: humanMito.fa and fuguMito.fa.  We
can compare them like this::

  lastdb -cR01 humdb humanMito.fa
  lastal humdb fuguMito.fa > myalns.maf

The lastdb command creates several files whose names begin with
"humdb".  The lastal command then compares fuguMito.fa to the humdb
files, and writes the alignments to a file called "myalns.maf".

The "-cR01" option suppresses alignments caused by simple sequence
such as cacacacacacacacacacacaca.

Understanding the output
------------------------

The output has very long lines, so you need to view it without
line-wrapping.  For example, with a Unix/Linux/MacOsX command line,
you can use::

  less -S myalns.maf

Each alignment looks like this::

  a score=27 EG2=4.7e+04 E=2.6e-05
  s humanMito 2170 145 + 16571 AGTAGGCCTAAAAGCAGCCACCAATTAAGAAAGCGTT...
  s fuguMito  1648 142 + 16447 AGTAGGCTTAGAAGCAGCCACCA--CAAGAAAGCGTT...

The score is a measure of how significant the similarity is.  EG2 and
E are explained at `<last-evalues.html>`_.  Lines starting with "s"
contain: the sequence name, the start coordinate of the alignment, the
number of bases spanned by the alignment, the strand, the sequence
length, and the aligned bases.

The start coordinates are zero-based.  This means that, if the
alignment begins right at the start of a sequence, the coordinate is
0.  If the strand is "-", the start coordinate is in the reverse
strand.

This alignment format is called `MAF (multiple alignment format)
<http://genome.ucsc.edu/FAQ/FAQformat.html#format5>`_.  You can
convert it to several other formats using `maf-convert
<maf-convert.html>`_.  You can make lastal produce a few other formats
with option -f (see `<lastal.html>`_).

Example 2: Compare vertebrate proteins to invertebrate proteins
---------------------------------------------------------------

Use the lastdb -p option to indicate that the sequences are proteins::

  lastdb -p -cR01 invdb invertebrate.fa
  lastal invdb vertebrate.fa

Example 3: Compare DNA sequences to protein sequences
-----------------------------------------------------

Here we use the -F15 option, to specify translated alignment with a
score penalty of 15 for frameshifts::

  lastdb -p -cR01 protdb proteins.fa
  lastal -F15 protdb dnas.fa

Example 4: Find short protein alignments
----------------------------------------

LAST uses a `scoring scheme <last-matrices.html>`_ to find
similarities.  Some scoring schemes are good for long-and-weak
similarities, others for short-and-strong similarities.  If we seek
very short similarities, weak ones are hopeless (statistically
insignificant), so we had better focus on strong ones.  The PAM30
scoring scheme may work well::

  lastdb -p -cR01 invdb invertebrate.fa
  lastal -pPAM30 invdb vertebrate.fa

(How short is "very short"?  It depends on the amount of sequence data
we are searching, but perhaps roughly less than 40 amino acids.)

Example 5: Align human DNA sequences to the human genome
--------------------------------------------------------

We can align human DNA sequences to the human genome like this::

  lastdb -uNEAR -R01 humandb human/chr*.fa
  lastal humandb queries.fa | last-split > myalns.maf

This will use about 15 gigabytes of memory.

* -uNEAR selects a `seeding scheme <last-seeds.html>`_ that makes it
  better at finding short-and-strong similarities.  (It also changes
  the default scoring scheme.)

* -R01 tells it to mark simple sequences (such as cacacacacacacacaca)
  by lowercase, but not suppress them.  This has no effect on the
  alignment, but it allows us to see simple sequences in the output,
  and gives us the option to do `post-alignment masking
  <last-postmask.html>`_.

* last-split reads the alignments produced by lastal, and looks for a
  unique best alignment for each part of each query.  It allows
  different parts of one query to match different parts of the genome,
  which may happen due to rearrangements.  It has several useful
  options, please see `<last-split.html>`_.

Example 6: Find very short DNA alignments
-----------------------------------------

By default, LAST is quite strict, and only reports significant
alignments that will rarely occur by chance.  In the preceding
example, the minimum alignment length is about 28 bases (less for
smaller genomes).  To find shorter alignments, we must down-tune the
strictness::

  lastdb -uNEAR -R01 humandb human/chr*.fa
  lastal -D100 humandb queries.fa | last-split -m1 > myalns.maf

* -D100 makes lastal report alignments that could occur by chance once
  per hundred query letters.  (The default is once per million.)

* -m1 tells last-split to keep low-confidence alignments.

In this example, the minimum alignment length is about 20 bases (less
for smaller genomes).

Example 7: Align human fastq sequences to the human genome
----------------------------------------------------------

DNA sequences are not always perfectly accurate, and they are
sometimes provided in fastq format, which indicates the reliability of
each base.  LAST can use this information to improve alignment
accuracy.  (It assumes the reliabilities reflect substitution errors,
not insertion/deletion errors: if that is not true, it may be better
to use fasta format.)  Option -Q1 indicates fastq-sanger format::

  lastdb -uNEAR -R01 humandb human/chr*.fa
  lastal -Q1 -D100 humandb queries.fastq | last-split > myalns.maf

Fastq format confusion
----------------------

Unfortunately, there is more than one fastq format (see
http://nar.oxfordjournals.org/content/38/6/1767.long).  Recently
(2013) fastq-sanger seems to be dominant, but if you have another
variant you need to change the -Q option (see `<lastal.html>`_).

Paired reads
------------

If you have paired reads, there are two options:

1. Use last-pair-probs (see `<last-pair-probs.html>`_).

2. Ignore the pairing information, and align the reads individually
   (using last-split as above).  This may be useful because
   last-pair-probs does not currently allow different parts of one
   read to match different parts of the genome, though it does allow
   the two reads in a pair to match (e.g.) different chromosomes.

Tuning speed, sensitivity, memory and disk usage
------------------------------------------------

* You can make LAST faster by `using multiple CPUs
  <last-parallel.html>`_.

* You can `trade off speed, sensitivity, memory and disk usage
  <last-tuning.html>`_.

Example 8: Compare the cat and rat genomes
------------------------------------------

If you have ~50 GB of memory and don't mind waiting a few days, this
is a good way to compare such genomes::

  lastdb -uMAM8 -cR11 catdb cat.fa
  lastal -m100 -E0.05 catdb rat.fa | last-split -m1 > out.maf

This looks for a unique best alignment for each part of each rat
chromosome.  Omitting -m100 makes it faster but somewhat less
sensitive.  Omitting -uMAM8 reduces the memory use to ~10 GB and makes
it faster but considerably less sensitive.

This recipe aligns each rat base-pair to at most one cat base-pair,
but not necessarily vice-versa.  You can get strictly 1-to-1
alignments by swapping the sequences and running last-split again::

  maf-swap out.maf | last-split -m1 > out2.maf

Example 9: Compare the human and chimp genomes
----------------------------------------------

For strongly similar genomes (e.g. 99% identity), something like this
is more appropriate::

  lastdb -uNEAR -cR11 human human.fa
  lastal -m50 -E0.05 human chimp.fa | last-split -m1 > out.maf

Example 10: Ambiguity of alignment columns
------------------------------------------

Consider this alignment::

  TGAAGTTAAAGGTATATGAATTCCAATTCTTAACCCCCCTATTAAACGAATATCTTG
  |||||||| ||||||  |  ||  | |  |    || ||||||   |||||||||||
  TGAAGTTAGAGGTAT--GGTTTTGAGTAGT----CCTCCTATTTTTCGAATATCTTG

The middle section has such weak similarity that its precise alignment
cannot be confidently inferred.

It is sometimes useful to estimate the ambiguity of each column in an
alignment.  We can do that using lastal option -j4::

  lastdb -cR01 humdb humanMito.fa
  lastal -j4 humdb fuguMito.fa > myalns.maf

The output looks like this::

  a score=17 EG2=9.3e+09 E=5e-06
  s seqX 0 57 + 57 TGAAGTTAAAGGTATATGAATTCCAATTCTTAACCCCCCTATTAAACGAATATCTTG
  s seqY 0 51 + 51 TGAAGTTAGAGGTAT--GGTTTTGAGTAGT----CCTCCTATTTTTCGAATATCTTG
  p                %*.14442011.(%##"%$$$$###""!!!""""&'(*,340.,,.~~~~~~~~~~~

The "p" line indicates the probability that each column is wrongly
aligned, using a compact code (the same as fastq-sanger format):

  ======  =================   ======  =================
  Symbol  Error probability   Symbol  Error probability
  ------  -----------------   ------  -----------------
  ``!``   0.79 -- 1           ``0``   0.025 -- 0.032
  ``"``   0.63 -- 0.79        ``1``   0.02  -- 0.025
  ``#``   0.5  -- 0.63        ``2``   0.016 -- 0.02
  ``$``   0.4  -- 0.5         ``3``   0.013 -- 0.016
  ``%``   0.32 -- 0.4         ``4``   0.01  -- 0.013
  ``&``   0.25 -- 0.32        ``5``   0.0079 -- 0.01
  ``'``   0.2  -- 0.25        ``6``   0.0063 -- 0.0079
  ``(``   0.16 -- 0.2         ``7``   0.005  -- 0.0063
  ``)``   0.13 -- 0.16        ``8``   0.004  -- 0.005
  ``*``   0.1  -- 0.13        ``9``   0.0032 -- 0.004
  ``+``   0.079 -- 0.1        ``:``   0.0025 -- 0.0032
  ``,``   0.063 -- 0.079      ``;``   0.002  -- 0.0025
  ``-``   0.05  -- 0.063      ``<``   0.0016 -- 0.002
  ``.``   0.04  -- 0.05       ``=``   0.0013 -- 0.0016
  ``/``   0.032 -- 0.04       ``>``   0.001  -- 0.0013
  ======  =================   ======  =================

Note that each alignment is grown from a "core" region, and the
ambiguity estimates assume that the core is correctly aligned.  The
core is indicated by "~" symbols, and it contains exact matches only.

LAST has options to find alignments with optimal column probabilities,
instead of optimal score: see `<lastal.html>`_.