Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

Commit

Permalink
fixes to full_text_urls() function to work correctly for clinicaltrai…
Browse files Browse the repository at this point in the history
…ls urls

updated readme
bumepd dev version
  • Loading branch information
sckott committed Apr 14, 2016
1 parent b0ea305 commit 921e558
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 95 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Description: A programmatic interface to the 'SOLR' based
articles, making plots, doing 'faceted' searches,
'highlight' searches, and viewing results of 'highlighted'
searches in a browser.
Version: 0.5.6.9300
Version: 0.5.6.9500
License: MIT + file LICENSE
Authors@R: c(
person("Scott", "Chamberlain", role = c("aut", "cre"), email = "myrmecocystus@gmail.com"),
Expand Down
12 changes: 9 additions & 3 deletions R/fulltext.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@ full_text_urls <- function(doi){
pgen = 'plosgenetics',
pcbi = 'ploscompbiol',
ppat = 'plospathogens',
pntd = 'plosntds')
ub <- 'http://www.%s.org/article/fetchObject.action?uri=info:doi/%s&representation=XML'
sprintf(ub, journal, x)
pntd = 'plosntds',
pctr = 'plosclinicaltrials')
if ("plosclinicaltrials" == journal) {
ub <- 'http://journals.plos.org/plosclinicaltrials/article/asset?id=%s.XML'
sprintf(ub, x)
} else {
ub <- 'http://www.%s.org/article/fetchObject.action?uri=info:doi/%s&representation=XML'
sprintf(ub, journal, x)
}
}
vapply(doi, makeurl, "", USE.NAMES = FALSE)
}
Expand Down
182 changes: 91 additions & 91 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Search for the term ecology, and return id (DOI) and publication date, limiting
searchplos('ecology', 'id,publication_date', limit = 5)
#> $meta
#> numFound start maxScore
#> 1 27832 0 NA
#> 1 32563 0 NA
#>
#> $data
#> id
Expand All @@ -81,15 +81,15 @@ searchplos(q="*:*", fl='id', fq=list('cross_published_journal_key:PLoSONE',
'doc_type:full'), limit=5)
#> $meta
#> numFound start maxScore
#> 1 133907 0 NA
#> 1 156005 0 NA
#>
#> $data
#> id
#> 1 10.1371/journal.pone.0031384
#> 2 10.1371/journal.pone.0031385
#> 3 10.1371/journal.pone.0107441
#> 4 10.1371/journal.pone.0000339
#> 5 10.1371/journal.pone.0046739
#> 1 10.1371/journal.pone.0084520
#> 2 10.1371/journal.pone.0027194
#> 3 10.1371/journal.pone.0073075
#> 4 10.1371/journal.pone.0050158
#> 5 10.1371/journal.pone.0050268
```

Query to get some PLOS article-level metrics, notice difference between two outputs
Expand All @@ -101,20 +101,20 @@ out_sorted <- searchplos(q="*:*", fl=c('id','counter_total_all','alm_twitterCoun
fq='doc_type:full', sort='counter_total_all desc')
head(out$data)
#> id alm_twitterCount counter_total_all
#> 1 10.1371/journal.pone.0031384 0 4036
#> 2 10.1371/journal.pone.0031385 0 2483
#> 3 10.1371/journal.pone.0107441 4 794
#> 4 10.1371/journal.pone.0000339 0 4978
#> 5 10.1371/journal.pone.0046739 0 1480
#> 6 10.1371/journal.pone.0061900 0 1615
#> 1 10.1371/journal.pone.0084520 0 1088
#> 2 10.1371/journal.pone.0027194 1 1966
#> 3 10.1371/journal.pone.0073075 0 2118
#> 4 10.1371/journal.pone.0050158 0 1709
#> 5 10.1371/journal.pone.0050268 4 1642
#> 6 10.1371/journal.pone.0084489 0 1223
head(out_sorted$data)
#> id alm_twitterCount counter_total_all
#> 1 10.1371/journal.pmed.0020124 1769 1110803
#> 2 10.1371/journal.pmed.0050045 116 336537
#> 3 10.1371/journal.pone.0007595 197 328552
#> 4 10.1371/journal.pone.0069841 820 316100
#> 5 10.1371/journal.pone.0033288 39 308133
#> 6 10.1371/journal.pone.0044864 87 240407
#> 1 10.1371/journal.pmed.0020124 2314 1602293
#> 2 10.1371/journal.pmed.0050045 151 382347
#> 3 10.1371/journal.pone.0069841 857 378155
#> 4 10.1371/journal.pcbi.0030102 52 377892
#> 5 10.1371/journal.pone.0007595 242 365498
#> 6 10.1371/journal.pcbi.0030077 53 317609
```

A list of articles about social networks that are popular on a social network
Expand All @@ -126,20 +126,20 @@ searchplos(q="*:*",fl=c('id','alm_twitterCount'),
sort='counter_total_month desc')
#> $meta
#> numFound start maxScore
#> 1 24 0 NA
#> 1 38 0 NA
#>
#> $data
#> id alm_twitterCount
#> 1 10.1371/journal.pone.0069841 820
#> 2 10.1371/journal.pone.0073791 782
#> 3 10.1371/journal.pbio.1001535 1670
#> 4 10.1371/journal.pone.0090315 402
#> 5 10.1371/journal.pcbi.1003858 272
#> 6 10.1371/journal.pone.0064841 123
#> 7 10.1371/journal.pcbi.1003789 1080
#> 8 10.1371/journal.pone.0065774 107
#> 9 10.1371/journal.pone.0059030 216
#> 10 10.1371/journal.pone.0110329 184
#> 1 10.1371/journal.pmed.1000316 899
#> 2 10.1371/journal.pbio.1002413 246
#> 3 10.1371/journal.pone.0069841 857
#> 4 10.1371/journal.pone.0073791 1642
#> 5 10.1371/journal.pone.0151387 197
#> 6 10.1371/journal.pone.0148405 447
#> 7 10.1371/journal.pbio.1001535 1763
#> 8 10.1371/journal.pbio.1002373 342
#> 9 10.1371/journal.pone.0150989 183
#> 10 10.1371/journal.pone.0149777 113
```

Show all articles that have these two words less then about 15 words apart
Expand All @@ -149,13 +149,13 @@ Show all articles that have these two words less then about 15 words apart
searchplos(q='everything:"sports alcohol"~15', fl='title', fq='doc_type:full', limit=3)
#> $meta
#> numFound start maxScore
#> 1 70 0 NA
#> 1 95 0 NA
#>
#> $data
#> title
#> 1 Alcohol Ingestion Impairs Maximal Post-Exercise Rates of Myofibrillar Protein Synthesis following a Single Bout of Concurrent Training
#> 2 “Like Throwing a Bowling Ball at a Battle Ship” Audience Responses to Australian News Stories about Alcohol Pricing and Promotion Policies: A Qualitative Focus Group Study
#> 3 Investigating the Associations of Self-Rated Health: Heart Rate Variability Is More Strongly Associated than Inflammatory and Other Frequently Used Biomarkers in a Cross Sectional Occupational Sample
#> title
#> 1 Alcohol Advertising in Sport and Non-Sport TV in Australia, during Children’s Viewing Times
#> 2 Correction: Alcohol Advertising in Sport and Non-Sport TV in Australia, during Children’s Viewing Times
#> 3 Symptoms of Insomnia and Sleep Duration and Their Association with Incident Strokes: Findings from the Population-Based MONICA/KORA Augsburg Cohort Study
```

Narrow results to 7 words apart, changing the ~15 to ~7
Expand All @@ -165,13 +165,13 @@ Narrow results to 7 words apart, changing the ~15 to ~7
searchplos(q='everything:"sports alcohol"~7', fl='title', fq='doc_type:full', limit=3)
#> $meta
#> numFound start maxScore
#> 1 32 0 NA
#> 1 47 0 NA
#>
#> $data
#> title
#> 1 Alcohol Ingestion Impairs Maximal Post-Exercise Rates of Myofibrillar Protein Synthesis following a Single Bout of Concurrent Training
#> 2 “Like Throwing a Bowling Ball at a Battle Ship” Audience Responses to Australian News Stories about Alcohol Pricing and Promotion Policies: A Qualitative Focus Group Study
#> 3 Investigating the Associations of Self-Rated Health: Heart Rate Variability Is More Strongly Associated than Inflammatory and Other Frequently Used Biomarkers in a Cross Sectional Occupational Sample
#> title
#> 1 Alcohol Advertising in Sport and Non-Sport TV in Australia, during Children’s Viewing Times
#> 2 Correction: Alcohol Advertising in Sport and Non-Sport TV in Australia, during Children’s Viewing Times
#> 3 Symptoms of Insomnia and Sleep Duration and Their Association with Incident Strokes: Findings from the Population-Based MONICA/KORA Augsburg Cohort Study
```

Remove DOIs for annotations (i.e., corrections) and Viewpoints articles
Expand All @@ -182,15 +182,15 @@ searchplos(q='*:*', fl=c('id','article_type'),
fq=list('-article_type:correction','-article_type:viewpoints'), limit=5)
#> $meta
#> numFound start maxScore
#> 1 1307941 0 NA
#> 1 1516083 0 NA
#>
#> $data
#> id article_type
#> 1 10.1371/journal.pone.0123754/title Research Article
#> 2 10.1371/journal.pone.0123754/abstract Research Article
#> 3 10.1371/journal.pone.0123754/references Research Article
#> 4 10.1371/journal.pone.0123754/body Research Article
#> 5 10.1371/journal.pone.0123754/introduction Research Article
#> id article_type
#> 1 10.1371/journal.pone.0084520 Research Article
#> 2 10.1371/journal.pone.0084520/title Research Article
#> 3 10.1371/journal.pone.0084520/abstract Research Article
#> 4 10.1371/journal.pone.0084520/references Research Article
#> 5 10.1371/journal.pone.0084520/body Research Article
```

### Faceted search
Expand All @@ -206,19 +206,19 @@ facetplos(q='alcohol', facet.field=c('journal','subject'), facet.limit=5)
#> $facet_fields
#> $facet_fields$journal
#> X1 X2
#> 1 plos one 1083485
#> 2 plos genetics 45073
#> 3 plos pathogens 39357
#> 4 plos computational biology 32816
#> 5 plos neglected tropical diseases 29607
#> 1 plos one 1275921
#> 2 plos genetics 50342
#> 3 plos pathogens 43597
#> 4 plos computational biology 37219
#> 5 plos neglected tropical diseases 35331
#>
#> $facet_fields$subject
#> X1 X2
#> 1 biology and life sciences 1250577
#> 2 medicine and health sciences 958759
#> 3 research and analysis methods 798256
#> 4 biochemistry 617863
#> 5 cell biology 550737
#> 1 biology and life sciences 1459514
#> 2 medicine and health sciences 1131931
#> 3 research and analysis methods 963634
#> 4 biochemistry 719264
#> 5 cell biology 615901
#>
#>
#> $facet_dates
Expand Down Expand Up @@ -246,16 +246,16 @@ facetplos(q='*:*', url=url, facet.range='counter_total_all',
#> $facet_ranges
#> $facet_ranges$counter_total_all
#> X1 X2
#> 1 5 160
#> 2 15 399
#> 3 25 462
#> 4 35 605
#> 5 45 620
#> 6 55 998
#> 7 65 908
#> 8 75 1014
#> 9 85 1027
#> 10 95 941
#> 1 5 318
#> 2 15 842
#> 3 25 1590
#> 4 35 2022
#> 5 45 2202
#> 6 55 2068
#> 7 65 1791
#> 8 75 1433
#> 9 85 1465
#> 10 95 1225
```

### Highlight searches
Expand Down Expand Up @@ -305,7 +305,7 @@ full_text_urls(doi='10.1371/journal.pone.0086169')
```r
(out <- plos_fulltext(doi='10.1371/journal.pone.0086169'))
#> 1 full-text articles retrieved
#> Min. Length: 111132 - Max. Length: 111132
#> Min. Length: 110717 - Max. Length: 110717
#> DOIs: 10.1371/journal.pone.0086169 ...
#>
#> NOTE: extract xml strings like output['<doi>']
Expand All @@ -317,7 +317,7 @@ Then parse the XML any way you like, here getting the abstract
```r
library("XML")
xpathSApply(xmlParse(out$`10.1371/journal.pone.0086169`), "//abstract", xmlValue)
#> [1] "Mammalian females pay high energetic costs for reproduction, the greatest of which is imposed by lactation. The synthesis of milk requires, in part, the mobilization of bodily reserves to nourish developing young. Numerous hypotheses have been advanced to predict how mothers will differentially invest in sons and daughters, however few studies have addressed sex-biased milk synthesis. Here we leverage the dairy cow model to investigate such phenomena. Using 2.39 million lactation records from 1.49 million dairy cows, we demonstrate that the sex of the fetus influences the capacity of the mammary gland to synthesize milk during lactation. Cows favor daughters, producing significantly more milk for daughters than for sons across lactation. Using a sub-sample of this dataset (Nâ\u0080\u008a=â\u0080\u008a113,750 subjects) we further demonstrate that the effects of fetal sex interact dynamically across parities, whereby the sex of the fetus being gestated can enhance or diminish the production of milk during an established lactation. Moreover the sex of the fetus gestated on the first parity has persistent consequences for milk synthesis on the subsequent parity. Specifically, gestation of a daughter on the first parity increases milk production by â\u0088¼445 kg over the first two lactations. Our results identify a dramatic and sustained programming of mammary function by offspring in utero. Nutritional and endocrine conditions in utero are known to have pronounced and long-term effects on progeny, but the ways in which the progeny has sustained physiological effects on the dam have received little attention to date."
#> [1] "Mammalian females pay high energetic costs for reproduction, the greatest of which is imposed by lactation. The synthesis of milk requires, in part, the mobilization of bodily reserves to nourish developing young. Numerous hypotheses have been advanced to predict how mothers will differentially invest in sons and daughters, however few studies have addressed sex-biased milk synthesis. Here we leverage the dairy cow model to investigate such phenomena. Using 2.39 million lactation records from 1.49 million dairy cows, we demonstrate that the sex of the fetus influences the capacity of the mammary gland to synthesize milk during lactation. Cows favor daughters, producing significantly more milk for daughters than for sons across lactation. Using a sub-sample of this dataset (N = 113,750 subjects) we further demonstrate that the effects of fetal sex interact dynamically across parities, whereby the sex of the fetus being gestated can enhance or diminish the production of milk during an established lactation. Moreover the sex of the fetus gestated on the first parity has persistent consequences for milk synthesis on the subsequent parity. Specifically, gestation of a daughter on the first parity increases milk production by ∼445 kg over the first two lactations. Our results identify a dramatic and sustained programming of mammary function by offspring in utero. Nutritional and endocrine conditions in utero are known to have pronounced and long-term effects on progeny, but the ways in which the progeny has sustained physiological effects on the dam have received little attention to date."
```

### Search within a field
Expand All @@ -337,20 +337,20 @@ For example:
plossubject(q='marine ecology', fl = c('id','journal'), limit = 10)
#> $meta
#> numFound start maxScore
#> 1 2345 0 NA
#> 1 2902 0 NA
#>
#> $data
#> id journal
#> 1 10.1371/journal.pone.0028556 PLoS ONE
#> 2 10.1371/journal.pone.0028556/title PLoS ONE
#> 3 10.1371/journal.pone.0028556/abstract PLoS ONE
#> 4 10.1371/journal.pone.0028556/references PLoS ONE
#> 5 10.1371/journal.pone.0028556/body PLoS ONE
#> 6 10.1371/journal.pone.0028556/introduction PLoS ONE
#> 7 10.1371/journal.pone.0028556/results_and_discussion PLoS ONE
#> 8 10.1371/journal.pone.0028556/materials_and_methods PLoS ONE
#> 9 10.1371/journal.pone.0021810 PLoS ONE
#> 10 10.1371/journal.pone.0021810/title PLoS ONE
#> 1 10.1371/journal.pone.0080365/abstract PLoS ONE
#> 2 10.1371/journal.pone.0080365/references PLoS ONE
#> 3 10.1371/journal.pone.0080365/body PLoS ONE
#> 4 10.1371/journal.pone.0092590/body PLoS ONE
#> 5 10.1371/journal.pone.0092590/introduction PLoS ONE
#> 6 10.1371/journal.pone.0092590/results_and_discussion PLoS ONE
#> 7 10.1371/journal.pone.0092590/materials_and_methods PLoS ONE
#> 8 10.1371/journal.pone.0092590/conclusions PLoS ONE
#> 9 10.1371/journal.pone.0092590 PLoS ONE
#> 10 10.1371/journal.pone.0092590/title PLoS ONE
```

However, you can always just do this in `searchplos()` like `searchplos(q = "subject:science")`. See also the `fq` parameter. The above convenience functions are simply wrappers around `searchplos`, so take all the same parameters.
Expand All @@ -363,11 +363,11 @@ Search with term _marine ecology_, by field _subject_, and limit to 5 results
```r
plosviews(search='marine ecology', byfield='subject', limit=5)
#> id counter_total_all
#> 3 10.1371/journal.pone.0126253 306
#> 5 10.1371/journal.pone.0116720 1216
#> 1 10.1371/journal.pone.0028556 1319
#> 2 10.1371/journal.pone.0021810 1634
#> 4 10.1371/journal.pone.0022881 8450
#> 2 10.1371/journal.pone.0080365 1954
#> 3 10.1371/journal.pone.0021810 2229
#> 4 10.1371/journal.pone.0149852 3368
#> 1 10.1371/journal.pone.0092590 6526
#> 5 10.1371/journal.pone.0047598 8610
```

### Visualize
Expand All @@ -379,16 +379,16 @@ Visualize word use across articles
plosword(list('monkey','Helianthus','sunflower','protein','whale'), vis = 'TRUE')
#> $table
#> No_Articles Term
#> 1 9098 monkey
#> 2 347 Helianthus
#> 3 937 sunflower
#> 4 101040 protein
#> 5 1139 whale
#> 1 10237 monkey
#> 2 419 Helianthus
#> 3 1133 sunflower
#> 4 114217 protein
#> 5 1325 whale
#>
#> $plot
```

![wordusage](inst/assets/img/unnamed-chunk-21-1.png)
![wordusage](inst/assets/img/unnamed-chunk-21-1.png)

## Meta

Expand Down
Binary file modified inst/assets/img/unnamed-chunk-21-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 921e558

Please sign in to comment.