RDF Tutorial#

The metadata is converted to an RDF data file and can be queried using the SPARQL query language.

Loading the data#

We will load the dataset from the previous tutorial into GraphDB. To install GraphDB, go to graphdb-free and register to download the installer (registration is free and required!).

After successful installation and running the program, you should be able to access the application at http://localhost:7200. To load the data into a repository do the following:

If you did not complete the previous tutorials you can obtain the resulting RDF file from here and the complete study in RDF with all participants here (right click + Save link as...).

  • Click on Repositories under Setup

  • Create new repository

    • GraphDB Repository

  • Give it a name in the Repository ID*

    • Leave everything else as default

  • Choose the repository in the dropdown menu on the top right

  • Import

  • Import the RDF (.ttl) file

Tip

We suggest importing RDF data into separate named graphs (contexts).
This allows for the selective removal and tracking of triples by deleting graphs instead of wiping the repository.
This is done using the Target graphs option during import,
select Named graph and type something meaningful such as an IRI, e.g. file:my-datafile.ttl for instance.
Manage graphs via the Explore -> Graphs Overview or SPARQL UPDATE queries.

  • Click import

  • The data should load within a few seconds to minutes, depending on size

When you return to the home screen (click GraphDB) you should see your local active repository with a certain number of statements depending on the RDF file.

Enable autocomplete#

To make life easier we will enable autocomplete for the SPARQL queries.

  • Click on Autocomplete under Setup

  • Toggle Autocomplete on for the repository you created

Explore the data#

Now the data is loaded we can start exploring the data. To do so, use the Explore view:

  • Click on Explore on the sidebar

  • Select Visual graph

  • In the Easy Graph bar type “Investigation” and select the http://jermontology.org/ontology/JERMOntology#Investigation URL

  • Click on the “inv_demo1” node or however you named the investigation

  • Follow the “hasPart” links to the study and the other nodes

Do you see the connections between the nodes and the excel sheet?

  • Click on one of the Observation Units (e.g., obs_XDRS176892)

  • A sidebar should appear

  • What properties are used and do you see different namespaces?

Query the data#

Now that we have explored the data we can start querying it. To do this we will use the SPARQL query language:

  • Click on SPARQL in the sidebar

  • In the query box type the following query:

To obtain all observation units

PREFIX jerm: <http://jermontology.org/ontology/JERMOntology#>
PREFIX ppeo: <http://purl.org/ppeo/PPEO.owl#>
SELECT *
WHERE {
  ?ou a ppeo:observation_unit .
}

Index

Observation ID

1

fair:inv_demo1/stu_control_vs_infected/obs_O_SAMD00665829

2

fair:inv_demo1/stu_control_vs_infected/obs_O_SAMD00665819

3

fair:inv_demo1/stu_control_vs_infected/obs_O_SAMD00665820

4

fair:inv_demo1/stu_control_vs_infected/obs_O_SAMD00665831

To obtain all observation units that are female

PREFIX jerm: <http://jermontology.org/ontology/JERMOntology#>
PREFIX ppeo: <http://purl.org/ppeo/PPEO.owl#>
PREFIX mixs: <https://w3id.org/mixs/>
SELECT *
WHERE {
  ?ou a ppeo:observation_unit .
  ?ou mixs:0000811 'female' .
}

Observation ID

1

fair:inv_demo1/stu_control_vs_infected/obs_O_SAMD00665829

2

fair:inv_demo1/stu_control_vs_infected/obs_O_SAMD00665819

3

fair:inv_demo1/stu_control_vs_infected/obs_O_SAMD00665820

4

fair:inv_demo1/stu_control_vs_infected/obs_O_SAMD00665831

To obtain all observation units that are female and a trader

PREFIX jerm: <http://jermontology.org/ontology/JERMOntology#>
PREFIX ppeo: <http://purl.org/ppeo/PPEO.owl#>
PREFIX mixs: <https://w3id.org/mixs/>
PREFIX fair: <http://fairbydesign.nl/ontology/>
SELECT *
WHERE {
  ?ou a ppeo:observation_unit .
  ?ou mixs:0000811 'female' .
  ?ou jerm:hasPart ?sample .
  ?sample fair:occupation 'Trader' .
}

ou

sample

1

fair:inv_demo1/stu_control_vs_infected/obs_O_SAMD00665820

fair:inv_demo1/stu_control_vs_infected/obs_O_SAMD00665820/sam_SAMD00665820

Overview of the different occupations

PREFIX jerm: <http://jermontology.org/ontology/JERMOntology#>
PREFIX ppeo: <http://purl.org/ppeo/PPEO.owl#>
PREFIX mixs: <https://w3id.org/mixs/>
PREFIX fair: <http://fairbydesign.nl/ontology/>
SELECT DISTINCT ?occ
WHERE {
  ?ou a ppeo:observation_unit .
  ?ou jerm:hasPart/fair:occupation ?occ .
}

occ

1

“Unemployed”

2

“Farming”

3

“Trader”

4

“Farmer”

As you might have noticed, the SPARQL query language is case sensitive for variables. Thus, it is crucial to have proper standardisation methods in place. For example there is no ‘trader’ in the dataset but there is a ‘Trader’.