-
Notifications
You must be signed in to change notification settings - Fork 0
/
_targets.r
143 lines (132 loc) · 3.15 KB
/
_targets.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
#################################################
#################################################
# _targets.R file
# Libraries
library(targets)
#CRAN new packages
list.of.packages = c(
"targets",
"ggplot2",
"grid",
"readr",
"plyr" ,
"dplyr",
"tidyr",
"taxize",
"here",
"stringr",
"ggnewscale",
"ggtext",
"maps",
"FactoMineR",
"factoextra",
"ggpubr",
"rstatix",
"ggrepel",
"devtools",
"BiocManager"
)
new.packages = list.of.packages[!(list.of.packages %in% installed.packages()[, "Package"])]
if (length(new.packages)) {
install.packages(new.packages)
}
# Other new packages
if ("traitdataform" %in% new.packages) {
devtools::install_github('EcologicalTraitData/traitdataform')
}
if ("ggtree" %in% new.packages) {
BiocManager::install("ggtree")
}
if ("ggtreeExtra" %in% new.packages) {
BiocManager::install("ggtreeExtra")
}
tar_option_set(
packages = c(
"ggplot2",
"grid",
"readr",
"plyr" ,
"dplyr",
"tidyr",
"taxize",
"here",
"traitdataform",
"stringr",
"ggtree",
"ggtreeExtra",
"ggnewscale",
"ggtext",
"maps",
"FactoMineR",
"factoextra",
"ggpubr",
"rstatix",
"ggrepel",
"devtools"
)
)
# We source all functions contained in all files in the R directory
lapply(list.files(here::here("R"), recursive = TRUE, full.names = T), source)
list(
# define nutrient literature files
tar_target(
data_nutrients_literature_files,
list.files(pattern = "[0-9]{4}_[0-9]{3}_.*?_[0-9]{4}.xls", recursive = TRUE),
format = "file"
),
# load nutrient literature files
tar_target(
data_nutrients_literature,
load_dnl(data_nutrients_literature_files)
),
# define nutrient proprietary files
tar_target(
data_nutrients_proprietary_file,
here::here(
"1_data",
"1_data_nutrients",
"2_data_samples",
"1030_999_charberet_2020",
"1030_999_charberet_2020.csv"
),
format = "file"
),
# load nutrient proprietary files
tar_target(
data_nutrients_proprietary,
load_dnp(data_nutrients_proprietary_file)
),
# combine nutrient data
tar_target(
data_nutrients_combined,
combine_nutrient_data(data_nl = data_nutrients_literature, data_np = data_nutrients_proprietary)
),
# define traits file
tar_target(
data_traits_combined_file,
here::here("1_data", "3_data_traits", "data_traits.csv")
),
# load traits file
tar_target(data_traits_combined, load_dt(data_traits_combined_file)),
# Combine traits and nutrient data
tar_target(
data_combined,
combine_nutrients_traits(data_n = data_nutrients_combined, data_t = data_traits_combined)
),
# Generate usable datatables for analysis
tar_target(
datasets_for_analyses,
create_datasets_for_analyses(data = data_combined)
),
# define fluxes file
tar_target(
data_fluxes_file,
here::here("1_data", "2_data_fluxes", "data_fluxes.csv")
),
# load fluxes file
tar_target(data_fluxes, load_df(data_fluxes_file)),
# Model the data
tar_target(models, model_ds(data = data_combined, data_f = data_fluxes)),
# Plot the data
tar_target(plots, plot_ds(data = data_combined, data_f = data_fluxes))
)