This repository has been archived by the owner on Sep 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 107
/
Copy pathrplos.Rmd
346 lines (281 loc) · 8.35 KB
/
rplos.Rmd
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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
---
title: Introduction to rplos
author: Scott Chamberlain
date: "2021-02-23"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Introduction to rplos}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
The `rplos` package interacts with the API services of [PLoS](https://plos.org/)
(Public Library of Science) Journals. You used to need an API key to work with
this package - that is no longer needed!
This tutorial will go through three use cases to demonstrate the kinds
of things possible in `rplos`.
* Search across PLoS papers in various sections of papers
* Search for terms and visualize results as a histogram OR as a plot through
time
* Text mining of scientific literature
### Load package from CRAN
```r
install.packages("rplos")
```
```r
library('rplos')
```
### Search across PLoS papers in various sections of papers
`searchplos` is a general search, and in this case searches for the term
**Helianthus** and returns the DOI's of matching papers
```r
searchplos(q = "Helianthus", fl = "id", limit = 5)
```
```
#> $meta
#> # A tibble: 1 x 2
#> numFound start
#> <int> <int>
#> 1 646 0
#>
#> $data
#> # A tibble: 5 x 1
#> id
#> <chr>
#> 1 10.1371/journal.pone.0198869
#> 2 10.1371/journal.pone.0213065
#> 3 10.1371/journal.pone.0148280
#> 4 10.1371/journal.pone.0111982
#> 5 10.1371/journal.pone.0212371
```
Get only full article DOIs
```r
searchplos(q = "*:*", fl = 'id', fq = 'doc_type:full', start = 0, limit = 5)
```
```
#> $meta
#> # A tibble: 1 x 2
#> numFound start
#> <int> <int>
#> 1 292789 0
#>
#> $data
#> # A tibble: 5 x 1
#> id
#> <chr>
#> 1 10.1371/journal.pcbi.0020071
#> 2 10.1371/journal.pbio.1000152
#> 3 10.1371/journal.pbio.1000153
#> 4 10.1371/journal.pbio.1000159
#> 5 10.1371/journal.pbio.1000165
```
Get DOIs for only PLoS One articles
```r
searchplos(q = "*:*", fl = 'id', fq = 'journal_key:PLoSONE',
start = 0, limit = 5)
```
```
#> $meta
#> # A tibble: 1 x 2
#> numFound start
#> <int> <int>
#> 1 2125942 0
#>
#> $data
#> # A tibble: 5 x 1
#> id
#> <chr>
#> 1 10.1371/journal.pone.0002397/title
#> 2 10.1371/journal.pone.0002397/abstract
#> 3 10.1371/journal.pone.0002397/references
#> 4 10.1371/journal.pone.0002397/body
#> 5 10.1371/journal.pone.0002397/introduction
```
Get DOIs for full article in PLoS One
```r
searchplos(q = "*:*", fl = 'id',
fq = list('journal_key:PLoSONE', 'doc_type:full'),
start = 0, limit = 5)
```
```
#> $meta
#> # A tibble: 1 x 2
#> numFound start
#> <int> <int>
#> 1 246927 0
#>
#> $data
#> # A tibble: 5 x 1
#> id
#> <chr>
#> 1 10.1371/journal.pone.0002399
#> 2 10.1371/journal.pone.0002401
#> 3 10.1371/journal.pone.0002403
#> 4 10.1371/journal.pone.0002405
#> 5 10.1371/journal.pone.0002407
```
Search for many terms
```r
q <- c('ecology','evolution','science')
lapply(q, function(x) searchplos(x, limit = 2))
```
```
#> [[1]]
#> [[1]]$meta
#> # A tibble: 1 x 2
#> numFound start
#> <int> <int>
#> 1 55873 0
#>
#> [[1]]$data
#> # A tibble: 2 x 1
#> id
#> <chr>
#> 1 10.1371/journal.pone.0001248
#> 2 10.1371/journal.pone.0059813
#>
#>
#> [[2]]
#> [[2]]$meta
#> # A tibble: 1 x 2
#> numFound start
#> <int> <int>
#> 1 82168 0
#>
#> [[2]]$data
#> # A tibble: 2 x 1
#> id
#> <chr>
#> 1 10.1371/journal.pbio.2002255
#> 2 10.1371/journal.pone.0205798
#>
#>
#> [[3]]
#> [[3]]$meta
#> # A tibble: 1 x 2
#> numFound start
#> <int> <int>
#> 1 260220 0
#>
#> [[3]]$data
#> # A tibble: 2 x 1
#> id
#> <chr>
#> 1 10.1371/journal.pone.0229237
#> 2 10.1371/journal.pone.0202320
```
### Search on specific sections
A suite of functions were created as light wrappers around `searchplos` as
a shorthand to search specific sections of a paper.
* `plosauthor` searchers in authors
* `plosabstract` searches in abstracts
* `plostitle` searches in titles
* `plosfigtabcaps` searches in figure and table captions
* `plossubject` searches in subject areas
`plosauthor` searches across authors, and in this case returns the authors of
the matching papers. the fl parameter determines what is returned
```r
plosauthor(q = "Eisen", fl = "author", limit = 5)
```
```
#> $meta
#> # A tibble: 1 x 2
#> numFound start
#> <int> <int>
#> 1 1107 0
#>
#> $data
#> # A tibble: 5 x 1
#> author
#> <chr>
#> 1 Myungsun Kang,Timothy J Eisen,Ellen A Eisen,Arup K Chakraborty,Herman N Eisen
#> 2 Myungsun Kang,Timothy J Eisen,Ellen A Eisen,Arup K Chakraborty,Herman N Eisen
#> 3 Myungsun Kang,Timothy J Eisen,Ellen A Eisen,Arup K Chakraborty,Herman N Eisen
#> 4 Myungsun Kang,Timothy J Eisen,Ellen A Eisen,Arup K Chakraborty,Herman N Eisen
#> 5 Myungsun Kang,Timothy J Eisen,Ellen A Eisen,Arup K Chakraborty,Herman N Eisen
```
`plosabstract` searches across abstracts, and in this case returns the id and
title of the matching papers
```r
plosabstract(q = 'drosophila', fl = 'id,title', limit = 5)
```
```
#> $meta
#> # A tibble: 1 x 2
#> numFound start
#> <int> <int>
#> 1 3944 0
#>
#> $data
#> # A tibble: 5 x 2
#> id title
#> <chr> <chr>
#> 1 10.1371/journal.pone.… Host Range and Specificity of the Drosophila C Virus
#> 2 10.1371/journal.pgen.… Drosophila Myc restores immune homeostasis of Imd path…
#> 3 10.1371/journal.pone.… Exogenous expression of Drp1 plays neuroprotective rol…
#> 4 10.1371/journal.pone.… A Drosophila model for developmental nicotine exposure
#> 5 10.1371/image.pbio.v0… PLoS Biology Issue Image | Vol. 6(5) May 2008
```
`plostitle` searches across titles, and in this case returns the title and
journal of the matching papers
```r
plostitle(q = 'drosophila', fl = 'title,journal', limit = 5)
```
```
#> $meta
#> # A tibble: 1 x 2
#> numFound start
#> <int> <int>
#> 1 2480 0
#>
#> $data
#> # A tibble: 5 x 2
#> journal title
#> <chr> <chr>
#> 1 PLOS ONE Tandem Duplications and the Limits of Natural Selection in Drosophil…
#> 2 PLoS ONE A DNA Virus of Drosophila
#> 3 PLOS ONE Nematocytes: Discovery and characterization of a novel anculeate hem…
#> 4 PLOS ONE Peptidergic control in a fruit crop pest: The spotted-wing drosophil…
#> 5 PLoS ONE In Vivo RNAi Rescue in Drosophila melanogaster with Genomic Transgen…
```
### Search terms & visualize results as a histogram OR as a plot through time
`plosword` allows you to search for 1 to K words and visualize the results
as a histogram, comparing number of matching papers for each word
```r
out <- plosword(list("monkey", "Helianthus", "sunflower", "protein", "whale"),
vis = "TRUE")
out$table
```
```
#> No_Articles Term
#> 1 14528 monkey
#> 2 646 Helianthus
#> 3 1876 sunflower
#> 4 164537 protein
#> 5 2142 whale
```
```r
out$plot
```
![plot of chunk plosword1plot](../man/figures/plosword1plot-1.png)
You can also pass in curl options, in this case get verbose information on the
curl call.
```r
plosword('Helianthus', callopts = list(verbose = TRUE))
```
```
#> Number of articles with search term
#> 646
```
### Visualize terms
`plot_throughtime` allows you to search for up to 2 words and visualize the
results as a line plot through time, comparing number of articles matching
through time. Visualize with the ggplot2 package, only up to two terms for now.
```r
library("ggplot2")
plot_throughtime(terms = "phylogeny", limit = 200) +
geom_line(size = 2, color = 'black')
```
![plot of chunk throughtime1](../man/figures/throughtime1-1.png)
### More
See the _Faceted and highlighted searches_ and _Full text_ vignettes for
more `rplos` help.