-
Notifications
You must be signed in to change notification settings - Fork 0
/
01_requirements.R
242 lines (182 loc) · 6.28 KB
/
01_requirements.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# Please run this script first to make sure you have all the necessary packages
# installed for running the rest of the scripts in this R project
set.seed(147)
source("fun_def_h_load.R")
#do a binary install of all of tidyverse specifically
if(!"tidyverse" %in% rownames(installed.packages()) ){
install.packages("tidyverse", type="binary", dependencies = T)
}
suppressMessages(
library("tidyverse", quietly = T, warn.conflicts = F, verbose = F)
)
#depdencies for castor
h_load(c("naturalsort", "RSpectra"))
h_load(dependencies = T, pkg = c(
"tidyverse",
"reshape2",
"RcppParallel",
"qs",
"viridis",
# rlang",
#"snakecase",
# "readODS",
"assertthat",
"beepr",
# lazyeval",
"gplots",
# MASS",
# ggridges",
"ggplot2",
"grDevices",
# ggthemes",
# readxl",
# glue",
# broom",
# ggrepel",
"jsonlite", #reading json files
"fs",
# ggpubr",
# psych",
# fuzzyjoin",
# infotheo",
# rlist",
"data.table",
#making maps
# "mapdata",
# "maptools",
"maps",
# "mapproj",
# ggmap",
"glue",
"stringi",
"data.table",
"ape",
"caper",
"castor",
"naniar",
# fields",
# "phytools",
"adephylo",
"phylobase",
"nloptr",
"GenSA",
"wesanderson",
"phangorn", #for acctran and dep of phytools
"xtable",
"broom",
# sf",
# raster",
# "scales",
"janitor")
)
#Liam fixed a specific issue with dottree, therefore we want to install a development version of phytools
#do a binary install of all of tidyverse specifically
if(!"phytools" %in% rownames(installed.packages()) ){
remotes::install_github("liamrevell/phytools", ref = "c4c8c72", force = T)
}
library("phytools")
h_load("Rmpfr")
#installing pacakge corHMM from specific website
if(!"corHMM" %in% rownames(installed.packages()) ){
install.packages("corHMM", repo = 'https://mac.R-project.org')
}
library("corHMM")
#quieting down tidyverse
options(tidyverse.quiet = TRUE)
options(readr.show_col_types = FALSE)
#setting options for graphics (necessary for the cluster)
#options(bitmapType='cairo')
#setting up cut-off numbers for tree tips
ntips_half_gray <- 132/2 #half of gray et al tree tips that can be matched to GB
ntips_half_glottolog <- 271/2 #half of glottolog tree tips that can be matched to GB
1
##setting up folder structure for output
if (!dir.exists("output")) { dir.create("output") }
#dirs for gray_et_al_tree
fn <- "output/gray_et_al_2009"
if (!dir.exists(fn)) { dir.create(fn) }
fn <- "output/gray_et_al_2009/ML"
if (!dir.exists(fn)) { dir.create(fn) }
fn <- "output/gray_et_al_2009/ML/mcct"
if (!dir.exists(fn)) { dir.create(fn) }
fn <- "output/gray_et_al_2009/ML/results_by_tree"
if (!dir.exists(fn)) { dir.create(fn) }
fn <- "output/gray_et_al_2009/parsimony/"
if (!dir.exists(fn)) { dir.create(fn) }
fn <- "output/gray_et_al_2009/parsimony/mcct"
if (!dir.exists(fn)) { dir.create(fn) }
fn <- "output/gray_et_al_2009/parsimony/results_by_tree"
if (!dir.exists(fn)) { dir.create(fn) }
#processed data dirs
fn <- "output/processed_data"
if (!dir.exists(fn)) { dir.create(fn) }
fn <- "output/processed_data/HL_findings/"
if (!dir.exists(fn)) { dir.create(fn) }
fn <- "output/HL_comparison/"
if (!dir.exists(fn)) { dir.create(fn) }
fn <- "output/processed_data/trees"
if (!dir.exists(fn)) { dir.create(fn) }
fn <- "output/processed_data/trees/gray_et_al_2009_posterior_trees_pruned"
if (!dir.exists(fn)) { dir.create(fn) }
#dirs for glottolog-tree
fn <- "output/glottolog-tree"
if (!dir.exists(fn)) { dir.create(fn) }
fn <- "output/glottolog-tree/ML"
if (!dir.exists(fn)) { dir.create(fn) }
fn <- "output/glottolog-tree/parsimony/"
if (!dir.exists(fn)) { dir.create(fn) }
#dir for plots
#this project is meant to be working in tandem with tex code. To make that process easier, if there is a tex file one level up plots will be deposited there directly. However, if this code has been moved to somewhere else and no longer next to the tex folder, plots will just be straight in the output dir inside this dir.
if(dir.exists("../tex")){
OUTPUTDIR_plots <- "../tex/illustrations/plots_from_R/"
}else{
OUTPUTDIR_plots<- "output"
}
if (!dir.exists(OUTPUTDIR_plots)) { dir.create(OUTPUTDIR_plots) }
fn <- file.path( OUTPUTDIR_plots , "coverage_plots")
if (!dir.exists(fn)) { dir.create(fn) }
fn <- file.path( OUTPUTDIR_plots , "tree_plots")
if (!dir.exists(fn)) { dir.create(fn) }
fn <- file.path( OUTPUTDIR_plots , "tree_plots", "glottolog-tree")
if (!dir.exists(fn)) { dir.create(fn) }
fn <- file.path( OUTPUTDIR_plots , "tree_plots", "glottolog-tree", "parsimony")
if (!dir.exists(fn)) { dir.create(fn) }
fn <- file.path( OUTPUTDIR_plots , "tree_plots", "glottolog-tree", "ML")
if (!dir.exists(fn)) { dir.create(fn) }
fn <- file.path( OUTPUTDIR_plots , "tree_plots", "gray_et_al_2009")
if (!dir.exists(fn)) { dir.create(fn) }
fn <- file.path( OUTPUTDIR_plots , "tree_plots", "gray_et_al_2009", "parsimony")
if (!dir.exists(fn)) { dir.create(fn) }
fn <- file.path( OUTPUTDIR_plots , "tree_plots", "gray_et_al_2009", "ML")
if (!dir.exists(fn)) { dir.create(fn) }
fn <- file.path( OUTPUTDIR_plots , "coverage_plots", "maps")
if (!dir.exists(fn)) { dir.create(fn) }
fn <- file.path( OUTPUTDIR_plots , "coverage_plots", "tree")
if (!dir.exists(fn)) { dir.create(fn) }
fn <- file.path( OUTPUTDIR_plots , "coverage_plots", "tables")
if (!dir.exists(fn)) { dir.create(fn) }
#loading in tables that are used in multiple scripts
HL_findings_sheet_fn <- "output/processed_data/HL_findings/HL_findings_for_comparison.tsv"
HL_findings_sheet_conflicts_fn <- "data/HL_findings_conflicts.csv"
GB_df_desc_fn <- "output/GB_wide/parameters_binary.tsv"
GB_binary_fn <- "output/GB_wide/GB_wide_binarized.tsv"
glottolog_df_fn <- "output/processed_data/glottolog_language_table_wide_df.tsv"
#colors
colours_binary <- viridisLite::viridis(n=2, end = 0.9, direction = -1)
source("fun_def_plotRECON_tweaked.R")
gray_dup_to_remove <- c("Sisingga",
"Carolinian",
"Futuna",
"Aria",
"Madara",
"Maututu",
"Chuukese",
"NakanaiBileki_D",
"LwepeSantaCruz",
"Buma",
"NehanHape",
"Woleai",
"Marshallese",
"FutunaWest", #mystery language with no entries
"Baliledo" #can't get a glottocode match
)