Pages

Wednesday, April 03, 2019

BioSchemas CreativeWork annotation in Bioconductor Vignettes

Since the EU BioHackathon in Paris last year, I've picked up Bioschemas stuff more extensively, to help the ELIXIR Metabolomics and Toxicology (in development) communities getting their stuff more FAIR. We could annotate training material already (see this ELIXIR NL post), but big boon was annotation of vignettes on Bioconductor. Over the past 2-3 months I have been exploring this, and on Monday at the #metaRbolomics meeting in Wittenberg, with a room full or R users, I got the right pointers to a promising lead.

So, because the vignettes are generated differently than Markdown on GitHub, I had to find the right hooks. In the end, I found these in one vignette adding a Google Analytics tracker in the header of the file. Bingo!

Screenshot of Google's Structured Data Testing Tool.
So, here's how to do it. The R package set up allows adding custom HTML to the generated HTML, either in the header and at the start or end of the body. I went for the header. But I had to wait two days for the BioConductor website to make a new BridgeDbR package binary (1st day), and for it to update the website (2nd day).

The HTML snippet (saved as bioschemas.html) to add is basically a <script> element with a fragment of JSON-LD:

<script type="application/ld+json">
{
  "@context":"http://schema.org/",
  "@type":"CreativeWork",
  "about":"This tutorial describes how to use the BridgeDbR package for identifier mapping.",
  "audience":[
    "http://edamontology.org/topic_3070",
    "http://edamontology.org/topic_3314"
  ],
  "genre":[
    "http://edamontology.org/topic_0605",
    "http://edamontology.org/operation_3282",
    "http://edamontology.org/data_1025",
    "http://edamontology.org/data_0982"
  ],
  "name":"BridgeDbR Tutorial",
  "author":[{
    "@type":"Person",
    "name":"Egon Willighagen",
    "identifier":"0000-0001-7542-0286"
  }],
  "difficultyLevel": "beginner",
  "keywords":"ELIXIR RIR, BridgeDb",
  "license":"AGPL-3",
  "url":[
    "https://bioconductor.org/packages/devel/bioc/vignettes/BridgeDbR/inst/doc/tutorial.html"
  ],
  "version":"1.17.4"
}
</script>

The other half of the story is to instruct the HTML generation pipeline to add it, which is done with this bit of YAML in your Markdown file (part of it you should already have):

output: 
  BiocStyle::html_document:
    toc_float: true
    includes:
      in_header: bioschemas.html

Check the full folder here.

No comments:

Post a Comment