Debian Codegraph @

docs/source/tutorials/ancestral.rst

raw
1
2 Ancestral sequence reconstruction using TreeTime
3 ------------------------------------------------
4
5 At the core of TreeTime is a class that models how sequences change along the tree.
6 This class allows to reconstruct likely sequences of internal nodes of the tree.
7 On the command-line, ancestral reconstruction can be done via the command
8
9 .. code-block:: bash
10
11 treetime ancestral --aln data/h3n2_na/h3n2_na_20.fasta --tree data/h3n2_na/h3n2_na_20.nwk --outdir ancestral_results
12
13 This command will save a number of files into the directory `ancestral_results` and generate the output
14
15 .. code-block:: bash
16
17 Inferred GTR model:
18 Substitution rate (mu): 1.0
19
20 Equilibrium frequencies (pi_i):
21 A: 0.2983
22 C: 0.1986
23 G: 0.2353
24 T: 0.2579
25 -: 0.01
26
27 Symmetrized rates from j->i (W_ij):
28 A C G T -
29 A 0 0.8273 2.8038 0.4525 1.031
30 C 0.8273 0 0.5688 2.8435 1.0561
31 G 2.8038 0.5688 0 0.6088 1.0462
32 T 0.4525 2.8435 0.6088 0 1.0418
33 - 1.031 1.0561 1.0462 1.0418 0
34
35 Actual rates from j->i (Q_ij):
36 A C G T -
37 A 0 0.2468 0.8363 0.135 0.3075
38 C 0.1643 0 0.1129 0.5646 0.2097
39 G 0.6597 0.1338 0 0.1432 0.2462
40 T 0.1167 0.7332 0.157 0 0.2686
41 - 0.0103 0.0106 0.0105 0.0104 0
42
43 --- alignment including ancestral nodes saved as
44 ancestral_results/ancestral_sequences.fasta
45
46 --- tree saved in nexus format as
47 ancestral_results/annotated_tree.nexus
48
49 TreeTime has inferred a GTR model and used it to reconstruct the most likely ancestral sequences.
50 The reconstructed sequences will be written to a file ending in ``_ancestral.fasta`` and a tree with mutations mapped to branches will be saved in nexus format in a file ending on ``_mutation.nexus``.
51 Mutations are added as comments to the nexus file like ``[&mutations="G27A,A58G,A745G,G787A,C1155T,G1247A,G1272A"]``.
52
53 Amino acid sequences
54 ^^^^^^^^^^^^^^^^^^^^
55
56 Ancestral reconstruction of amino acid sequences works analogously to nucleotide sequences.
57 However, the user has to either explicitly choose an amino acid substitution model (JTT92)
58
59 .. code-block:: bash
60
61 treetime ancestral --tree data/h3n2_na/h3n2_na_20.nwk --aln data/h3n2_na/h3n2_na_20_aa.fasta --gtr JTT92
62
63 or specify that this is a protein sequence alignment using the flag ``--aa``\ :
64
65 .. code-block:: bash
66
67 treetime ancestral --tree data/h3n2_na/h3n2_na_20.nwk --aln data/h3n2_na/h3n2_na_20_aa.fasta --aa
68
69 VCF files as input
70 ^^^^^^^^^^^^^^^^^^
71
72 In addition to standard fasta files, TreeTime can ingest sequence data in form of vcf files which is common for bacterial data sets where short reads are mapped against a reference and only variable sites are reported.
73 In this case, an additional argument specifying the mapping reference is required.
74
75 .. code-block:: bash
76
77 treetime ancestral --aln data/tb/lee_2015.vcf.gz --vcf-reference data/tb/tb_ref.fasta --tree data/tb/lee_2015.nwk
78
79 The ancestral reconstruction is saved as a vcf files with the name ``ancestral_sequences.vcf``.
80