-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path4_astral_script.sh
158 lines (103 loc) · 9.33 KB
/
4_astral_script.sh
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
#!/bin/bash
###########################################################################
# Project: Orania Phylogeny MT
# Script: alignment_script.sh
# --- Action: This script builds a coalescent tree using Astral.
# --- Input: genetrees from raxml
# --- Output: coalescent species tree and tree of individuals
# Author: Maya Schroedl ([email protected])
###########################################################################
###################
#----ARGUMENTS----#
###################
#t:if you want trimmed contigs, based on coverage and threshold, enter t:threshold
#o: outgroup (TAG)
#l: labeled outgroup (individual name)
while getopts ":t:o:l:" opt; do
case ${opt} in
t)
echo "-t was triggered, File: $OPTARG"
t=$OPTARG
;;
o)
echo "-o was triggered, Outgroup: $OPTARG"
outgroup=$OPTARG
;;
l)
echo "-l was triggered, labeled Outgroup: $OPTARG"
outgroup_lab=$OPTARG
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
esac
done
#################################
#----DIRECTORIES & VARIABLES----#
#################################
#working directories
GWD=$PWD #global working directory, with subprojects and scripts
WD="$GWD"/1_phylo_reconstruction #current working directory
if ! [ -z "$t" ]; #if there is a threshold definded, then work in the threshold directory
then
dir_value=$t/
fi
mkdir -p $WD/4_coalescent_trees/$dir_value
################
#----ASTRAL----#
################
cd $WD/4_coalescent_trees/$dir_value
rm *
#ASTRAL tree with tips representing individuals (individuals of same species are not merged into one species tip) (extended sptree)
#execute with branch support as local posterior probabilities (lpp) [default]
java -jar $GWD/programs/Constrained-search/Astral/astral.5.6.9.jar -i $WD/3_gene_trees/"$dir_value"4_collapsed/all_genes.raxml.support.coll -o $WD/4_coalescent_trees/"$dir_value"coalescent_lpp.tree 2>$WD/4_coalescent_trees/"$dir_value"coalescent_lpp.log
#execute with branch support as all quartet supports [all alternatives] (qs) [-t 8]
java -jar $GWD/programs/Constrained-search/Astral/astral.5.6.9.jar -t 8 -i $WD/3_gene_trees/"$dir_value"4_collapsed/all_genes.raxml.support.coll -o $WD/4_coalescent_trees/"$dir_value"coalescent_qs_all.tree 2>$WD/4_coalescent_trees/"$dir_value"coalescent_qs_all.log
#execute with branch support as quartet supports (qs) [-t 1]
java -jar $GWD/programs/Constrained-search/Astral/astral.5.6.9.jar -t 1 -i $WD/3_gene_trees/"$dir_value"4_collapsed/all_genes.raxml.support.coll -o $WD/4_coalescent_trees/"$dir_value"coalescent_qs.tree 2>$WD/4_coalescent_trees/"$dir_value"coalescent_qs.log
#ASTRAL tree with tips representing species (individuals of same species are merged into one species tip) ("-a" otion = "ASTRAL-multi")
#execute with branch support as local posterior probabilities (lpp) [default]
java -jar $GWD/programs/Constrained-search/Astral/astral.5.6.9.jar -i $WD/3_gene_trees/"$dir_value"4_collapsed/all_genes.raxml.support.coll -o $WD/4_coalescent_trees/"$dir_value"coalescent_lpp_idmerg.tree -a $WD/input_reads_and_info/astral_name_mapping.txt 2>$WD/4_coalescent_trees/"$dir_value"coalescent_lpp_idmerg.log
#execute with branch support as all quartet supports [all alternatives] (qs) [-t 8]
java -jar $GWD/programs/Constrained-search/Astral/astral.5.6.9.jar -t 8 -i $WD/3_gene_trees/"$dir_value"4_collapsed/all_genes.raxml.support.coll -o $WD/4_coalescent_trees/"$dir_value"coalescent_qs_all_idmerg.tree -a $WD/input_reads_and_info/astral_name_mapping.txt 2>$WD/4_coalescent_trees/"$dir_value"coalescent_qs_all_idmerg.log
#execute with branch support as quartet supports (qs) [-t 1]
java -jar $GWD/programs/Constrained-search/Astral/astral.5.6.9.jar -t 1 -i $WD/3_gene_trees/"$dir_value"4_collapsed/all_genes.raxml.support.coll -o $WD/4_coalescent_trees/"$dir_value"coalescent_qs_idmerg.tree -a $WD/input_reads_and_info/astral_name_mapping.txt 2>$WD/4_coalescent_trees/"$dir_value"coalescent_qs_idmerg.log
#### constrain not-monophyletic species to monophyly, to test how probable monophyly would be. this is possible with the astral -j option (astral 5.6.9)
java -jar $GWD/programs/Constrained-search/Astral/astral.5.6.9.jar -i $WD/3_gene_trees/"$dir_value"4_collapsed/all_genes.raxml.support.coll -o $WD/4_coalescent_trees/"$dir_value"coalescent_lpp_constr_palindan.tree -j $WD/input_reads_and_info/astral_constr_palindan.txt 2>$WD/4_coalescent_trees/"$dir_value"coalescent_lpp_constr_palindan.log
java -jar $GWD/programs/Constrained-search/Astral/astral.5.6.9.jar -i $WD/3_gene_trees/"$dir_value"4_collapsed/all_genes.raxml.support.coll -o $WD/4_coalescent_trees/"$dir_value"coalescent_lpp_constr_lauterb.tree -j $WD/input_reads_and_info/astral_constr_lauterb.txt 2>$WD/4_coalescent_trees/"$dir_value"coalescent_lpp_constr_lauterb.log
java -jar $GWD/programs/Constrained-search/Astral/astral.5.6.9.jar -i $WD/3_gene_trees/"$dir_value"4_collapsed/all_genes.raxml.support.coll -o $WD/4_coalescent_trees/"$dir_value"coalescent_lpp_constr_palindan_and_lauterb.tree -j $WD/input_reads_and_info/astral_constr_palindan_and_lauterb.txt 2>$WD/4_coalescent_trees/"$dir_value"coalescent_lpp_constr_palindan_and_lauterb.log
#############################
#----LABEL SPECIES TREES----#
#############################
#### unlabeled individual trees (extended sp tree) --> add label (species names)
#with branch support as local posterior probabilities (lpp) [default]
Rscript $GWD/scripts/general/change_tiplabels.R $WD/4_coalescent_trees/"$dir_value"coalescent_lpp.tree $WD/4_coalescent_trees/"$dir_value"coalescent_lpp.tree_lab $WD/input_reads_and_info/tags_indiv.txt
#with branch support as all quartet supports [all alternatives] (qs) [-t 8]
Rscript $GWD/scripts/general/change_tiplabels.R $WD/4_coalescent_trees/"$dir_value"coalescent_qs_all.tree $WD/4_coalescent_trees/"$dir_value"coalescent_qs_all.tree_lab $WD/input_reads_and_info/tags_indiv.txt
#with branch support as quartet supports (qs) [-t 1]
Rscript $GWD/scripts/general/change_tiplabels.R $WD/4_coalescent_trees/"$dir_value"coalescent_qs.tree $WD/4_coalescent_trees/"$dir_value"coalescent_qs.tree_lab $WD/input_reads_and_info/tags_indiv.txt
###constrained trees
Rscript $GWD/scripts/general/change_tiplabels.R $WD/4_coalescent_trees/"$dir_value"coalescent_lpp_constr_palindan.tree $WD/4_coalescent_trees/"$dir_value"coalescent_lpp_constr_palindan.tree_lab $WD/input_reads_and_info/tags_indiv.txt
Rscript $GWD/scripts/general/change_tiplabels.R $WD/4_coalescent_trees/"$dir_value"coalescent_lpp_constr_lauterb.tree $WD/4_coalescent_trees/"$dir_value"coalescent_lpp_constr_lauterb.tree_lab $WD/input_reads_and_info/tags_indiv.txt
Rscript $GWD/scripts/general/change_tiplabels.R $WD/4_coalescent_trees/"$dir_value"coalescent_lpp_constr_palindan_and_lauterb.tree $WD/4_coalescent_trees/"$dir_value"coalescent_lpp_constr_palindan_and_lauterb.tree_lab $WD/input_reads_and_info/tags_indiv.txt
######################
#----REROOT TREES----#
######################
######for unlabeled tree of individuals (extended sptree)
Rscript $GWD/scripts/general/root_tree.R $WD/4_coalescent_trees/"$dir_value"coalescent_lpp.tree $WD/4_coalescent_trees/"$dir_value"coalescent_lpp.tree_rooted $outgroup
Rscript $GWD/scripts/general/root_tree.R $WD/4_coalescent_trees/"$dir_value"coalescent_qs_all.tree $WD/4_coalescent_trees/"$dir_value"coalescent_qs_all.tree_rooted $outgroup
Rscript $GWD/scripts/general/root_tree.R $WD/4_coalescent_trees/"$dir_value"coalescent_qs.tree $WD/4_coalescent_trees/"$dir_value"coalescent_qs.tree_rooted $outgroup
#####for labeled tree of individuals (extended sptree)
Rscript $GWD/scripts/general/root_tree.R $WD/4_coalescent_trees/"$dir_value"coalescent_lpp.tree_lab $WD/4_coalescent_trees/"$dir_value"coalescent_lpp.tree_lab_rooted $outgroup_lab
Rscript $GWD/scripts/general/root_tree.R $WD/4_coalescent_trees/"$dir_value"coalescent_qs_all.tree_lab $WD/4_coalescent_trees/"$dir_value"coalescent_qs_all.tree_lab_rooted $outgroup_lab
Rscript $GWD/scripts/general/root_tree.R $WD/4_coalescent_trees/"$dir_value"coalescent_qs.tree_lab $WD/4_coalescent_trees/"$dir_value"coalescent_qs.tree_lab_rooted $outgroup_lab
#####for species tree ("-a" otion = "ASTRAL-multi")
Rscript $GWD/scripts/general/root_tree.R $WD/4_coalescent_trees/"$dir_value"coalescent_lpp_idmerg.tree $WD/4_coalescent_trees/"$dir_value"coalescent_lpp_idmerg.tree_rooted $outgroup_lab
Rscript $GWD/scripts/general/root_tree.R $WD/4_coalescent_trees/"$dir_value"coalescent_qs_idmerg.tree $WD/4_coalescent_trees/"$dir_value"coalescent_qs_idmerg.tree_rooted $outgroup_lab
Rscript $GWD/scripts/general/root_tree.R $WD/4_coalescent_trees/"$dir_value"coalescent_qs_all_idmerg.tree $WD/4_coalescent_trees/"$dir_value"coalescent_qs_all_idmerg.tree_rooted $outgroup_lab
#### labeled constrained trees
Rscript $GWD/scripts/general/root_tree.R $WD/4_coalescent_trees/"$dir_value"coalescent_lpp_constr_palindan.tree_lab $WD/4_coalescent_trees/"$dir_value"coalescent_lpp_constr_palindan.tree_lab_rooted $outgroup_lab
Rscript $GWD/scripts/general/root_tree.R $WD/4_coalescent_trees/"$dir_value"coalescent_lpp_constr_lauterb.tree_lab $WD/4_coalescent_trees/"$dir_value"coalescent_lpp_constr_lauterb.tree_lab_rooted $outgroup_lab
Rscript $GWD/scripts/general/root_tree.R $WD/4_coalescent_trees/"$dir_value"coalescent_lpp_constr_palindan_and_lauterb.tree_lab $WD/4_coalescent_trees/"$dir_value"coalescent_lpp_constr_palindan_and_lauterb.tree_lab_rooted $outgroup_lab
cd $GWD