This pipeline describes the migration analysis process using Treetime Mugration. Below are the files and steps required to perform the analysis.
- Timescale Tree (
timetree.nwk) - Metadata File (
states.tsv) which should contain the following columns:
name: Name or identifier of the sequenceregion: Region associated with the sequence
The states.tsv file should be formatted as follows:
name region
Sample1 Region1
Sample2 Region2
Sample3 Region3
...Note: Make sure the
regioncolumn is formatted without spaces, special characters, or accents.
To perform the migration analysis, use the command below:
treetime mugration --tree timetree.nwk --states states.tsv --attribute region- After running the above command, go to the output folder generated by Mugration.
- Copy the
annotated_tree.nexusfile to a new folder containing thebaltic.pyandAncestralChanges.pyscripts.
- Before performing this step, you will need to make a manual adjustment to the AncestralChanges.py script.
- On line 12, you must insert the date of your newest sequence in the tree.
Once done, move on to the next step:
- In the newly created folder, run the following command in the terminal (make sure Python 3 is installed):
python3 AncestralChanges.pyThis command will generate a .csv file with three columns: Year, Origin, and Destination.
- The generated
.csvfile needs to be converted to a matrix that will serve as input for data visualization in R. - The matrix structure should follow the example available in the "inputfiles" folder, with the regions arranged in rows and columns. The values in the matrix correspond to the sum of the migration events between each pair of regions (from region X to region Y).
- To count the values to be entered in the matrix, open your annotated_tree_events.csv file.
- Suggestion: To improve data visualization in the graph, normalize the values to LOG10.
- Open RStudio and load the
circos.Rscript. - Use the matrix as input to generate the migration graph.
├── timeTree_final.nwk
├── states.tsv
├── newfolder
│ ├── AncestralChanges.py
│ ├── baltic.py
│ ├── annotated_tree.nexus
│ └── annotated_tree_events.csv
└── rstudio_files
├── circos.R
└── matriz.txt
- Prerequisites: Make sure
python3and the necessary R packages are installed.