-
Notifications
You must be signed in to change notification settings - Fork 0
/
Example_Script.R
135 lines (109 loc) · 4.57 KB
/
Example_Script.R
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
###############################################################################
#Installation section
###############
#Install ape and stringr the tradiational way
install.packages(c("ape", "stringr"))
#Install devtools
install.packages("devtools")
#Install AstralPlane
devtools::install_github("chutter/AstralPlane")
###############################################################################
#Load packages
###############
library(AstralPlane)
###############################################################################
#astral and working directory setup
###############
#You will want a variable that includes your full path to the astral jar file.
#NOTE: if you move this file, you will need to move the lib/ directory along with it.
astral.path = "/usr/local/bin/Astral-5-14/astral.5.14.2.jar"
#Create
work.dir = "/Volumes/Rodents/Australian_Rodents/Data_Processing/Astral"
dir.create(work.dir)
setwd(work.dir)
###############################################################################
#Single dataset example
###############
#Set up your directories
tree.dir = "/Volumes/Rodents/Australian_Rodents/Data_Processing/Alignments/Ausred/genes_trimmed_trees"
outgroups = c("Rattus_tunneyi_RAT130", "Rattus_colletti_RAT25")
save.name = "Ausred"
#Setting up a single dataset
setupAstral(genetree.folder = tree.dir,
output.name = save.name,
overwrite = TRUE,
min.n.samples = 4,
min.sample.prop = 0,
make.polytomy = TRUE,
polytomy.limit = 10)
#Run astral for a single set of gene trees
runAstral(input.genetrees = paste0(save.name, "_genetrees.tre"),
output.name = save.name,
astral.path = astral.path,
astral.t = 2,
quiet = FALSE,
overwrite = TRUE,
load.tree = FALSE,
multi.thread = TRUE,
memory = "8g")
#Read in the astral data and tree and organize it into different slots
astral.data = createAstralPlane(astral.tree = save.name,
outgroups = outgroups,
tip.length = 1)
#Plots the astral data
astralProjection(astral.plane = astral.data,
local.posterior = TRUE,
pie.plot = TRUE,
pie.data = "qscore",
save.file = NULL,
pie.colors = c("purple", "blue", "green"),
node.color.text = c("white"),
node.color.bg = c("black"),
tip.label.size = 0.75,
pie.chart.size = 1)
###############################################################################
###############################################################################
###############################################################################
###############################################################################
# Multi-dataset example
###############
library(AstralPlane)
work.dir = "/Users/chutter/Dropbox/Research/1_Main-Projects/0_Working-Projects/Hylidae"
genetree.folder = "/Users/chutter/Dropbox/Research/1_Main-Projects/0_Working-Projects/Hylidae/Trees/Gene_Trees"
setwd(work.dir)
#If you have many different datasets to set up and run, you can give it the folder
#of various datasets.
batchAstral(genetree.datasets = genetree.folder,
astral.t = 2,
output.dir = "test-dataset",
min.n.samples = 4,
min.sample.prop = 0.1,
taxa.remove = NULL,
overwrite = TRUE,
quiet = F,
astral.path = astral.path,
make.polytomy = TRUE,
polytomy.limit = 10,
multi.thread = TRUE,
memory = "8g")
#Obtains dataset names
datasets = list.dirs(genetree.folder, full.names = F, recursive = F)
for (i in 1:length(datasets)){
#Read in the astral data and tree and organize it into different slots
dataset.name = paste0("test-dataset/", datasets[i], "_astral.tre")
astral.data = createAstralPlane(astral.tree = dataset.name,
outgroups = outgroups,
tip.length = 1)
#Plots the astral data
astralProjection(astral.plane = astral.data,
local.posterior = TRUE,
pie.plot = TRUE,
pie.data = "qscore",
save.file = paste0("test-dataset/", datasets[i], ".pdf"),
pie.colors = c("purple", "blue", "green"),
node.color.text = c("white"),
node.color.bg = c("black"),
tip.label.size = 0.75,
pie.chart.size = 1)
}#end i loop
###### END SCRIPT