Zenodo is a repository which allows everybody to deposit free of charge any type of research output, in all disciplines of science.
EFSA is piloting it’s use for creating a knowledge base on all types of food safety related evidence(data, documents, models).
Zenodo has an API and can be queried using the standard OAI-PMH protocol, which allows to harvest the metadata and all deposits.
R has a package available to query any OAI-PMH repository, including Zenodo. It can be installed from CRAN like this:
The development version is available on Github at https://github.com/ropensci/oai
The libraries I use in this tutorial are:
Retreive records from Zenodo
The oai package allows to retrieve all records of a given Zenodo community, in this case the EFSA pilot community. The following code shows all records of a community with their digital object identifier and the title.
|EFSA Source Attribution Model (EFSA_SAM)
|PRIMo rev.1 – Pesticide Residue Intake Model
|Egg Pooling Module
|GMOANALYSIS VERSION 2.1.0 – 10 JULY 2014
|Pesticide Residues Overview File: PROFile (3.0)
|Food Additives Intake Model (FAIM) – Version 1.1 – July 2013
|Modelling continental-scale spread of Schmallenberg virus in Europe
|C-TSEMM – Cattle TSE Monitoring Model
|TSEi – TSE Infectivity Model
|Dietary Exposure Calculator Smoke Flavouring
|CHIP: Commodity based Hazard Identification Tool
|PRIMo rev.2 – Pesticide Residue Intake Model
|Exposure of operators, workers, residents and bystanders in risk assessment for plant protection products calculator (Version 30MAR2015)
|Within farms transmission model for Schmallenberg Virus
|User-friendly interface version of the QMRA model for Salmonella in pigs
Currently there are 18 records available.
Statistics on keywords
Query records from Zenodo
I was further on interested in the current distribution of keywords each record was tagged with. Zenodo supports two types of keywords. Simple free text keywords and ‘subjects’. Subjects need to come from a controlled vocabulary, in which each topic has an URI.
EFSA uses the GACS vocabulary, and so a certain topic ‘salmonella’ is represented as URI ‘http://browser.agrisemantics.org/gacs/en/page/C2225’.
The API returns therefore for the subjects only the URI, which is nicely unique and clear but not user friendly as a label. On the URI of each ‘subject’, additional information is available.
The following code retrieves all records and extract all their subjects (which have a Xpath of //d3:subject). The current oai package has some problems with some Zenodo specific metadata, so I parse the raw XML by hand.
The OIA-PMH standard and the oai::get_records function, allow the client to select, in which metadata format he wants to receive the metadata. Here I have selected ‘oai-datacite’, because it is recommended from the Zenodo API documenation and should contain all metadata Zenodo supports, while other metadata formats might only support a smaller subset.
|food additives intake model
|food composition difference testing
I use the ‘map’ function from the ‘purrr’ package to apply to every vector in the result (which is first an xml string) a number of transformations:
- read_xml() – to convert from string to class xml_document
- xml_find_all() – to find all xml nodes given by xpath expression
- xml_text() – get the text from the xml node
Then I combine all this via c() and the reduce() function to obtain a single list of all subjects.
The API returns both types of subjects, the generic keywords and the terms referring to a controlled vocabulary.
The table() command produces then a frequency table for them, of which I show here a subset. We have in this table entries with an English label, and some with the GACS URI.
Add human readable label to GACS topics
To add a human readable label to each GACS URI, I use the GACS API which allows to query information on each topic. So I call the API for each URI and make a table where each row contains a list of (URI,label). This gets the converted into a table with bind_rows()
I use again the ‘map’ function with an anonymous function, which does the call to the GACS API. GACS uses the (Skomsos)[https://github.com/NatLibFi/Skosmos] software, so has an (API)[http://api.finto.fi/doc/] to query the vocabulary.
|emerging infectious diseases
Distributions of labels in efsa-pilot community
To get the final table, I join the label-GACS pairs with the former table and do some clean-up with the functions from tidyr package.
The table is then sorted by frequency and shown on the screen.
As we can see, the most frequent words are ‘risk assessment’ and ‘exposure assessment’, which is no surprise as these is the core of EFSA’s scientific work.
|risk assessment – http://id.agrisemantics.org/gacs/C1470
|quantitative analysis – http://id.agrisemantics.org/gacs/C603
|exposure assessment – http://id.agrisemantics.org/gacs/C29232
|population – http://id.agrisemantics.org/gacs/C2955
|prion diseases – http://id.agrisemantics.org/gacs/C18728
|pesticides – http://id.agrisemantics.org/gacs/C284
|Apoidea – http://id.agrisemantics.org/gacs/C1932
|Salmonella – http://id.agrisemantics.org/gacs/C2225
|pesticide residues – http://id.agrisemantics.org/gacs/C3009
|linear models – http://id.agrisemantics.org/gacs/C3504
|model validation – http://id.agrisemantics.org/gacs/C4332
|time – http://id.agrisemantics.org/gacs/C4525
|pollinators – http://id.agrisemantics.org/gacs/C5325
|decision support systems – http://id.agrisemantics.org/gacs/C8154
|acute risk assesment
|chronic risk assesment
|bovine spongiform encephalopathy – http://id.agrisemantics.org/gacs/C14182
|calculation – http://id.agrisemantics.org/gacs/C15337
To monitor regularly this distribution can help in keeping the list of all keywords clean and eventually propose additional subjects to the GACS vocabulary.