Retrieving >50 pathways from evidences

Hi Keith

Pagination on Evidence is possible, although it is a little more tricky than other areas.

Consider the following query and parameters:

query PaginatedEvidence($ensgId: String!, $efo: [String!]!, $ds: [String!]!) {
  target(ensemblId: $ensgId) {
    evidences(efoIds:$efo, datasourceIds:$ds) {
      count
      rows {
        id
      }
      cursor
    }
  }
}

parameterised over:

{
  "ensgId": "ENSG00000141736",
  "efo": ["EFO_0000311"],
  "ds": ["reactome", "slapenrich"]
}

The response will show that there are 63 entries, but there are only 25 rows returned.

You’ll notice that as part of the request we asked for a cursor. This can either have a value or be null. If the value is null then there are no more records. If there is a value, then you can use that value as a parameter into a follow up query:

query PaginatedEvidence($ensgId: String!, $efo: [String!]!, $ds: [String!]!) {
  target(ensemblId: $ensgId) {
    evidences(efoIds:$efo, datasourceIds:$ds, cursor: "WzEsIjVlMGExNmQyNzhhZWEyMzU3MDg5MWZlYTBiMGZiZjI0MmUyZGMwYmQiXQ==") {
      count
      rows {
        id
      }
      cursor
    }
  }
}

This will return the next set of 25 results, and another different cursor will be returned as part of the response, which will collect the following page until eventually no cursor will be returned and you know you have all the results.

Depending on what you wish to do with the data, you might be better off exploring accessing it through Google Cloud Big Query where the data is available as a public dataset.

A query such as:

SELECT pathways
FROM `open-targets-prod.platform.evidence` 
WHERE datasourceId IN ('slapenrich', 'reactome') AND targetId = 'ENSG00000141736' AND diseaseId = 'EFO_0000311'
LIMIT 10
2 Likes