Searching the Ontology Lookup Service is done first by creating an object `OlsSearch` using the `OlsSearch()` constructor. Query responses are then retrieved with the `olsSearch()` function.

OlsSearch(
  q,
  ontology = "",
  type = "",
  slim = "",
  fieldList = "",
  queryFields = "",
  exact = FALSE,
  groupField = FALSE,
  obsoletes = FALSE,
  local = TRUE,
  childrenOf = "",
  rows = 20L,
  start = 0L
)

olsSearch(object, all = FALSE)

# S4 method for class 'OlsSearch'
show(object)

olsRows(object)

olsRows(object) <- value

allRows(object)

Arguments

q

`characher(1)` containing the search query.

ontology

`character()` defining the ontology to be queried. Default is the empty character, to search all ontologies.

type

`character()` restricting the search to an entity type, one of `"class"`, `"property"`, `"individual"` or `"ontology"`.

slim

`character()` restricts the search to an particular set of slims by name.

fieldList

`character()` specifcies the fields to return. The defaults are iri, label, short_form, obo_id, ontology_name, ontology_prefix, description and type. Default is `""` for all fields.

queryFields

`character()` specifcies the fields to query, the defaults are label, synonym, description, short_form, obo_id, annotations, logical_description, iri. Default is `""` for all fields.

exact

`logical(1)` defining if exact matches should be returned. Default is `FALSE`.

groupField

`logical(1)`, set to `TRUE` to group results by unique id (IRI).

obsoletes

`logical(1)` defining whether obsolete terms should be queried. Default is `FALSE`.

local

`character(1)`, default is `FALSE`. Set to `TRUE` to only return terms that are in a defining ontology e.g. only return matches to gene ontology terms in the gene ontology, and exclude ontologies where those terms are also referenced.

childrenOf

`character()` to restrict a search to children of a given term. Supply a list of IRI for the terms that you want to search under.

rows

`integer(1)` defining the number of query returns. Default is 20L. Maximum number of values returned by the server is 1000. To retrieve the next results, set `start` 1000. See examle below.

start

`integer(1)` defining the results page. number. Default is 0L.

object

`OlsSeach` result object.

all

`logical(1)` Should all rows be retrieved. Default is `FALSE`. Can also be set in the queary object directly with `allRows()`.

value

replacement value

References

- OLS3 API (the OLS4 API should function identically to the OLS3): <http://www.ebi.ac.uk/ols4/ols3help>

- REST API for OLS: <https://www.ebi.ac.uk/ols4/swagger-ui/index.html>

Author

Laurent Gatto

Examples


## Many results across all ontologies
OlsSearch(q = "trans-golgi")
#> Object of class 'OlsSearch':
#>   query: trans-golgi 
#>   requested: 20 (out of 13264)
#>   response(s): 0 

## Exact matches
OlsSearch(q = "trans-golgi", exact = TRUE)
#> Object of class 'OlsSearch':
#>   query: trans-golgi 
#>   requested: 20 (out of 258)
#>   response(s): 0 

## Exact match in the gene ontology (go or GO) only
OlsSearch(q = "trans-golgi", exact = TRUE, ontology = "go")
#> Object of class 'OlsSearch':
#>   ontolgy: go 
#>   query: trans-golgi 
#>   requested: 20 (out of 35)
#>   response(s): 0 
OlsSearch(q = "trans-golgi", exact = TRUE, ontology = "GO")
#> Object of class 'OlsSearch':
#>   ontolgy: GO 
#>   query: trans-golgi 
#>   requested: 20 (out of 35)
#>   response(s): 0 

## Exact match in the GO and Uberon
OlsSearch(q = "trans-golgi", exact = TRUE,
          ontology = c("GO", "Uberon"))
#> Object of class 'OlsSearch':
#>   ontolgies: GO, Uberon 
#>   query: trans-golgi 
#>   requested: 20 (out of 39)
#>   response(s): 0 

## Testing different ESI queries
OlsSearch(q = "electrospray", ontology = "MS")
#> Object of class 'OlsSearch':
#>   ontolgy: MS 
#>   query: electrospray 
#>   requested: 20 (out of 0)
#>   response(s): 0 
OlsSearch(q = "ionization", ontology = "MS")
#> Object of class 'OlsSearch':
#>   ontolgy: MS 
#>   query: ionization 
#>   requested: 20 (out of 0)
#>   response(s): 0 
OlsSearch(q = "electrospray ionization", ontology = "MS")
#> Object of class 'OlsSearch':
#>   ontolgy: MS 
#>   query: electrospray ionization 
#>   requested: 20 (out of 0)
#>   response(s): 0 
OlsSearch(q = "electrospray ionization", ontology = "MS", exact=TRUE)
#> Object of class 'OlsSearch':
#>   ontolgy: MS 
#>   query: electrospray ionization 
#>   requested: 20 (out of 0)
#>   response(s): 0 

## Request 5 results instead of 20 (default)
OlsSearch(q = "plasma,membrane", ontology = "go", rows = 5)
#> Object of class 'OlsSearch':
#>   ontolgy: go 
#>   query: plasma,membrane 
#>   requested: 5 (out of 4199)
#>   response(s): 0 
## Same as above
OlsSearch(q = "plasma membrane", ontology = "go", rows = 5)
#> Object of class 'OlsSearch':
#>   ontolgy: go 
#>   query: plasma membrane 
#>   requested: 5 (out of 4199)
#>   response(s): 0 

## or, once the object was created
(res <- OlsSearch(q = "plasma,membrane", ontology = "go"))
#> Object of class 'OlsSearch':
#>   ontolgy: go 
#>   query: plasma,membrane 
#>   requested: 20 (out of 4199)
#>   response(s): 0 
olsRows(res) <- 5
res
#> Object of class 'OlsSearch':
#>   ontolgy: go 
#>   query: plasma,membrane 
#>   requested: 5 (out of 4199)
#>   response(s): 0 

## all results
res <- allRows(res)
res
#> Object of class 'OlsSearch':
#>   ontolgy: go 
#>   query: plasma,membrane 
#>   requested: 4199 (out of 4199)
#>   response(s): 0 

res <- OlsSearch(q = "trans-golgi", ontology = "go", rows = 5)
res
#> Object of class 'OlsSearch':
#>   ontolgy: go 
#>   query: trans-golgi 
#>   requested: 5 (out of 926)
#>   response(s): 0 
res <- olsSearch(res)
res
#> Object of class 'OlsSearch':
#>   ontolgy: go 
#>   query: trans-golgi 
#>   requested: 5 (out of 926)
#>   response(s): 5 
as(res, "data.frame")
#>                                         iri ontology_name ontology_prefix
#> 1 http://purl.obolibrary.org/obo/GO_0000138            go              GO
#> 2 http://purl.obolibrary.org/obo/GO_0005802            go              GO
#> 3 http://purl.obolibrary.org/obo/GO_1990676            go              GO
#> 4 http://purl.obolibrary.org/obo/GO_0032588            go              GO
#> 5 http://purl.obolibrary.org/obo/GO_0098629            go              GO
#>   short_form  description                                     label     obo_id
#> 1 GO_0000138 The Golg....                      Golgi trans cisterna GO:0000138
#> 2 GO_0005802 The netw....                       trans-Golgi network GO:0005802
#> 3 GO_1990676 The lipi....             Golgi trans cisterna membrane GO:1990676
#> 4 GO_0032588 The lipi....              trans-Golgi network membrane GO:0032588
#> 5 GO_0098629 A proces.... trans-Golgi network membrane organization GO:0098629
#>    type
#> 1 class
#> 2 class
#> 3 class
#> 4 class
#> 5 class
trms <- as(res, "olsTerms")
trms
#> Object of class 'olsTerms' with 5 entries
#>  From the GO ontology
#>   GO:0000138, GO:0005802 ... GO:0032588, GO:0098629 
termPrefix(trms)
#> GO:0000138 GO:0005802 GO:1990676 GO:0032588 GO:0098629 
#>       "GO"       "GO"       "GO"       "GO"       "GO" 
termId(trms)
#>   GO:0000138   GO:0005802   GO:1990676   GO:0032588   GO:0098629 
#> "GO:0000138" "GO:0005802" "GO:1990676" "GO:0032588" "GO:0098629" 

## Setting rows and start parameters
tg1 <- OlsSearch(q = "trans-golgi", rows = 5, start = 0) |>
                 olsSearch() |>
                 as("data.frame")
tg2 <- OlsSearch(q = "trans-golgi", rows = 5, start = 5) |>
                 olsSearch() |>
                 as("data.frame")
tg3 <- OlsSearch(q = "trans-golgi", rows = 10, start = 0) |>
                 olsSearch() |>
                 as("data.frame")

## The two consecutive small results are identical
## to the larger on.
identical(rbind(tg1, tg2), tg3)
#> [1] TRUE