From 2409c2377635cb28e07b01d12ab059804b56f6c3 Mon Sep 17 00:00:00 2001 From: Mahwash Jamy <40695699+mjamy@users.noreply.github.com> Date: Fri, 17 Jun 2022 12:54:02 +0200 Subject: [PATCH] Update README.md --- README.md | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/README.md b/README.md index 07c05b7..a167d96 100644 --- a/README.md +++ b/README.md @@ -678,5 +678,71 @@ for i in *Log.rates.txt; do header=$(grep "Lh" Apicomplexa/Apicomplexa.rooted.RA ``` +#### 6.2.2 Normalised transition rates +Run BayesTraits to get normalised transition rates irrespective of direction. + +The analysis is the same as before but with the `NormaliseQMatrix` command added to the commands file. + + +## 7 PastML analyses + +To find the relative timing of transitions events we use PastML. However, we first need to convert the phylogenies to chronograms. + +Convert phylogenies into ultrametric trees using Pathd8. + +Add sequence length at the beginning of each tree file. For this, create a file called sequence_length.txt. + +``` +cat sequence_length.txt +Sequence length = 7160; +``` + +``` +for i in */*tree; do cat sequence_length.txt $i > "$i".pathd8.in; done +``` + +Run PATHd8! +``` +for i in */*pathd8.in; do PATHd8 $i "$i".out; done +``` + +Remove input files now. +``` +for i in */*pathd8.in; do rm $i; done +``` + +Get the tree/chronogram from the output. +``` +for i in */*out; do out=$(echo $i | sed -E 's/pathd8.in.out/dated/'); grep "d8 tree" $i | sed -E 's/d8 tree : //' > $out; done +``` + +Remove the pathd8 output to save space. + +``` +for i in */*pathd8.in.out; do rm $i; done +``` + +Now run PASTML on the chronograms following the manual. The output files need to be formatted though so that they can be parsed by ETE. This is done as follows: + +``` +## Format to remove the annotations at the node so that ete is happy with newick files +for i in */*/named.tree*; do cat $i | sed -E 's/n[0-9]+\:/\:/g' | sed -E 's/root//g' > "$i".ete; done +``` + +Calculate no. of transitions. + +``` +for i in */*/*ete; do clade=$(echo $i | sed -E 's/([^/*])\/.*/\1/'); python scripts_transitions/transition_counter_MT_conservative.py $i >> "$clade"/"$clade".transition_counts_MT_conservative.txt; done +for i in */*/*ete; do clade=$(echo $i | sed -E 's/([^/*])\/.*/\1/'); python scripts_transitions/transition_counter_TM_conservative.py $i >> "$clade"/"$clade".transition_counts_TM_conservative.txt; done +``` + +...and timing of transitions. + +``` +for i in */*/*ete; do clade=$(echo $i | sed -E 's/([^/*])\/.*/\1/'); python scripts_transitions/transition_time_MT_conservative.py $i >> "$clade"/"$clade".transition_time_MT_conservative.txt; done +for i in */*/*ete; do clade=$(echo $i | sed -E 's/([^/*])\/.*/\1/'); python scripts_transitions/transition_time_TM_conservative.py $i >> "$clade"/"$clade".transition_time_TM_conservative.txt; done +``` + +Put these together and plot in R.