-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path_targets.R
190 lines (180 loc) · 5.35 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
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
# Created by use_targets().
# Follow the comments below to fill in this target script.
# Then follow the manual to check and run the pipeline:
# https://books.ropensci.org/targets/walkthrough.html#inspect-the-pipeline # nolint
# Load packages required to define the pipeline:
library(targets)
library(tarchetypes)
# Set target options:
tar_option_set(
format = "rds" # default storage format
# Set other options as needed.
)
# tar_make_clustermq() configuration (okay to leave alone):
# options(clustermq.scheduler = "multicore")
# tar_make_future() configuration (okay to leave alone):
# Install packages {{future}}, {{future.callr}}, and {{future.batchtools}} to allow use_targets() to configure tar_make_future() options.
# Saved in .Renviron
# Sys.setenv(ZENODO_PAT = askpass::askpass("Please provide the PAT for Zenodo."))
# Run the R scripts in the R/ folder with your custom functions:
# tar_source()
library(magrittr)
source("R/utils.R")
source("R/openalex-search.R")
source("R/exclusions.R")
source("R/title-review.R")
source("R/abstract-review.R")
source("R/fulltext-review.R")
list(
# Open Alex Title Search --------------------------------------------------
tar_target(
name = search_term,
command = search_terms()
),
tar_target(
name = five_years_from_today,
command = five_years_ago()
),
tar_target(
name = records_title_only,
command = openalex_retrieve_titles(search_term, five_years_from_today)
),
# Exclude and save --------------------------------------------------------
tar_target(
name = records_after_title_exclusion,
command = exclude_from_title(records_title_only)
),
tar_target(
name = records_titles_path,
command = save_as_csv(records_after_title_exclusion, here::here("data/review/titles.csv"))
),
# Title review stage ------------------------------------------------------
tar_target(
name = reviewers,
command = c("daniel", "mario", "luke")
),
tar_target(
name = reviewers_title_files,
command = reviewers |>
path_reviewer_titles() |>
purrr::walk(\(path) copy_if_not_exists(records_titles_path, path)),
format = "file"
),
tar_target(
name = titles_kept,
command = reviewers_title_files |>
read_title_reviews()
),
tar_target(
name = titles_agreed_on,
command = titles_kept |>
get_agreed_on_titles()
),
tar_target(
name = titles_disagreed_on,
command = titles_kept |>
get_disagreed_on_titles(titles_agreed_on)
),
tar_target(
name = titles_disagreed_on_path,
command = save_as_csv(titles_disagreed_on, here::here("data/review/titles/disagreements.csv")),
format = "file"
),
tar_target(
name = titles_resolved_path,
command = titles_disagreed_on |>
copy_if_not_exists(
here::here("data/review/titles/resolved.csv")
),
format = "file"
),
tar_target(
name = titles_selected,
command = purrr::list_rbind(list(
titles_agreed_on,
titles_resolved_path |>
readr::read_csv()
)) |>
dplyr::distinct()
),
# Abstract retrieval ------------------------------------------------------
tar_target(
name = records_abstracts,
command = openalex_retrieve_abstracts(titles_selected$id)
),
tar_target(
name = records_abstracts_path,
command = save_as_yaml(records_abstracts, here::here("data/review/abstracts.yaml")),
format = "file"
),
tar_target(
name = reviewers_abstract_files,
command = reviewers |>
path_reviewer_abstracts() |>
purrr::walk(\(path) copy_if_not_exists(records_abstracts_path, path)),
format = "file"
),
tar_target(
name = abstracts_kept,
command = reviewers_abstract_files |>
read_abstract_reviews()
),
tar_target(
name = abstracts_agreed_on,
command = abstracts_kept |>
get_agreed_on_abstracts()
),
tar_target(
name = abstracts_disagreed_on,
command = abstracts_kept |>
get_disagreed_on_abstracts(abstracts_agreed_on)
),
tar_target(
name = abstracts_disagreed_on_path,
command = save_as_yaml(abstracts_disagreed_on, here::here("data/review/abstracts/disagreements.yaml")),
format = "file"
),
tar_target(
name = abstracts_resolved_path,
command = abstracts_disagreed_on |>
copy_if_not_exists(
here::here("data/review/abstracts/resolved.yaml")
),
format = "file"
),
tar_target(
name = abstracts_selected,
command = purrr::list_rbind(list(
abstracts_agreed_on,
abstracts_resolved_path |>
read_abstract_yaml()
)) |>
dplyr::distinct()
),
# Fulltext retrieval ------------------------------------------------------
tar_target(
name = reviewed_article_records,
command = abstracts_selected$id |>
openalex_retrieve_records()
),
tar_target(
name = fulltext_pdf_paths,
command = reviewed_article_records |>
openalex_retrieve_pdf(),
format = "file"
)
# Don't need to regenerate this every time
# tar_target(
# name = fulltext_review_qmd,
# command = reviewed_article_records |>
# dplyr::rename(path = pdf_proj_path) |>
# create_fulltext_review_template(reviewers),
# format = "file"
# )
# Render report -----------------------------------------------------------
# TODO: there is an error and I don't know why.
# tar_quarto(
# name = review_steps,
# path = here::here("doc/review-stages.qmd")
# )
)