Query disease for descendants

Hi everyone,

I’m trying to query a list of selected diseases for their descendants. I’ve seen from the documentation that there are different ways to query for descendants.

The first one is very simple:

query descendants_test {
disease(efoId: “EFO_0001421”) {
descendants
}
}

Another option is:

query disease_children {
disease(efoId: “EFO_0001421”) {
children{
descendants
}
}
}

the last option is :

query disease_children {
disease(efoId: “EFO_0001421”) {
parents{
descendants
}
}
}

These 3 options clearly return 3 different results.

These three options clearly return different results. Can you please explain to me the difference behind these queries?

Additionally, I would like to know which code is most suitable for my goal, which is to find only the direct descendants of a given disease.

Thank you so much!! :smiley:
Vittorio

Hi @Vittorio_lembo!

To get the direct descendants only I’d suggest to use the children endpoint.

Briefly:

  • descendants returns a list containing all the terms in the ontology tree that descend from a given term. You’ll get not only the direct descendants of your trait of interest but also the descendants of those children, and so on.
  • children returns an object with only the direct descendants of your trait. You can fetch the ID and/or the name.
  • parents.descendants, therefore, returns a list of objects for each parent term of your given term, including all their descendants (both direct and indirect). This is why you will find the ID you’re interested in within these lists.

For a more graphical explanation, I suggest you look at the response of this query for rheumatoid arthritis in the API playground and compare it with our ontology widget.

query diseaseAnnotation {
  disease(efoId: "EFO_0000685") {
    id
    name
    descendants
    children {
      id
    }
    parents {
      id
      descendants
    }
  }
}

Thank you for your question. It is our intention to improve the documentation of our API to make these questions clearer.

Best,
Irene

1 Like

Thank you so much Irene, now it is much clearer how these functions work

Best,
Vittorio