-
Notifications
You must be signed in to change notification settings - Fork 2
/
supermatrix.smk
129 lines (115 loc) · 4.14 KB
/
supermatrix.smk
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
rule concatenate_alignments:
"""
Concatenate alignments into a single supermatrix.
https://jlsteenwyk.com/PhyKIT/usage/index.html#create-concatenation-matrix
"""
input:
rules.list_alignments.output
output:
fasta="results/supermatrix/supermatrix.{alignment_type}.fa",
partition="results/supermatrix/supermatrix.{alignment_type}.partition",
occupancy="results/supermatrix/supermatrix.{alignment_type}.occupancy",
conda:
ENV_DIR / "phykit.yaml"
# bibs:
# "../bibs/phykit.bib"
log:
LOG_DIR / "supermatrix/supermatrix.{alignment_type}.log"
shell:
"""
phykit create_concatenation_matrix --alignment {input} --prefix results/supermatrix/supermatrix.{wildcards.alignment_type} 2>&1 | tee {log}
"""
rule supermatrix_alignment_summary:
"""
Summarizes the supermatrix alignment using BioKIT
https://jlsteenwyk.com/BioKIT/usage/index.html#alignment-summary
https://jlsteenwyk.com/tutorials/phylogenomics_made_easy.html
"""
input:
rules.concatenate_alignments.output.fasta
output:
"results/supermatrix/alignment_summary.{alignment_type}.txt"
conda:
ENV_DIR / "biokit.yaml"
# bibs:
# "../bibs/biokit.bib",
log:
LOG_DIR / "supermatrix/alignment_summary.{alignment_type}.log"
shell:
"{{ biokit alignment_summary {input} > {output} ; }} 2>&1 | tee {log}"
supermatrix_outgroup = config.get("supermatrix_outgroup", SUPERMATRIX_OUTGROUP_DEFAULT)
rule supermatrix_iqtree:
"""
Use IQTREE on the supermatrix.
"""
input:
rules.concatenate_alignments.output.fasta
output:
treefile="results/supermatrix/supermatrix.{alignment_type}.treefile",
consensus_tree="results/supermatrix/supermatrix.{alignment_type}.contree",
iqtree_report="results/supermatrix/supermatrix.{alignment_type}.iqtree",
iqtree_log="results/supermatrix/supermatrix.{alignment_type}.log",
conda:
ENV_DIR / "iqtree.yaml"
# bibs:
# "../bibs/iqtree2.bib",
# "../bibs/ultrafast-bootstrap.bib",
# "../bibs/modelfinder.ris",
params:
bootstrap_string=config.get("bootstrap_string", BOOTSTRAP_STRING_DEFAULT),
model_string=config.get("model_string", MODEL_STRING_DEFAULT),
supermatrix_outgroup_string=f"-o {supermatrix_outgroup}" if supermatrix_outgroup else "",
shell:
"""
iqtree2 -s {input} \
{params.bootstrap_string} \
{params.model_string} \
{params.supermatrix_outgroup_string} \
-nt {threads} \
-redo \
-pre "results/supermatrix/supermatrix.{wildcards.alignment_type}"
"""
rule supermatrix_ascii:
"""
Displays the tree in ASCII format.
"""
input:
rules.supermatrix_iqtree.output.treefile
output:
"results/supermatrix/supermatrix_tree_ascii.{alignment_type}.txt"
conda:
ENV_DIR / "phykit.yaml"
# bibs:
# "../bibs/phykit.bib",
shell:
"phykit print_tree {input} > {output}"
rule supermatrix_tree_render:
"""
Renders the supermatrix tree in SVG and PNG formats.
"""
input:
rules.supermatrix_iqtree.output.treefile
output:
svg="results/supermatrix/supermatrix_tree_render.{alignment_type}.svg",
png="results/supermatrix/supermatrix_tree_render.{alignment_type}.png"
conda:
ENV_DIR / "toytree.yaml"
# bibs:
# "../bibs/toytree.bib",
shell:
"python {SCRIPT_DIR}/render_tree.py {input} --svg {output.svg} --png {output.png}"
rule supermatrix_consensus_tree_render:
"""
Renders the consensus supermatrix tree in SVG and PNG formats.
"""
input:
rules.supermatrix_iqtree.output.consensus_tree
output:
svg="results/supermatrix/supermatrix_consensus_tree_render.{alignment_type}.svg",
png="results/supermatrix/supermatrix_consensus_tree_render.{alignment_type}.png"
conda:
ENV_DIR / "toytree.yaml"
# bibs:
# "../bibs/toytree.bib",
shell:
"python {SCRIPT_DIR}/render_tree.py {input} --svg {output.svg} --png {output.png}"