Friday, July 24, 2015

Shiny new toys 1: How I got new toys

Image by "Peng" from Wikimedia Commons CC BY-SA

When I was a kid, one of the most exciting things was to talk about and show my friends the new toys that I had just gotten.  As an adult, it's no different - the toys are just different.  Recently, I've been able to play with several new biodiversity informatics "toys" and I'm going to "show my friends" by writing several blog posts about them and let my friends (you) play with them if you want.

My first new toy: Darwin-SW version 0.4


Well, it's a little bit of an exaggeration to call the Darwin-SW ontology (DSW) a "new" toy.  Cam Webb and I put the first version of it together in a few frenetic months back in 2010-2011.  But DSW was in limbo for several years while we waited for some basic questions about the future of Darwin Core (DwC) to be settled by TDWG (Biodiversity Information Standards).  One issue was what to do about the fact that DwC originally defined two parallel sets of classes, one in the main dwc:[1] namespace and another in the dwctype: [2] namespace.  At first we thought the dwc: ones were the ones to use.  But then we thought the dwctype: ones were preferred.  Then we just weren't sure.

In the end (October 2014), the dwctype: classes were deprecated and the dwc: ones (including the new dwc:Organism class, which we had modeled in DSW) prevailed.  So we finally knew what to build DSW around.  The other thing that finally got settled in March of 2015 was the adoption of the DwC RDF Guide, which had languished in TDWG purgatory for a couple years.  There were some properties that we had defined in DSW that would be unnecessary if they could be replaced by properties in the new dwciri: [3] namespace that the RDF Guide established.  When the Guide was adopted, we were pretty much able to finalize the cast of characters in the DSW ontology.

I'm not going to say a lot about DSW here.  There is more than most people would ever want to read about it at our old Google Code site, which we are now in the process of moving over to the new DSW GitHub site.  The most succinct summary is in our manuscript submitted to the Semantic Web Journal, which has suffered in reviewer hell [4] for something like 15 months now since it was first submitted (shame on you SWJ!).

The bottom line here is that in the spring of this year we were finally able to release what we believe to be a stable version (0.4) of DSW and start to use it in a stable way in our own work.  Which leads me to...

My second new toy: Bioimages RDF

Again, it is a bit disingenuous to call Bioimages RDF "new".  The Bioimages website had been serving some form of RDF/XML through content negotiation of its URIs since 2010.  But the graph was unstable because the predicates were constantly changing as our understanding of how Darwin Core properties should be used as RDF and as DSW (on which the Bioimages graph model is primarily based) developed.  When DSW 0.4 was at last released as a stable version, it was finally possible to release Bioimages RDF without potential users having to worry about the predicates and classes changing without warning.

Click here to see a larger version of this graph

The Bioimages RDF graph model (diagram above) is basically the same as the DSW model, except that Bioimages adds properties from the Audubon Core Standard and the (somewhat obsolete but not yet replaced) TDWG TaxonConcept Ontology.

The actual Bioimages dataset itself is not as complicated as the RDF graph model shown above.  The data actually "live" primarily in five pipe-delineated CSV files, one each for agents, determinations, images, organisms, and sensu references.  The data are CC0 licensed and freely available on the Bioimages GitHub site.  The five resource types that Bioimages documents in the CSV files would only require five of the nodes (bubbles) in the diagram above.  So why make it more complicated?

The point of Darwin-SW is to create the simplest graph model that enables all of the one-to-many relationships that most people in the traditional biodiversity informatics community have said they need.  (I said "traditional" because the DSW model doesn't do much for metagenomics people.  But that wasn't the problem we set out to address.)  In the simplest possible model, Bioimages doesn't really "need" Event and Location nodes because all Occurrences are considered to be at separate Events and Locations (i.e. there is a 1:1:1 relationship between Occurrence, Event, and Location).  But when the data in the CSV files are expressed as RDF, the "extra" nodes are created so that it is possible for the Bioimages data to be merged with data from a provider that has 1:many relationships in places where Bioimages doesn't (for example a provider that's tracking many Occurrences at one collecting Event, or many Events at one Location).  Just for fun, Cam once merged his Xmalesia data from Indonesia (expressed as DSW RDF) with the Bioimages data (mostly from the southeastern US).  He had no problem running simple queries on the combined dataset because both followed the basic DSW graph model.

The 1488578 RDF triples currently in the Bioimages dataset are generated from the CSV files.  In the past I did it using some horrid software that I wrote myself.  However, recently I've started hanging out with a fun group of people who are mostly affiliated with the Jean and Alexander Heard Library at Vanderbilt.  Their interest is primarily in the Digital Humanities (I had to look that up - see my blog post on the subject), but we have a common interest in playing with metadata.  The primary outcome of this interaction for me was that I have started to learn how to use XQuery, so as an exercise I wrote queries that would transform the data in the CSV files into XHTML (for the Bioimages website; view source for this file for an example) and RDF/XML (to generate the RDF triples in the Bioimages graph; here is an example) files for organisms and images.  Currently, the queries output into many static files that are served in a boring way when the URIs are dereferenced via content negotiation, but along with the XQuery group I've also been experimenting with the server capabilities of BaseX, so eventually these individual files may be generated on the fly from a database.  Using a hack of those XQueries, I can also output the entire database as RDF/XML into a few files that zip up into a relatively small and portable file (bioimages-rdf.zip) that can be obtained from the Bioimages GitHub repo.  The version in the current database release (2014-07-22; http://dx.doi.org/10.5281/zenodo.21009) takes up only 3.7 MB.

As fun as it is to say that I've generated an RDF graph of about 1.5 million triples representing real data, those triples are completely useless unless you can do something with them.  So that brings me to ...

My third new toy: Callimachus-based SPARQL endpoint

Right around the time last winter when things were starting to move with the stalled TDWG stuff, Suellen Stringer-Hye , Digital Librarian at the Heard Library approached me about proposing a Dean's Fellow project to explore using Callimachus to set up a SPARQL endpoint that could query a triplestore containing the Bioimages RDF.  I was very excited about this prospect because I was keen to find out what it was possible to do with a real RDF dataset based on Darwin-SW.  The project was approved and Sean King, a senior in the Vanderbilt Biological Sciences Department who works on genomics in the Rokas Lab, was chosen to work on the the project with us as a Dean's Fellow.

Callimachus is actually really easy to set up as a localhost on a desktop machine.  The installation directions on the Callimachus website are very straightforward. I've set it up on two of my Windows computers and it only took a few minutes to get it running, although it may take significantly longer if you run into port conflicts and have to troubleshoot that.  The server is cranked up by running a batch file from the DOS command prompt and you are up and running:


 You run the software through a browser pointed to the localhost (default: port 8080).  That takes you to a screen where you can upload data files or invoke the SPARQL endpoint:


Before you can start playing with the SPARQL endpoint, you have to upload the RDF data files.  Callimachus will accept RDF in a number of serializations.  I used XML because that's what I had, but it will also accept RDF in Turtle and JSON-LD (I think) serializations.  It takes only a few moments to upload a small file, such as the FOAF vocabulary.  However, it can take several minutes to upload larger files, such as the Bioimages images.rdf file that contains hundreds of thousands of triples.  On my first try loading that file, I thought that I'd hung the computer but all that was required was patience.  It is also possible to load an entire batch of XML files that are bundled in a zip file.  I haven't tried this, but Suellen says it works fine.  So one should be able to load the entire Bioimages dataset just by uploading the bioimages-rdf.zip file into Callimachus.  If you upload a new version of a particular file, Callimachus will replace any previous version of the file that has the same name.

The names of the files that contain particular triples are significant because Callimachus uses them when referencing particular dataset graphs in SPARQL queries.  For example, if a query contains the line:


FROM <http://localhost:8080/organisms.rdf>

the triples contained in the organisms.rdf file will be searched in the query.  If you have only loaded a single dataset into your Callimachus instance, it doesn't really matter if your query restricts the search via FROM clauses.  However, if several datasets are loaded, queries may return annoying results from datasets that are irrelevant to the search if you don't specify FROM clauses.

Once you've loaded all of the files containing the triples, just click on the SPARQL link in the file list and voilà! ... you are staring at a blank box that expects you to enter a SPARQL query.  If you are unfamiliar with SPARQL, this is a bit daunting.  In my next blog post, I'm going to provide some queries that you can run on the Bioimages data.

After playing around with Callimachus as a localhost for a while, Sean, Suellen, and I started talking about the next step, which was to get Callimachus running on the library server.  When you have a new toy, it is always nice to let others play with it, so we wanted to make sure that it was possible for queries to be sent from clients outside the rdf.library.vanderbilt.edu subdomain.  Otherwise, users would be stuck with typing ugly queries into the blank box.  The issue is to change the settings on Callimachus to allow cross-domain requests.  It took us a while to find where the settings were located, but eventually we figured it out:

1. In the Callimachus Home folder, click Edit and add "*" as an Allowed origin.
2. Load the SPARQL page (http://localhost:8080/sparql?view), drop down the menu, select "Permissions", and change the "Reader" value to "public".

If you want to experiment with querying a Callimachus endpoint via a script in a webpage, it is necessary to make these changes even if you aren't planning to put the endpoint on the Internet.  By default, most browsers are using port 80, so if a browser queries the server (at port 8080), it's considered a cross-domain request and the endpoint will refuse to respond if the Callimachus settings are left at their defaults.  (I hope I have stated the technical details of this correctly. Many thanks to Cliff Anderson, Heard Library Director of Scholarly Communications, for helping us troubleshoot this problem!)

Playing (nicely) with the toys

We have just recently finished creating a somewhat user-friendly demo web page that queries the Bioimages RDF graph via the Heard Library public SPARQL endpoint.  You can try it at:

http://www.library.vanderbilt.edu/webimages/Bioimages/

(Note: we are still tinkering with this page, so its behavior may be somewhat unpredictable.  Many thanks to Jodie Gambill, Systems Librarian at the Heard Library for helping us get it to work the way we wanted!)  To the end user, the page looks like a typical search page that uses web services to provide appropriate options to the user.  By selecting appropriate values from the dropdowns, a user can screen images and view thumbnails of images that meet the selected criteria.  Clicking on a thumbnail takes the user to the image web page where detailed metadata and access to the original high-resolution image are provided.

Under the hood, this behavior is accomplished in an atypical way: by making queries via Javascript in the HTML to the public SPARQL endpoint, and using the results to change the appearance of the web page.  Because the page is being served from http://www.library.vanderbilt.edu/ and the endpoint is at http://rdf.library.vanderbilt.edu/, the queries are being made cross-domain.  Because we have allowed cross-domain queries, the HTML page could actually be served from anywhere (even loaded as a local file on your hard drive) and it would still work.

The "guts" of the page are in the Javascript file http://www.library.vanderbilt.edu/webimages/Bioimages/bioimages.js, which must be located in the same directory as the HTML.  The basic mechanism that makes the page work involves several steps:

1. Assemble a string that contains the query and URL-encode it.  For example:

        var string = "PREFIX Iptc4xmpExt: <http://iptc.org/std/Iptc4xmpExt/2008-02-29/>"+
                    "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>"+
                    'SELECT DISTINCT ?category WHERE {' +
                    "?image Iptc4xmpExt:CVterm ?view." +
                    "?view rdfs:subClassOf ?featureCategory." +
                    "?featureCategory rdfs:label ?category." +
                    '}'
                    +'ORDER BY ASC(?category)';
 var encodedQuery = encodeURIComponent(string);

2. Append the string to the URI of the endpoint as a query, then use AJAX (facilitated by jQuery) to send the query to the endpoint and receive the results XML:

       $.ajax({
            type: 'GET',
            url: 'http://rdf.library.vanderbilt.edu/sparql?query=' + encodedQuery,
            headers: {
                Accept: 'application/sparql-results+xml'
            },
            success: parseCategoryXml

I really didn't want to get the results in XML format.  There is a JSON format for SPARQL results that can be requested in the Accept header:

application/sparql-results+json

but unfortunately XML is the only format currently supported by Callimachus.  To see an example of the result of a query, click here.

3. Use jQuery's XML-processing capabilities to pull the desired values from the results XML and insert them into a component of the page's HTML:

    $("#div1").html("").append(resultsStatement + "<table>");
    //step through each "result" element
    $(xml).find("result").each(function() {
        tableRow="<tr><td>";
        // pull the "binding" element that has the name attribute of "image"
        $(this).find("binding[name='image']").each(function() {
            tableRow=tableRow+"<a href='"+$(this).find("uri").text() + "'>";
        });
        // pull the "binding" element that has the name attribute of "uri"
        $(this).find("binding[name='uri']").each(function() {
           tableRow=tableRow+"<img src='"+$(this).find("uri").text() + "'></a></td><td>";
        });
        // pull the "binding" element that has the name attribute of "title"
        $(this).find("binding[name='title']").each(function() {
            tableRow=tableRow+$(this).find("literal").text() + "</td></tr>";
            $("#div1").append(tableRow);
        });
    });
    $("#div1").append("</table>");

We hacked these basic three functions several times to make the page behave the way we wanted.  First, after the page loads, the endpoint is queried to find out what values of genus, state, and category exist in the database.  Those values are used to populate the corresponding three dropdowns. If the user selects a value for genus, the endpoint is further queried to find out what species values exist in the database for that genus and the values of the species dropdown are set.  When the "Search" button is clicked, the main query is sent and the results are formatted into an HTML table that is displayed at the bottom of the page.

This is a relatively simple application, but it demonstrates how anyone anywhere could create code to retrieve data from the Heard Library public SPARQL endpoint and use it to do something interesting in a Web page.  Even more interesting things could be done with more user interaction to create more complex queries or by displaying the results in other ways, such as maps or charts.

Next time: playing roughly with the toys

The demo webpage is a nice demonstration of making use of the three toys (Darwin-SW, the Bioimages data, and the Heard Library SPARQL endpoint) to do something useful.  However, whenever kids get a new toy, they are usually not interested in playing with it according to the instructions.  In my next blog post, I will report on my attempts to try doing more interesting things with the toys, including finding out what it takes to break them.


[1] dwc: = http://rs.tdwg.org/dwc/terms/
[2] dwctype: = http://rs.tdwg.org/dwc/type/
[3] dwciri: = http://rs.tdwg.org/dwc/iri/
[4] Possibly the only thing worse than TDWG purgatory!

Tuesday, July 21, 2015

Confessions of an RDF agnostic, part 7: Where are we now?

I had intended a long time ago to wrap up this series of blog posts from April and May of 2014.  However, I got really busy with other things and haven't taken the time to write the last installment until now.  Perhaps that is a good thing.  At that time in 2014 I was really pessimistic about the outlook for using RDF to do anything useful in the realm of biodiversity informatics, but now my outlook is somewhat rosier.  Who wants to read a depressing, pessimistic blog post anyway?


The Rod Page Challenge, one more time
 
I started this series of blog posts by talking about the Rod Page Challenge, stated succinctly in October 2011 as: "What new things have we learnt about biodiversity by converting biodiversity data into RDF?"[1]  I then blathered on for a number of blog posts about what it means for a semantic client to "learn", unintended consequences caused by careless use of terms having entailments, and the sorts of machine "learning" that don't really result in anything useful (triple "bloating" caused by the failure to reuse terms and identifiers and the "discovery" of lots of triples that don't actually help you answer the kinds of questions that interest you).  I promised to revisit the Rod Page Challenge, which I modified into this form: "What new things have humans learnt about biodiversity by converting biodiversity data into RDF?  What interesting new inferences have semantic clients made using RDF?".

I should start by confessing that in the interest of haranguing, I failed to mention in my previous posts that Rod's challenge was met within a few days by Cam Web.[2]  You can see Cam's approach on a wiki page in the TDWG RDF/OWL Task Group's Google Code site (at least until Google Code goes down - when it does, check GitHub for the RDF TG's new home).  Cam set up some triplestores queriable via SPARQL (unfortunately those triplestores are currently down), loaded the datasets (http://dx.doi.org/10.5281/zenodo.20990) that Rod provided, and created two SPARQL queries that demonstrated some form of machine "learning" from the datasets.  (Note on 2015-07-22: Rod has loaded the triples where they can be queried at http://dydra.com/rdmpage/tdwg-challenge/@query#reflections-table.  Cam's first query [5] can be run there.)

The first query demonstrated machine "learning" of the first sort: increasing the number of triples relevant to a particular resource by pooling triples from several independent, but linked datasets.  In his example, he found all of the species in the genus Bufo according to UniProt.  He then used linked data from GenBank and Wikipedia (via DBpedia) to find the conservation status of the species and geocoordinates of occurrences. One could call this a sort of victory for the "Linked Data" approach.

The second query demonstrated machine "learning" of the second sort: materializing entailed triples that have not previously been stated explicitly by anyone.  In his example, the rdfs inferencing capabilities of the 4sr reasoner associated with one of the triplestores was used to infer unstated triples based on rdfs:subClassOf entailments.  One could call this a sort of victory for the "Semantic Web" approach.

So should Cam win the esteemed prize [3] for meeting the challenge?  One could say that easily associating species' names with reported geocoordinates and the conservation status of the species is a "learned" thing that wouldn't be obvious to a human.  It's cool that this was "learned" using RDF data from different "silos" (although one could also probably find out the same information from a single data provider like GBIF that uses conventional database tools).  It is also possible that Cam's first query could be hacked a bit to satisfy some of the other questions Rod asked in his blog ("what is the conservation status of frogs sequenced in Genbank?, is there correlation between the conservation status of a frog and the date it was discovered?, who has described the most frog species?, etc.").  Perhaps we should give Cam a thumbs-up for the prize based on this query.  The second query resulted in inferences, but I'm not sure they would qualify as "interesting" since the subclass relationships it materializes can be seen by going to the webpage that is displayed when http://www.uniprot.org/taxonomy/651673 is dereferenced in a browser and clicking on the "All lower taxonomy nodes" link.   So I probably would give a thumbs down on that one and call it a rather hollow victory for the Semantic Web. I suppose Rod should be the ultimate judge on whether to award Cam the prize, but I'm not aware that Rod ever made a judgment about Cam's entry.

Image from http://linkeddata.org/ CC By-SA

A hollow victory for Linked Data?

A key point of Rod's "Challenge" blog post was:
My contention is that actually we can't do any of this because the data is siloed due to the lack of shared identifiers and vocabularies (I suspect that there is not a single identifier any of these files share). The only way we can currently link these data sets together is by shared string literals (e.g., taxonomic names), in which case why bother with RDF?

In Cam's first query, the "glue" that linked the UniProt data to the GenBank data was the triple pattern:

  ?gb dcterms:subject ?sp .

which was satisfied because the bio2rdf.org RDF descriptions contained triples like:

http://bio2rdf.org/genbank:EU566842 dcterms:subject <http://purl.uniprot.org/taxonomy/8354>.

I'm not sure how that relationship was established - the GenBank record for EU566842 itself doesn't seem to contain any link to the UniProt IRI.  Does bio2rdf use string matching to make this link?

In Cam's first query, the "glue" that linked the UniProt data to Wikipedia was the triple pattern:

    ?sp rdfs:seeAlso ?dbp .

which was satisfied because of triples like:

<http://purl.uniprot.org/taxonomy/888540> rdfs:seeAlso <http://dbpedia.org/resource/Telmatobius_yuracare>.

That particular set of triples was actually generated by Rod himself in the linkout.rdf file that he provided to give a boost to the challenge.  The file was generated based on mapping in "iPhilo LinkOut", a project described in http://dx.doi.org/10.1371/currents.RRN1228 .  Examination of the iPhilo methods gives: "The initial mapping was constructed by extracting the scientific name of the taxon that was the topic of each Wikipedia page, then finding a match for this in the NCBI taxonomy database." Aaaargh!  Linked Data fails here - it's really all just string matching.

"male" = "M" = "M." = "macho" = "M +" = ...  ?

What's so bad about string matching?

In my last blog post, I described datatype properties (properties having string literals as their values) as a sort of "dead end".  This is because currently, you aren't allowed to use literals as the subjects of triples.  So if a machine encountered the triple:

http://bioimages.vanderbilt.edu/ind-baskauf/14750#2002-08-05baskauf dwc:genus "Argemone".

it could not try to "learn" more about the properties of the literal "Argemone" by dereferencing it (it's not a IRI), nor through a SPARQL query like:

DESCRIBE "Argemone" WHERE {
     "Argemone" ?predicate ?object.
     }

(literals are not allowed in the subject position of an RDF triple). 

To some extent, you could get around this by setting up SPARQL queries where two triple patterns share a common literal object, like this:

  ?resource1 dwc:genus ?genus.
  ?resource2 ?property ?genus.

where ?genus could have a value of a literal like "Argemone".  If ?resource1 were http://bioimages.vanderbilt.edu/ind-baskauf/14750#2002-08-05baskauf, I guess a machine could investigate ?resource2 and ?property and possibly "learn" something about "Argemone".  However, this method depends on the literal that represents a certain resource having a consistent controlled value.

Let's suppose I'm interested in finding pairs of organisms that were established in a location by the same means.  Darwin Core provides the term dwc:establishmentMeans (a literal-value property) for providing this kind of information.

I could run this query:

SELECT ?organism1 ?organism2 WHERE {
     ?organism1 dwc:establishmentMeans ?means.
     ?organism2 dwc:establishmentMeans ?means.
     }

The query results would contain pairs of organisms that shared the same means of establishment.  But what if organism1 has a dwc:establishmentMeans value of "naturalized" and organism2 has a dwc:establishmentMeans value of "naturalised"?  No match.  One could simply chalk this up to failure to use a consistent controlled vocabulary, but these kinds of things happen a lot even with what would seem like "simple" controlled vocabularies [4].  One could also argue that a similar misspelling could happen with a IRI like:

http://rs.gbif.org/vocabulary/gbif/establishment_means/naturalised

However, if users bother to find and reuse an appropriate IRI, they probably will go to the effort to make sure that they get it right (or acquire the IRI values using software rather than typing the value out of their head).

The other issue with using literal values to link resources is that you really don't need RDF to do it.  Google's algorithms for linking things using strings are probably better than any literal-matching SPARQL queries that most people could come up with.

Agnostic to Believer???

 "If there is something you know, communicate it. If there is something you don't know, search for it." — An engraving from the 1772 edition of the Encyclopédie; Truth, in the top center, is surrounded by light and unveiled by the figures to the right, Philosophy and Reason.

Image from an engraving by Benoît Louis Prévost, 1804.  Public domain.  Source: https://commons.wikimedia.org/wiki/File:Encyclopedie_frontispice_full.jpg










At the close of my previous blog post, in addition to revisiting the Rod Page Challenge, I also promised to talk about what it would take to turn me from an RDF Agnostic into an RDF Believer.  I will recap the main points about what I think it will take in order for the Rod Page Challenge to REALLY be met (i.e. for machines to make interesting inferences and provide humans with information about biodiversity that would not be obvious otherwise):

1. Resource descriptions in RDF need to be rich in triples containing object properties that link to other IRI-identified resources.
2. "Discovery" of IRI-identified resources is more likely to lead to interesting information when the linked IRIs are from Internet domains controlled by different providers.
3. Materialized entailed triples do not necessarily lead to "learning" useful things.  Materialized entailed triples are useful if they allow the construction of more clever or meaningful queries, or if they state relationships that would not be obvious to humans.

In the introduction to this post, I said that last year when I finished the previous blog post, I was pessimistic about the prospects for doing anything useful with RDF in the context of biodiversity informatics.  One of the primary reasons that I was pessimistic was because the TDWG process for moving the Darwin Core (DwC) standard seemed to be hopelessly stuck.  However, in October the confusion about the duplicate DwC classes was cleared up and the long-awaited (by me at least) dwc:Organism class was accepted.  These changes made it possible to stabilize Darwin-SW, which is designed to facilitate object-property links between instances of all of the core classes of Darwin Core.  Then in March, the DwC RDF Guide was officially added to the standard, making it possible for the first time to unambiguously create linkages to either literal or IRI-identified object resources using Darwin Core terms.  The completion of the DwC RDF Guide and Darwin-SW makes it now possible (in my opinion) to satisfy point number 1 above.

Making it possible to create rich, object-property linkages doesn't necessarily mean that people will actually DO it.   Point number 2 isn't going to happen until the biodiversity community settles on some mechanism for generating, exposing, and reusing IRI identifiers, preferably ones that dereference to return consistent RDF.  This is a difficult task because it requires consensus-building and self-discipline on the part of data providers to reuse identifiers instead of constantly issuing new ones (and subsequently leading to triple "bloat").  So I'm still relatively pessimistic on that point.

On a small scale, completion of the DwC RDF Guide, stabilization of Darwin-SW, and the adoption of Audubon Core has made it possible for me to generate stable and standardized RDF representations of organisms and images in the Bioimages database.  Bioimages organism and image IRIs dereference to RDF/XML (e.g. http://bioimages.vanderbilt.edu/vanderbilt/7-314.rdf) and all 1488578 triples in the database can be downloaded (file: bioimages-rdf.zip, 3.7 Mb; http://dx.doi.org/10.5281/zenodo.21009) from the Bioimages GitHub repo (https://github.com/baskaufs/Bioimages).  A summer Heard Library Dean's Fellowship has made it possible for Suellen String-Hye and me to work with Sean King on setting up a triplestore and SPARQL endpoint that allows the Bioimages RDF data to be queried.  The Callimachus-based endpoint is now live at http://rdf.library.vanderbilt.edu/sparql and loaded with the Bioimages triples.  So the stage is set for experimenting to find out what kinds of SPARQL-based reasoning is practical with a real 1.7 M triple RDF dataset.  After that experimentation, I'll know a little better how I feel about what is realistic to expect for point number 3. 

So overall, I've moved incrementally along the line from RDF agnostic towards RDF believer.  For me to become a true believer, we'll need to come up with datasets thousands of times larger than the Bioimages dataset, and to successfully conduct on those data reasoning that is computable in a reasonable amount of time and that results in materialized triples that are actually novel and interesting.  That's a pretty tall order.

With that conclusion, I'll draw this series of blog posts to a close.  I'm planning to start on some posts to report what I've learned from experimenting with the Bioimages triples via the new endpoint.  So stay tuned...

[1] Rod has posted the challenge data at https://github.com/rdmpage/tdwg-challenge-rdf and loaded it into an endpoint if you want to play with it.
[2] See also Rod's followup blog post http://iphylo.blogspot.co.uk/2011/10/reflections-on-tdwg-rdf.html in which Rod posts a SPARQL query and shows a visualization of the frog data created by Olivier Rovellotti.
[3] An announcement by Rod in his blog (http://iphylo.blogspot.com/) that the challenge entry sucked.
[4] See https://soyouthinkyoucandigitize.wordpress.com/2013/07/18/data-diversity-of-the-week-sex/ for an interesting example.
[5] In the event that Google Code is gone when you read this, Cam's query was:

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX uni: <http://purl.uniprot.org/core/> 
PREFIX dcterms: <http://purl.org/dc/terms/> 
PREFIX dbp: <http://dbpedia.org/ontology/> 
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> 

CONSTRUCT {
  ?gb dcterms:subject ?sp .
  ?sp uni:scientificName ?sn .
  ?sp rdfs:seeAlso ?dbp .
  ?dbp dbp:conservationStatus ?cons .
  ?gb dcterms:relation _:occ .
  _:occ geo:long ?long .
  _:occ geo:lat ?lat .
}
WHERE {
  # Where name is Bufo and rank is genus
  ?gen uni:scientificName "Bufo" .
  ?gen uni:rank uni:Genus .
  # go down two subclasses, check it's a species
  ?sect rdfs:subClassOf ?gen .
  ?sp rdfs:subClassOf ?sect .
  ?sp uni:rank uni:Species .
  ?sp uni:scientificName ?sn .
  # link to genbank and find those with occurrences
  ?gb dcterms:subject ?sp .
  ?gb dcterms:relation [
     geo:long ?long ;
     geo:lat ?lat ] .
  # optionally, link to DBpedia and get the conservation status
  OPTIONAL {
    ?sp rdfs:seeAlso ?dbp .
    ?dbp dbp:conservationStatus ?cons . }
 
 The second query was:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX uni: <http://purl.uniprot.org/core/>

SELECT ?n WHERE {
  ?s uni:scientificName ?n .
  ?s rdfs:subClassOf <http://purl.uniprot.org/taxonomy/651673> .
}

However, reasoning of the entailed rdfs:subClassOf relationships was done automatically by a reasoner built in to Cam's triplestore, so if you run the query on a conventional SPARQL endpoint, you can't see the effect of reasoning caused by the materializing of additional entailed rdfs:subClassOf triples.

Friday, May 23, 2014

Confessions of an RDF agnostic, part 6: properties, ontologies, and linking

Dunce cap by Rept0n1x, Wikimedia Commons BY-SA
 The term duns or dunce became ... a synonym for one incapable of scholarship.

Wikipedia article on "Dunce"












 

Meaning and "understanding"

The aspect of RDF that makes it more than just a markup system is that triples are intended to "mean" something.  In the most raw sense of RDF, one can think of the subject and object of a triple as entities that we would like to describe in some way, while the predicate represents some kind of relationship that connects them.  If we adopt the perspective of the rdfs-interpretation of RDF (see the second post in this series for more on interpretations of RDF), we can consider the predicate to represent a property that is used to describe the subject resource (which also implies that we consider the subject to be a thing that we wish to describe).  The object in the triple can be considered to be a value of the property.  RDFS is a convenient semantic extension of RDF, and one that is likely to be accepted by many RDF users since it is consistent with the outlook of commonly-used vocabularies such as Dublin Core (see the DCMI Abstract Model, which was designed to be compatible with RDFS) and within our own biodiversity informatics community, Darwin Core (see the Darwin Core Abstract Model, which is roughly based on Dublin core). 

So buying into the rdfs-interpretation of RDF gives us properties.  It also defines the notion of classes and instances of classes.  With RDFS, we can not only talk about "things" (resources), but also about "kinds of things" (classes).  RDFS defines a special property called rdf:type that is used to connect a resource to the class of which it is an instance [1].  This property is so fundamental, it has a special abbreviation in Turtle and SPARQL: "a".  So if we say

<http://bioimages.vanderbilt.edu/baskauf/11143#loc>
     dwc:decimalLatitude 36.14592^^xsd:decimal;
     a dcterms:Location.


a semantic client can "know" what kind of thing http://bioimages.vanderbilt.edu/baskauf/11143#loc is.  That seems very good, because we have increased a machine's ability to "know".

It is tempting to think that if we program our client to make use of the rdfs-interpretation, we are on the way to achieving Tim Berners-Lee's "intelligent agents" (see second post in this series for the quote) because with the notions introduced by RDFS clients can "know" what kind of thing something is and some stuff about the thing's properties.  A human looking at the two triples above might "know" that the thing identified by the subject IRI is a location, and that it's latitude is N 36.14592 degrees.  However, a semantic client's ability to "know" things is actually very limited.  The introduction to the RDF (1.0) Semantics document puts the ability of a client to "know" into perspective and I recommend reading it for further insight on this topic.  Particularly relevant are these quotes:
Exactly what is considered to be the 'meaning' of an assertion in RDF or RDFS in some broad sense may depend on many factors, including social conventions, comments in natural language or links to other content-bearing documents. Much of this meaning will be inaccessible to machine processing...

The chief utility of a formal semantic theory is not to provide any deep analysis of the nature of the things being described by the language or to suggest any particular processing model, but rather to provide a technical way to determine when inference processes are valid, i.e. when they preserve truth.

To paraphase this bluntly, clients are stupid.  When we make them "aware" of the rdfs-interpretation of RDF, we don't somehow magically endow them with the ability to "understand" what dwc:decimalLatitude "means" or to "understand" what a dcterms:Location is.  We can delude ourselves into thinking that our predicates and classes are meaningful by assigning them clever local names like "decimalLatitude" and "Location" that mean something to humans.  But the triples above don't "mean" anything more to a client than

<http://bioimages.vanderbilt.edu/baskauf/11143#loc>
     xq:p2-glwsopgn_2q4as 36.14592^^xsd:decimal;
     a vr:e33t5pp-98.


Since both terms are HTTP URIs, there may be some hope that "links to other content-bearing documents" might make the terms "mean" something more to clients.  Alas, in its defining RDF, the meaning of the term dwc:decimalLatitude is almost entirely imparted by a human language comment.  There is virtually nothing there that is meaningful to a semantic client aside from the term's designation as an rdfs:property.  Similarly, the defining RDF of dcterms:Location contains little more than a brief, human-readable comment ("A spatial region or named place."), designation as a rdfs:Class, and declaration that it is a subclass of dcterms:LocationPeriodOrJurisdiction. (which itself is defined by a human-readable comment). 

So even though RDF triples have the potential to "mean" something, in many cases that "meaning" depends critically on social conventions about what human-readable comments mean to humans.

Making a client smarter

In my last post in this series, I presented a rather dreary picture of the way that a human might have interactions with a semantic client through the mediation of SPARQL queries.  In the examples in that depressing post, the work of the client was mostly to make up for failure of humans to reach consensus on identifiers.  I'm going to attempt to be more upbeat in this post by talking about how a client might actually "learn" something useful that will help its human partner discover interesting things.

The quote from the RDF Semantics document mentioned three ways that "meaning" might be imparted to RDF:
  1. social conventions
  2. comments in natural language
  3. links to other content-bearing documents
Numbers 1 and 2 are human things.  Number 3 has some potential for machines.  The dream of the semantic web (see the second blog post in this series) was to enable semantic clients to traverse the web of data and accumulate data that would allow humans to use their intuition and inspiration to do wonderful things with those data.  So we might be able to make our clients a little less stupid if we enable them to go out and discover more information that is linked to what they already know.  In my third blog post in this series, I asserted that clients "learned" when they added triples to their graph.  What kinds of properties would enable a client to assemble triples that would add "meaning" that could be leveraged by humans?

To think about this question, I'm going to use the following example [2] :

@prefix po: http://owlfiles.plantontology.org/PO_ .
@prefix dsw: http://purl.org/dsw/ .
@prefix dwc: http://rs.tdwg.org/dwc/terms/ .
<http://bioimages.vanderbilt.edu/uncg/14>
     dwc:establishmentMeans "cultivated";
     a po:0000003;
     dsw:hasDerivative <http://herbarium.unc.edu/592810>.

The properties in this example fall into three categories that will be described in the following sections.



Datatype properties


The first category of property includes those that have literals as objects.   Web Ontology Language (OWL) introduces the notion of a class of properties called datatype properties that link instances (also called "individuals" in OWL) to data values in the form of datatyped literals.  For convenience, I'm going to refer to properties that link instances to literals as "datatype properties" even if their type hasn't been explicitly declared as owl:DatatypeProperty. 

Although the object of a datatype property is a literal, that literal still denotes some entity.  If the literal is accompanied by an explicit datatype IRI, then a client can "understand" the "meaning" of that literal by applying a lexical-to-value mapping (assuming the client's programming includes the capability to do such mapping).  So in the case of a typed literal such as "5"^^xsd:integer, the client can "know" that the literal denotes the abstract number five, rather than the character string "5".  If the literal isn't accompanied by an explicit datatype IRI (i.e., is an untyped literal), it is by default a member of the class xsd:string. Therefore the entity that the literal denotes is the string itself.  In other words, in the example, the resource that the untyped literal "cultivated" denotes is not a conceptual entity for "cultivatedness" but rather is a ten character string composed of the characters "c", "u", "l", "t", "i", "v", "a", "t", "e", and "d".

From the standpoint of discovery, datatype properties are a sort of "dead end".   This is true because it is not permissible in RDF to use a literal as the subject of a triple.  That means that one can't make additional statements in RDF describing the entity that is described by the literal.  In the case of a typed literal such as "5"^^xsd:integer, that probably isn't particularly important since the properties of the entity "the number five" are pretty well known. But in the case of a literal like "cultivated", the client is really in the dark.  When we provide the property/value pair dwc:establishmentMeans "cultivated", we intend it to mean that the subject came to exist through the actions of humans.  But there is no way for a client to know that.  It would be nice if the client at least knew that "cultivated" meant the same thing as "managed" (GBIF's preferred value).  When we had this kind of problem with multiple IRIs in the examples of my previous post, we used owl:sameAs to declare equivalence.  But since literals can't be the subject of triples, we can't say:

"cultivated" owl:sameAs "managed".

because a literal can't be the subject of a triple.  Even if we were allowed to make a statement like that, it would be a bad idea because the statement would be incorrect; the two strings that the literals denote are not equivalent.

This isn't to say that having a client discover datatype properties of a resource is useless for a human that would like to query the graph assembled by the client.  Strings can be very convenient for simple searches.  But unless a community adopts and adheres strictly to a controlled vocabulary, there may be many literals that are intended to represent the same thing (see this blog post by John Wieczorek if you want to know how bad things can get). The bottom line is that datatype properties don't do much for enabling interesting new inferences or discovery of new information.

cul-de-sac

rdf:type and classes


The second property category contains the single property: rdf:type. As I noted earlier, rdf:type and the notion of class membership is an important aspect of the rdfs-interpretation of RDF since (at least in theory) it allows a semantic client to know more about what a resource "is".  In the case of the triple

<http://bioimages.vanderbilt.edu/baskauf/11143#loc> a dcterms:Location.

I noted that there was very little useful information that a semantic client could "learn" by dereferencing the IRI dcterms:Location (i.e. http://purl.org/dc/terms/Location), although a human could guess something about the class because the IRI contains the local name "Location".  The situation is a bit different with this triple:

<http://bioimages.vanderbilt.edu/uncg/14> a po:0000003.

Since the IRI po:0000003 (i.e. http://owlfiles.plantontology.org/PO_0000003) is opaque, a human looking at the triple will have no idea what kind of thing http://bioimages.vanderbilt.edu/uncg/14 is without dereferencing the po:0000003 IRI.  The human dereferencer can discover an rdfs:label property with a value of "whole plant" and know that it's a plant.  But a semantic client can know more.

OBO Ontologies


The term po:0000003 is part of the Plant Ontology, which is one of the Open Biological and Biomedical Ontologies ("OBO" ontologies).  The Plant Ontology is typical for an OBO ontology in that it is very focused on classes.  As of 2014-05-19, the OWL version of the Plant Ontology contained descriptions of 1691 classes and 10 object properties.  The object properties are designed to relate the classes in ways such as "part of", "located in", "adjacent to", etc.  It also makes heavy use of what it refers to as the "is a" property.  In the raw RDF, that translates into rdfs:subClassOf. The Plant Ontology does not define terms that are particularly useful for relating instances [3].  So the Plant Ontology is very useful for talking generically about plants and their features (classes) but is much less useful for talking about particular individual plants (instances).  

Here are some things that a semantic client can "learn" (i.e., here are triples that it can add to its graph) about the class of whole plants by exploring the Plant Ontology:

po:0000003 rdfs:subClassOf po:0009011.  (plant structure)
po:0009011 rdfs:subClassOf po:0025131.  (plant anatomical entity)
po:0000003 rdfs:subClassOf <http://owlfiles.plantontology.org/PO>
(the super class of all Plant Ontology classes)

There are six owl:disjointWith declarations which entail that it is not consistent for a resource to be both a whole plant and also a plant organ, collective organ part structure, portion of plant tissue, collective plant structure, cardinal organ part, or vascular system.  There are also some properties that provide alternative names for the class, but which wouldn't be much benefit to a machine. 

If I assume that I let my client client ingest the subclass properties, what do I get in terms of "learning" on the part of my client?  Putting it another way, what kinds of entailed triples could my client materialize based on the new triples it discovered by dereferencing po:0000003 that would be relevant to my understanding of?  Here are three:

<http://bioimages.vanderbilt.edu/uncg/14> a po:0009011.
<http://bioimages.vanderbilt.edu/uncg/14> a po:0025131.
<http://bioimages.vanderbilt.edu/uncg/14> 
     a <http://owlfiles.plantontology.org/PO>.

As a human, these triples might be useful for me in a SPARQL query if I wanted to restrict my search to things that fall into those classes.  For example, if I wanted to search only for things that were plant anatomical entities, I could do so and http://bioimages.vanderbilt.edu/uncg/14 would come up. 

If I let my client ingest the disjointness properties, what do I get in terms of "learning" on the part of my client?  My client becomes able to detect that its graph is inconsistent if http://bioimages.vanderbilt.edu/uncg/14 is ever discovered or inferred to be a vascular system (or any of the other 5 disjoint classes). 

So in summary, an rdf:type declaration to class from an OBO ontology can enable a client to assemble some triples that would add "meaning" that I could leverage.  However, I would need to carefully consider whether those added triples actually help me enough to make up for the added danger of possible undesired effects (such as unintentionally rendering the graph inconsistent).

Object properties


The third category of property includes those that have IRIs as objects.  OWL introduces the notion of a class of properties called object properties that link subject instances (a.k.a. "individuals" sensu OWL) to object instances.  (Note: these instances do not have to be identified using IRIs - they can be anonymous or "blank" nodes.  But without being identified by an IRI, one cannot establish a link to the resource from outside the graph in which it is initially described.  Since this discussion is about discovery of useful information from elsewhere, I'm limiting this category to IRI-identified instances.)  For convenience, I'm going to refer to properties that link subject instances to IRI-identified object instances as "object properties" even if their type hasn't been explicitly declared as owl:ObjectProperty. 


The example contained this triple:

<http://bioimages.vanderbilt.edu/uncg/14> 
     dsw:hasDerivative <http://herbarium.unc.edu/592810>.

A human could do some guessing about the meaning of this triple by reading the hasDerivative local name and from the subdomain "herbarium...", but would have a clearer understanding of the intended use of dsw:hasDerivative by reading the Darwin-SW documentation (full disclosure: Cam Webb and I wrote Darwin-SW).

A semantic client that dereferenced the property's IRI would learn that it had an inverse property dsw:derivedFrom and that it was transitive.  Both of these properties of dsw:hasDerivative could allow the client to materialize potentially useful triples.  Even if the client and its human handler were completely clueless about what dsw:derivedFrom actually "meant", they would at least know that http://bioimages.vanderbilt.edu/uncg/14 was linked in some way to http://herbarium.unc.edu/592810.  If the client were able to dereference the object IRI [2], it could discover triples like these:

<http://herbarium.unc.edu/592810>
     a dwctype:PreservedSpecimen;
     a dcmitype:PhysicalObject;
     dcterms:created "2010-10-18"^^xsd:date;
     dwcuri:inCollection <http://biocol.org/urn:lsid:biocol.org:col:15495>;
     dsw:evidenceFor <http://herbarium.unc.edu/592810#occ>.

These types are relatively well-known, so that is of some use.  There are also object properties that lead to other resources, whose RDF description could be obtained, e.g.

<http://herbarium.unc.edu/592810#occ>
     a dwctype:Occurrence;
     dwcuri:recordedBy <http://bioimages.vanderbilt.edu/contact/kirchoff#masone>;
     dwc:recordNumber "6";
     dsw:atEvent <http://bioimages.vanderbilt.edu/specimen/ncu592810#eve>.
 
which also has a relatively well-known type and an object property that links to the person who recorded it, which could also be dereferenced, etc., etc.

The point here is that it is object properties that enable the kind of links that permit a semantic client to discover interesting triples that may not have been previously known to the client's human buddy.  The subdomain of the starting subject resource's IRI was bioimages.vanderbilt.edu, but the object properties connect that resource to other resources whose IRIs are managed by herbarium.unc.edu, and biocol.org. I'm likely to be aware of things happening with resources in the bioimages.vanderbilt.edu subdomain because I manage it.  But I could be surprised by metadata served by other providers (unpleasantly surprised in the case of biocol.org since most of the triples that were once there aren't being served anymore!).

Image by Kowloonese from Wikimedia Commons.  Public domain.

Road analogy


We can think about our client as a car driving around looking for information.  The client starts somewhere (the subject resource) and starts driving to look around.  If it drives down a "datatype property road", it hits a dead end.  It might find something useful there, but the road doesn't take it anywhere else.  If it drives down an "rdf:type road", it comes to a cul-de-sac.  The size of the cul-de-sac could range from a dead end to a large loop, with varying amounts of information to be discovered.  If the client drives down an "object property road", there is no way to know the number and length of side-streets that it might encounter, so there is no particular limit to what it might find by driving down those streets.

Returning to the original question I raised, "What kinds of properties would enable a client to assemble triples that would add "meaning" that could be leveraged by humans?", I would assert that object properties that link instances are the most productive sort if our goal is to discover things about biodiversity data that are interesting and novel.

Back to SPARQL


In my last post, I said that the most obvious way that a human could "learn" by interacting with a semantic client through conducting a query using SPARQL (the query language developed by the W3C specifically for use with RDF).  Based on what I've said so far in this post, I'm going to flesh this out a bit more.

I have tried to establish that clients are fundamentally stupid and that humans are fundamentally smart.  So let's let the division of labor reflect this.  The job of the client is to amass a giant blob of triples into its graph and then materialize other triples that the amassed triples entail (subject to the restrictions that its human master puts upon it; see cautionary tales in the third post in this series).  The job of the human is to figure out queries that would leverage the meaning placed upon the triples in order to discover useful information about the "world" described by the graph assembled by the client.  In the case of humans that are biodiversity informaticians, that world will hopefully be the "real" world in which we live.  The SPARQL endpoint mediates the interaction between the human querier and the client.

At its core, SPARQL is really just asking the client to do pattern matching, and by the time we get to the query stage in the process, the client is essentially "done" thinking (i.e. it should have materialized entailed triples before the query is made).  So it's up to the human to come up with triple patterns that can represent a restriction based on a statement that has "real world" meaning.  The human is only going to be successful in doing that if the predicates in the triple patterns and the classes used for typing have a clear, consensus meaning for both the querier and the data providers who generated the triples.  No Semantic Web "magic" is going to fix the problem if there isn't a common understanding of the meaning of the terms.

Here's an example query that would find cultivated plants from which specimens were derived:

PREFIX po: <http://owlfiles.plantontology.org/PO_>
PREFIX dsw: <http://purl.org/dsw/>
PREFIX dwctype: <http://rs.tdwg.org/dwc/dwctype/>
 
SELECT ?resource
WHERE {

     ?resource a po:0000003. 
     ?resource dwc:establishmentMeans "managed".
     ?resource dsw:hasDerivative ?specimen.
     ?specimen a dwctype:PreservedSpecimen.
     }

I like this query because it's nice and simple.  I don't like this query for several reasons.
  • TDWG doesn't actually recognize organisms as a class (yet), nor is it clear what kind of thing has dwc:establishmentMeans as a property (organism? occurrence? ??? There was a long and painful tdwg-content thread about this; I'm too lazy to look it up).  
  • Darwin-SW isn't any kind of ratified standard, but then there aren't any object properties to connect Darwin Core classes because TDWG hasn't worked out anything like a domain model. So at the present we have to use something non-standard. 
  • There is a proposal (stalled, as usual) before TDWG to clarify the Darwin Core classes and their namespaces, so I don't actually know if the class will be dwctype:PreservedSpecimen or dwc:PreservedSpecimen.  
Darn.  Things were looking so hopeful.  OK, let's pretend that either TDWG gets it's act together, or everybody starts thinking about things just like me (neither one is likely).  If we were to work things out, we could make this query more cool by stringing together more object properties:

PREFIX po: <http://owlfiles.plantontology.org/PO_>
PREFIX dsw: <http://purl.org/dsw/>
PREFIX dwctype: <http://rs.tdwg.org/dwc/dwctype/>
 
SELECT ?resource
WHERE {
 
     ?resource a po:0000003.
     ?resource dwc:establishmentMeans "managed".
     ?resource dsw:hasDerivative ?specimen.
     ?specimen a dwctype:PreservedSpecimen.
     ?specimen foaf:depiction ?image.
     ?image a dcmitype:StillImage.
     ?specimen dsw:evidenceFor ?occurrence.
     ?occurrence dwcuri:recordedBy ?collector.
     ?collector foaf:familyName "Smith".
     ?resource dsw:hasIdentification ?id.
     ?id dwc:genus "Quercus".
}

Now the query asks for cultivated plants identified as oaks from which imaged specimens were collected by a person named "Smith".  Notice that in the query, each datatype property is a dead end because the literal can't be put in the subject position of another triple pattern.  Each type declaration ("a") is also a dead end because we will probably want to put a fixed IRI in the object position.  It is the object properties that allow our query to search through the "web of data".

The ability to conduct interesting queries of this sort is fundamentally going to depend on a humans to designate the questions that they want to explore.  The semantic client will assemble the triples, but it isn't smart enough to create the queries.

Linking and the Biocollections Ontology (BCO)


As I noted above, a serious problem is that there are currently no object properties in any TDWG standard that could be used to provide the kinds of linkages that I've argued are so important to enable the discovery of interesting things using RDF.  The stalled Darwin Core RDF Guide provides a few (e.g. dwcuri:recordedBy) but does not link the core classes (e.g. Occurrence, Identification, Event, etc.).  It has been suggested repeatedly that developing the Biological Collections Ontology (BCO; an OBO-like ontology) would be a way forward for solving this problem.  So I'd like to examine the ontology's potential for facilitating linking.

A paper on the BCO [4] (of which I was a co-author) implied that development of that ontology provided a way to link diverse instance data.  During the discussion of the manuscript, I questioned the necessity of creating a complex ontology to link instance data.  The manuscript claimed that combining BCO with datasets would answer important questions, and in the supporting information section provided several use-cases that required linking information.  It was not clear to me how terms from the ontology would facilitate queries that would address these use cases.  I recommended that we include sample SPARQL queries to show how this could be done, but in the end none were ever put into the paper.  I was not interested in holding up what I felt was otherwise a good paper, so I dropped my objections.  Since that time, it was again suggested in a talk at the 2013 TDWG meeting that development of the BCO was an important step towards linking biodiversity data.  Again, no actual queries were provided to show how this might be accomplished.

Let's take a look at Figure 3 from the paper (also discussed at about 10 minutes into the video of the talk).  It suggests linking an insect instance to a taxon instance by asserting that an "identification using key" instance has a specified input that was the insect, and a specified output that was the taxon.  From the latest stable release of the BCO on 2014-05-21 a client could "learn" the following about "has specified input" and "has specified output":

@prefix bfo: http://purl.obolibrary.org/obo/BFO_ .
@prefix obi: http://purl.obolibrary.org/obo/OBI_ .
@prefix ro: http://purl.obolibrary.org/obo/RO_ .
@prefix my: http://example.org/ .

obi:0000293 a owl:ObjectProperty, owl:AnnotationProperty;
     rdfs:label "has_specified_input"@en;
     rdfs:domain obi:0000011;
     owl:inverseOf obi:0000295;
     rdfs:subPropertyOf ro:0002233.

obi:0000295 a owl:ObjectProperty, owl:AnnotationProperty;
     rdfs:label "is_specified_input_of"@en;
     rdfs:range obi:0000011;
     rdfs:subPropertyOf ro:0002352.

obi:0000299 a owl:ObjectProperty, owl:AnnotationProperty;
     rdfs:label "has_specified_output"@en;
     rdfs:domain obi:0000011;
     owl:inverseOf obi:0000312;
     rdfs:subPropertyOf ro:0002234.

obi:0000312 a owl:ObjectProperty, owl:AnnotationProperty;
     rdfs:label "is_specified_output_of"@en;
     rdfs:range obi:0000011;
     rdfs:subPropertyOf ro:0002353.

There are other properties, but they would mostly be useful only for humans.  Here are some more things a client could discover by exploring the various ontologies related to OBI:

obi:0000011 (a planned process) has superclasses bfo:0000007 (process), bfo:0000003 (occurrent), and bfo:0000001 (entity).
ro:0002233 (has input) is subproperty of ro:0000057(has participant).  
ro:0002352 (input of) is subproperty of ro:0000056 (participates in).
ro:0002352 (input of) is subproperty of ro:0002328 (functionally related to).
ro:0002234 (has output) is subproperty of ro:0000057 (has participant).
ro:0002353 (output of) is subproperty of ro:0000056 (participates in).
ro:0002353 (output of) is subproperty of ro:0002328 (functionally related to).

If we link the insect specimen to the taxon using the "has specified output" and "has specified input" properties as was suggested, we have these two triples:

my:identification031  obi:0000299 my:insectTaxon01;
     obi:0000293 my:insect03.

A client that reasoned on the triples from the various ontologies could materialize these 16 entailed triples:

my:identification031 obi:0002234 my:insectTaxon01;
     obi:0000057 my:insectTaxon01.
my:insectTaxon01 obi:0000312 my:identification031;
     obi:0002353 my:identification031;
     obi:0000056 my:identification031;
     obi:0002328 my:identification031.
my:identification031  obi:0002233 my:insect03;
     obi:0000057 my:insect03.
my:insect03  obi:0000295 my:identification031;
     obi:0002352 my:identification031;
     obi:0000056 my:identification031;
     obi:0002328 my:identification031.
my:identification031 a obi:0000011, obi:0000007, obi:0000003, obi:0000003.

Here are some observations based on theses results:
1. Although linking as suggested does connect the insect with the taxon, a single explicit linkage entails eighteen triples that don't provide any information that would improve a human's ability to discover the connection using a query.  A single triple containing a generic object property:

my:insect03 my:identifiedToTaxon my:insectTaxon01.

would be equally effective in making the link.
2. I am not sure why obi:0000293 and the other properties were declared to be both owl:ObjectProperty and owl:AnnotationProperty. This causes an inconsistency because annotation and object properties are disjoint.  I suspect that this is just an error in coding, but having a complex ontology makes this kind of error more likely to happen, and less likely to be noticed. 
3. Figure 3 shows eleven links of various sorts that are made using the two terms obi:0000299 and obi:0000293.  It seems to me that this would complicate querying because a triple pattern like:

?resource1 obi:0000299 ?resource2.

would bind triples that linked various kinds of resources related by various processes.  The human would probably have to complicate the query to sort them out and find the desired kinds of relationships.  One could probably fix that by specifying types for the resources. But simply making it clear in documentation which sorts of resources should be used with a property like my:identifiedToTaxon would be a less complicated approach.
4. None of the properties used in the example above were actually minted in the process of the development of BCO.  I understand and approve of the strategy of re-using terms from existing ontologies, but my point here is that the BCO-building effort did not produce any new capabilities for linking resources in the manner described above.  I could have generated the triples in the example even if the various workshops and meetings devoted to the development of BCO had never happened, because the BCO per se doesn't really increase capabilities for linking by creating new object properties to do the linking.

Provenance and the Biocollections Ontology


Figure 3 also suggests tracking the provenance of samples using ro:0001000 ("derives from") and the caption says that a chain of inputs and outputs can be used to infer that an instance of DNA molecules is derived from an instance of an insect specimen.  Here's what the BCO ontology says about "derives from":

ro:0001000 a owl:ObjectProperty;
     rdfs:label "derives from"@en;
     rdfs:subPropertyOf owl:topObjectProperty.

Using this property, one could describe the links between sampled objects like this:

my:tissueSample01 ro:0001000 my:insectTaxon01.
my:dnaSample01 ro:0001000 my:tissueSample01.

In contrast to the previous properties that had way more semantics than they probably needed to link effectively, this property has virtually no semantics that would be of any use to a machine.  If "derives from" were transitive, then a semantic client could easily materialize the triple

my:dnaSample01 ro:0001000 my:insectTaxon01.

allowing a human to discover all samples that were derived from the insect with a simple query like

SELECT ?derivedSample WHERE { 
?derivedSample ro:0001000 my:insectTaxon01.
}

But since "derives from" isn't transitive, a "stupid" semantic client can't do that kind of dirty work for the human.  The human could write more complex queries, rules, or specialized software to make the connections.  But those kinds of actions wouldn't make use of the reasoning capabilities built into RDF - the statements made in RDF can't directly entail the more distant "derives from" relationship.  [5]

The figure caption suggests tracking the provenance using "inputs and outputs", which might imply that linking should instead be achieved using "has specified input" and "has specified output" like this:

my:tissueSamplingProcess01 obi:0000293 my:insectTaxon01.
my:tissueSamplingProcess01 obi:0000299 my:tissueSample01.
my:dnaExtractionProcess01 obi:0000293 my:tissueSample01.
my:dnaExtractionProcess01 obi:0000299 my:dnaSample01.

I don't have the patience at this point to list all of the triples that this would entail - based on the earlier example, there should be about 32, or perhaps more.  But it is not at all apparent to me how having a client materialize all those triples would allow a client to infer that the instance of DNA molecules was derived from the instance of an insect specimen, or that doing so would make the job of a human querier easier.

OBO ontologies and the lack of clear definitions for terms


There is no question that there is currently a lack of clarity about the meaning of important terms and classes in Darwin Core.  There are several ways dealing with this problem.  One is to make it easier for humans to understand what the terms mean by improving the human-readable definitions of the terms.  This is one of the primary purposes of the (stalled) proposal to clarify the definitions of all Darwin Core classes.  Another would be to introduce clarity by tying the RDF definitions of Darwin Core classes to formal ontologies.  This has already been done by linking the new class dwctype:MaterialSample to the Ontology for Biomedical Investigations (OBI) by making it rdfs:subClassOf http://purl.obolibrary.org/obo/OBI_0100051.  I supported the proposal for defining the material sample class in that way because I think the precise language of the ontologies may be more clear than words along.  However, I also agree with the point made by Joel Sachs in his talk at TDWG 2013 where he cautioned that tying Darwin Core terms directly to external ontologies might result in unintended inferences. So if TDWG goes down the road of tying class definitions to formal ontologies, it should be done with full knowledge of the implications for machine reasoning. 

Wikimedia Commons. left: Luigizanasi CC BY-SA, right: Øyvind Holmstad  CC BY-SA

Hammers and saws


I once was asked a question, which I'll paraphrase as "Don't you think that the BCO approach is better than Darwin-SW approach?".  That is like asking a carpenter "Don't you think that a hammer is better than a saw?"  A hammer is better than a saw if you want to drive nails.  A saw is better than a hammer if you want to cut wood.  The BCO approach is better than Darwin-SW if you want to describe in a clear and semantically precise way how various biodiversity-related classes are related to each other, but it's not very useful for linking things.  The Darwin-SW approach is better than the BCO approach if you want to link things, but it is totally useless as far as describing the nature of biodiversity classes is concerned.  BCO is a hammer; Darwin-SW is a saw.

It has been suggested repeatedly that to move forward, TDWG needs to engage in ontology building, and in particular, by creating OBO-like ontologies.  I am not opposed to building ontologies, as long as we clearly articulate our reasons for doing so and can show what we will accomplish from the effort.  But I do not believe that those reasons have yet been clearly articulated. I certainly do not believe that putting more effort in building the BCO is going to solve TDWG's problem of lack of object properties to link instances of diverse kinds of biodiversity resources.

Summary


1.Despite the illusion generated by local names used in property IRIs, semantic clients have little or no understanding of the actual meaning of properties they encounter.

2. Clients "learn" useful things when they discover novel triples having resource IRIs from Internet domains controlled by other providers. 

3. Clients "learn" useful things when the entailed triples that they materialize help their human partners conduct more clever or meaningful queries.  Simply materializing triples that restate the same linkages, or that declare uninteresting types (like an rdf:type of "super class of all Plant Ontology classes") aren't particularly useful. 

4. Sources of RDF triples that are rich in object properties are most likely to help a human querier discover novel information.

5. If effort is expended toward ontology development, there should be a clear statement (preferably with functioning examples) that shows how that development will help semantic clients construct or evaluate graphs in a way that will assist humans in discovering information that isn't already obvious, or that can't be discovered with more conventional methods.

In my next post, I plan to revisit (for the last time) the Rod Page Challenge, and talk about what must happen to turn me from an RDF agnostic into an RDF believer.

Endnotes


[1] Although rdf:type is in the general rdf: namespace, in RDF 1.1 its meaning is now fleshed out in the RDFS specification http://www.w3.org/TR/2014/REC-rdf-schema-20140225/

[2] Unfortunately the IRI http://herbarium.unc.edu/592810 is a fake.  There are so few real examples of specimens that are meaningfully linked to other things using RDF that I had to make it up.  The other IRIs are real.  There is actual RDF for this specimen at http://bioimages.vanderbilt.edu/specimen/ncu592810 .  View the page source to see the raw RDF.

[3] Technically, I think this isn't true because object properties relate individuals to individuals (i.e., instances to instances).  So I believe that if a Plant Ontology object property is used to relate two classes, the classes would be both classes and instances.  If I am remembering correctly, that is only allowed on OWL Full, so that might be problematic for users who might be disturbed by the undecidability that this would introduce.  I spent about 20 minutes rummaging around the OWL documents trying to find the domain and range declarations for owl:ObjectProperty and to confirm that a resource can only be both a class and instance in OWL Full, but couldn't find it and didn't want to spend any more time on it.  So there is a good chance I'm wrong about this.

[4] Walls RL, Deck J, Guralnick R, Baskauf S, Beaman R, et al. (2014) Semantics in Support of Biodiversity Knowledge Discovery: An Introduction to the Biological Collections Ontology and Related Ontologies. PLoS ONE 9(3): e89606. http://dx.doi.org/10.1371/journal.pone.0089606

[5] Shameless plug for Darwin-SW, which has the transitive property dsw:derivedFrom.  See https://code.google.com/p/darwin-sw/wiki/TokenIssues for more details on how it is used. See http://www.semantic-web-journal.net/content/darwin-sw-darwin-core-based-terms-expressing-biodiversity-data-rdf for SPARQL query examples.