Using OAK for Environmental Ontologies

  • author: Chris Mungall

  • created: 2022-10-24

This tutorial walks through the neuro-relevant subset of the ENVO as well as SWEET.

  • to help understand the structure of ENVO

  • to show how to do advanced OAK queries and visualization (CLI and programmatic) on ENVO

  • demonstrate rudimentary text annotation

Running this notebook locally or on mybinder requires 0.1.41 or higher

Create an alias

For convenience we will set a bash alias within Jupyter.

The first time you run this, a copy of envo.db.gz is downloaded from S3, which may include a delay - for subsequent invocations, the cached copy will be used

[1]:
%alias envo runoak -i sqlite:obo:envo

Basic lookup

We will first lookup a term by name

[2]:
envo info biome
ENVO:00000428 ! biome

multiple terms can be entered, using either IDs or labels (later we will see how to include extensional terms that expand queries to sets of terms)

[15]:
envo info archipelago "hydrothermal vent" beach
ENVO:00000220 ! archipelago
ENVO:00000215 ! hydrothermal vent
ENVO:00000091 ! beach

hierarchical tree displays

The Oak Tree command will show a hierarchical tree for any set of terms.

Like any graph-oriented OAK command this is parameterized by --predicates (-p), so to show only is-a:

[4]:
envo tree biome -p i
* [] BFO:0000001 ! entity
    * [i] BFO:0000002 ! continuant
        * [i] BFO:0000004 ! independent continuant
            * [i] BFO:0000040 ! material entity
                * [i] RO:0002577 ! system
                    * [i] ENVO:01000254 ! environmental system
                        * [i] ENVO:01001110 ! ecosystem
                            * [i] **ENVO:00000428 ! biome**

note the default output is markdown-friendly, so this can be pasted into a GitHub issue (or a Jupyter cell) and it will render, like this:

  • [] BFO:0000001 ! entity

    • [i] BFO:0000002 ! continuant

      • [i] BFO:0000004 ! independent continuant

        • [i] BFO:0000040 ! material entity

          • [i] RO:0002577 ! system

            • [i] ENVO:01000254 ! environmental system

              • [i] ENVO:01001110 ! ecosystem

                • [i] ENVO:00000428 ! biome

We can also have the tree command show descendants (using --down).

The results can sometimes lead to “path explosions”, we can control this by setting a maximum number of hops using --max-hops:

[16]:
envo tree biome -p i --down --max-hops 2
* [] ENVO:01000254 ! environmental system
    * [i] ENVO:01001110 ! ecosystem
        * [i] **ENVO:00000428 ! biome**
            * [i] ENVO:01001838 ! arid biome
            * [i] ENVO:01001837 ! subalpine biome
            * [i] ENVO:01001836 ! montane biome
                * [i] ENVO:01000223 ! montane savanna biome
                * [i] ENVO:01000216 ! montane shrubland biome
            * [i] ENVO:01001835 ! alpine biome
                * [i] ENVO:01001505 ! alpine tundra biome
            * [i] ENVO:01001834 ! subpolar biome
            * [i] ENVO:01001832 ! subtropical biome
                * [i] ENVO:01001833 ! mediterranean biome
                    * [i] ENVO:01000229 ! mediterranean savanna biome
                    * [i] ENVO:01000217 ! mediterranean shrubland biome
                    * [i] ENVO:01000208 ! mediterranean woodland biome
                    * [i] ENVO:01000047 ! mediterranean sea biome
                        * [i] ENVO:01000857 ! temperate mediterranean sea biome
                        * [i] ENVO:01000128 ! dilution basin mediterranean sea biome
                        * [i] ENVO:01000004 ! concentration basin mediterranean sea biome
                * [i] ENVO:01000222 ! subtropical woodland biome
                    * [i] ENVO:01000208 ! mediterranean woodland biome
                * [i] ENVO:01000213 ! subtropical shrubland biome
                    * [i] ENVO:01000217 ! mediterranean shrubland biome
                * [i] ENVO:01000187 ! subtropical savanna biome
                    * [i] ENVO:01000229 ! mediterranean savanna biome
            * [i] ENVO:01001831 ! temperate biome
                * [i] ENVO:01000860 ! temperate marine upwelling biome
                * [i] ENVO:01000856 ! temperate marginal sea biome
                * [i] ENVO:01000221 ! temperate woodland biome
                * [i] ENVO:01000215 ! temperate shrubland biome
                * [i] ENVO:01000189 ! temperate savanna biome
            * [i] ENVO:01001830 ! tropical biome
                * [i] ENVO:01001230 ! tropical marginal sea biome
                * [i] ENVO:01000859 ! tropical marine upwelling biome
                * [i] ENVO:01000854 ! tropical marine coral reef biome
                * [i] ENVO:01000220 ! tropical woodland biome
                * [i] ENVO:01000214 ! tropical shrubland biome
                * [i] ENVO:01000188 ! tropical savanna biome
            * [i] ENVO:01000339 ! polar biome
            * [i] ENVO:00002030 ! aquatic biome
                * [i] ENVO:00000873 ! freshwater biome
                    * [i] ENVO:01000253 ! freshwater river biome
                        * [i] ENVO:00000890 ! small river biome
                        * [i] ENVO:00000889 ! large river delta biome
                        * [i] ENVO:00000888 ! large river headwater biome
                        * [i] ENVO:00000887 ! large river biome
                    * [i] ENVO:01000252 ! freshwater lake biome
                        * [i] ENVO:00000892 ! small freshwater lake biome
                        * [i] ENVO:00000891 ! large freshwater lake biome
                    * [i] ENVO:00000893 ! xeric basin biome
                * [i] ENVO:00000447 ! marine biome
                    * [i] ENVO:01000858 ! marine upwelling biome
                        * [i] ENVO:01000860 ! temperate marine upwelling biome
                        * [i] ENVO:01000859 ! tropical marine upwelling biome
                    * [i] ENVO:01000048 ! ocean biome
                    * [i] ENVO:01000047 ! mediterranean sea biome
                        * [i] ENVO:01000857 ! temperate mediterranean sea biome
                        * [i] ENVO:01000128 ! dilution basin mediterranean sea biome
                        * [i] ENVO:01000004 ! concentration basin mediterranean sea biome
                    * [i] ENVO:01000046 ! marginal sea biome
                        * [i] ENVO:01001230 ! tropical marginal sea biome
                        * [i] ENVO:01000856 ! temperate marginal sea biome
                    * [i] ENVO:01000045 ! epeiric sea biome
                    * [i] ENVO:01000024 ! marine benthic biome
                        * [i] ENVO:01000127 ! marine cold seep biome
                        * [i] ENVO:01000030 ! marine hydrothermal vent biome
                            * [i] ENVO:01000054 ! marine basaltic hydrothermal vent biome
                            * [i] ENVO:01000053 ! marine ultramafic hydrothermal vent biome
                            * [i] ENVO:01000052 ! marine white smoker biome
                            * [i] ENVO:01000051 ! marine black smoker biome
                        * [i] ENVO:01000029 ! marine reef biome
                            * [i] ENVO:01000123 ! marine sponge reef biome
                            * [i] ENVO:01000050 ! marine subtidal rocky reef biome
                            * [i] ENVO:01000049 ! marine coral reef biome
                                * [i] ENVO:01000854 ! tropical marine coral reef biome
                        * [i] ENVO:01000028 ! marine hadal zone biome
                        * [i] ENVO:01000027 ! marine abyssal zone biome
                        * [i] ENVO:01000026 ! marine bathyal zone biome
                        * [i] ENVO:01000025 ! marine neritic benthic zone biome
                    * [i] ENVO:01000023 ! marine pelagic biome
                        * [i] ENVO:01000033 ! oceanic pelagic zone biome
                            * [i] ENVO:01000040 ! oceanic benthopelagic zone biome
                            * [i] ENVO:01000039 ! oceanic hadal pelagic zone biome
                            * [i] ENVO:01000038 ! oceanic abyssopelagic zone biome
                            * [i] ENVO:01000037 ! oceanic bathypelagic zone biome
                            * [i] ENVO:01000036 ! oceanic mesopelagic zone biome
                            * [i] ENVO:01000035 ! oceanic epipelagic zone biome
                            * [i] ENVO:01000034 ! oceanic sea surface microlayer biome
                        * [i] ENVO:01000032 ! neritic pelagic zone biome
                            * [i] ENVO:01000043 ! neritic mesopelagic zone biome
                            * [i] ENVO:01000042 ! neritic epipelagic zone biome
                            * [i] ENVO:01000041 ! neritic sea surface microlayer biome
                    * [i] ENVO:01000022 ! marine salt marsh biome
                    * [i] ENVO:01000020 ! estuarine biome
            * [i] ENVO:00000446 ! terrestrial biome
                * [i] ENVO:01000219 ! anthropogenic terrestrial biome
                    * [i] ENVO:01000248 ! dense settlement biome
                        * [i] ENVO:01000249 ! urban biome
                    * [i] ENVO:01000247 ! rangeland biome
                    * [i] ENVO:01000246 ! village biome
                * [i] ENVO:01000181 ! mangrove biome
                * [i] ENVO:01000180 ! tundra biome
                    * [i] ENVO:01001505 ! alpine tundra biome
                * [i] ENVO:01000176 ! shrubland biome
                    * [i] ENVO:01001369 ! tidal mangrove shrubland
                    * [i] ENVO:01000218 ! xeric shrubland biome
                    * [i] ENVO:01000216 ! montane shrubland biome
                    * [i] ENVO:01000215 ! temperate shrubland biome
                    * [i] ENVO:01000214 ! tropical shrubland biome
                    * [i] ENVO:01000213 ! subtropical shrubland biome
                        * [i] ENVO:01000217 ! mediterranean shrubland biome
                * [i] ENVO:01000175 ! woodland biome
                    * [i] ENVO:01000222 ! subtropical woodland biome
                        * [i] ENVO:01000208 ! mediterranean woodland biome
                    * [i] ENVO:01000221 ! temperate woodland biome
                    * [i] ENVO:01000220 ! tropical woodland biome
                    * [i] ENVO:01000178 ! savanna biome
                        * [i] ENVO:01000223 ! montane savanna biome
                        * [i] ENVO:01000190 ! flooded savanna biome
                        * [i] ENVO:01000189 ! temperate savanna biome
                        * [i] ENVO:01000188 ! tropical savanna biome
                        * [i] ENVO:01000187 ! subtropical savanna biome
                            * [i] ENVO:01000229 ! mediterranean savanna biome

Visualization

The Oak Viz can be used to create flexible configurable visualizations centered around a set of input terms

[1]:
envo viz "oak woodland" -o output/oak-woodland.png
  Cell In[1], line 1
    envo viz "oak woodland" -o output/oak-woodland.png
         ^
SyntaxError: invalid syntax

img

Accessing SWEET

SWEET is also indexed in the SemSQL index, so we can download ready-made sqlite files

(the SWEET owl files can also be accessed directly using OAK, but we do not cover this in this tutorial)

First we will set up a Jupyter alias for convenience

[2]:
%alias sweet runoak -i sqlite:obo:sweetAll
[9]:
sweet search l~biome
sweet:realmBiolBiome/Biome ! biome
sweet:realmBiolBiome/TerrestrialBiome ! terrestrial biome
[24]:
sweet descendants sweet:realmBiolBiome/Biome
sweet:realmBiolBiome/Anthromes ! anthromes
sweet:realmBiolBiome/Barren ! barren
sweet:realmBiolBiome/Biome ! biome
sweet:realmBiolBiome/Biota ! biota
sweet:realmBiolBiome/Croplands ! croplands
sweet:realmBiolBiome/DenseSettlements ! dense settlements
sweet:realmBiolBiome/Forested ! forested
sweet:realmBiolBiome/Rangelands ! rangelands
sweet:realmBiolBiome/SparseTrees ! sparse trees
sweet:realmBiolBiome/Terrain ! terrain
sweet:realmBiolBiome/TerrestrialBiome ! terrestrial biome
sweet:realmBiolBiome/Villages ! villages
sweet:realmBiolBiome/Wildlands ! wildlands
[32]:
sweet tree .desc biome
* [] sweet:reprSciComponent/SystemComponent ! system component
    * [i] sweet:reprSciComponent/Environment ! environment
        * [i] **sweet:realmBiolBiome/Biome ! biome**
            * [i] **sweet:realmBiolBiome/TerrestrialBiome ! terrestrial biome**
                * [i] **sweet:realmBiolBiome/Rangelands ! rangelands**
                * [i] **sweet:realmBiolBiome/Terrain ! terrain**
                * [i] **sweet:realmBiolBiome/Wildlands ! wildlands**
                    * [i] **sweet:realmBiolBiome/SparseTrees ! sparse trees**
                    * [i] **sweet:realmBiolBiome/Barren ! barren**
                * [i] **sweet:realmBiolBiome/DenseSettlements ! dense settlements**
                * [i] **sweet:realmBiolBiome/Villages ! villages**
                * [i] **sweet:realmBiolBiome/Biota ! biota**
                * [i] **sweet:realmBiolBiome/Anthromes ! anthromes**
                * [i] **sweet:realmBiolBiome/Forested ! forested**
                * [i] **sweet:realmBiolBiome/Croplands ! croplands**

Accessing ENVO through Bioportal

[19]:
%alias bpenvo runoak -i bioportal:envo
[21]:
bpenvo annotate "Peatlands have acted as net CO2 sinks. Rock biome terrestrial biome"
match_type: PREF
object_id: ENVO:00001995
object_label: rock
object_source: https://data.bioontology.org/ontologies/ENVO
subject_end: 43
subject_label: ROCK
subject_start: 40

---
match_type: PREF
object_id: ENVO:00000428
object_label: biome
object_source: https://data.bioontology.org/ontologies/ENVO
subject_end: 49
subject_label: BIOME
subject_start: 45

---
match_type: PREF
object_id: ENVO:00000428
object_label: biome
object_source: https://data.bioontology.org/ontologies/ENVO
subject_end: 67
subject_label: BIOME
subject_start: 63

---
match_type: PREF
object_id: ENVO:00000446
object_label: terrestrial biome
object_source: https://data.bioontology.org/ontologies/ENVO
subject_end: 67
subject_label: TERRESTRIAL BIOME
subject_start: 51

---
[27]:
%alias agroportal runoak -i agroportal:
[33]:
agroportal annotate "Peatlands have acted as CO2 sinks"
match_type: SYN
object_id: http://www.yso.fi/onto/afo/p122
object_label: bogs
object_source: http://data.agroportal.lirmm.fr/ontologies/AFO
subject_end: 9
subject_label: PEATLANDS
subject_start: 1

---
match_type: PREF
object_id: http://id.agrisemantics.org/gacs/C10734
object_label: peatlands
object_source: http://data.agroportal.lirmm.fr/ontologies/GACS
subject_end: 9
subject_label: PEATLANDS
subject_start: 1

---
match_type: PREF
object_id: http://aims.fao.org/aos/agrovoc/c_13929
object_label: peatlands
object_source: http://data.agroportal.lirmm.fr/ontologies/AGROVOC
subject_end: 9
subject_label: PEATLANDS
subject_start: 1

---
match_type: PREF
object_id: http://www.yso.fi/onto/afo/p902
object_label: peatlands
object_source: http://data.agroportal.lirmm.fr/ontologies/AFO
subject_end: 9
subject_label: PEATLANDS
subject_start: 1

---
match_type: SYN
object_id: https://www.tno.nl/agrifood/ontology/common-greenhouse-ontology#CO2
object_label: Carbon Dioxide
object_source: http://data.agroportal.lirmm.fr/ontologies/CGO
subject_end: 27
subject_label: CO2
subject_start: 25

---
match_type: PREF
object_id: http://opendata.inra.fr/resources/hSC9z#co2
object_label: CO2
object_source: http://data.agroportal.lirmm.fr/ontologies/TRANSMAT
subject_end: 27
subject_label: CO2
subject_start: 25

---
match_type: SYN
object_id: http://aims.fao.org/aos/agrovoc/c_1302
object_label: carbon dioxide
object_source: http://data.agroportal.lirmm.fr/ontologies/AGROVOC
subject_end: 27
subject_label: CO2
subject_start: 25

---
match_type: PREF
object_id: http://www.yso.fi/onto/afo/p4770
object_label: CO2
object_source: http://data.agroportal.lirmm.fr/ontologies/AFO
subject_end: 27
subject_label: CO2
subject_start: 25

---
match_type: SYN
object_id: CHEBI:16526
object_label: carbon dioxide
object_source: http://data.agroportal.lirmm.fr/ontologies/PECO
subject_end: 27
subject_label: CO2
subject_start: 25

---
match_type: SYN
object_id: http://id.agrisemantics.org/gacs/C381
object_label: carbon dioxide
object_source: http://data.agroportal.lirmm.fr/ontologies/GACS
subject_end: 27
subject_label: CO2
subject_start: 25

---
match_type: SYN
object_id: http://opendata.inra.fr/anaeeThes/c2_2680
object_label: carbon dioxide
object_source: http://data.agroportal.lirmm.fr/ontologies/ANAEETHES
subject_end: 27
subject_label: CO2
subject_start: 25

---
[ ]: