# How to modify data source weights in the API?

**URL:** <https://community.opentargets.org/t/how-to-modify-data-source-weights-in-the-api/1064>\
**Category:** GraphQL API\
**Tags:** ot-platform\
**Created:** [28 April 2023 13:05 UTC](https://community.opentargets.org/t/how-to-modify-data-source-weights-in-the-api/1064 "2023-04-28T13:05:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![philge\_philip](https://dub1.discourse-cdn.com/flex017/user_avatar/community.opentargets.org/philge_philip/32/413_2.png) [@philge\_philip](https://community.opentargets.org/u/philge_philip)\
**Post date:** [28 April 2023 13:05 UTC](https://community.opentargets.org/t/how-to-modify-data-source-weights-in-the-api/1064/1 "2023-04-28T13:05:51Z")

</div>

Hi,

I have come across a statement, “The default weights used in the web application can be modified by the user in the API, to adjust to different prioritisation strategies.”. Can you please tell me how to do this?

Thanks  
Philge

---

<div class="post-metadata">

**Author:** ![dsuveges](https://dub1.discourse-cdn.com/flex017/user_avatar/community.opentargets.org/dsuveges/32/30_2.png) [@dsuveges](https://community.opentargets.org/u/dsuveges)\
**Post date:** [28 April 2023 13:48 UTC](https://community.opentargets.org/t/how-to-modify-data-source-weights-in-the-api/1064/2 "2023-04-28T13:48:49Z")

</div>

Hi,

Once you are fetching associations (associated diseases for a fixed target or associated targets for a fix disease), you have the option to specify datasource weights in the query as follows:

```graphql
query DiseaseAssociationsQuery {
  disease(efoId: "EFO_0005774") {
    id
    associatedTargets(
      page: { index: 0, size: 50 }
      orderByScore: "score"
      BFilter: ""
      aggregationFilters: []
      datasources: [{ id: "ot_genetics", weight: 0.5, propagate: false }]
    ) {
      count
      rows {
        target {
          id
          approvedSymbol
          approvedName
        }
        score
        datatypeScores {
          componentId: id
          score
        }
      }
    }
  }
}

```

You can try out [here](https://api.platform.opentargets.org/api/v4/graphql/browser?operationName=assocs&query=query%20DiseaseAssociationsQuery%20%7B%0A%20%20disease%28efoId%3A%20%22EFO_0005774%22%29%20%7B%0A%20%20%20%20id%0A%20%20%20%20associatedTargets%28%0A%20%20%20%20%20%20page%3A%20%7B%20index%3A%200%2C%20size%3A%2050%20%7D%0A%20%20%20%20%20%20orderByScore%3A%20%22score%22%0A%20%20%20%20%20%20BFilter%3A%20%22%22%0A%20%20%20%20%20%20aggregationFilters%3A%20%5B%5D%0A%20%20%20%20%20%20datasources%3A%20%5B%7B%20id%3A%20%22ot_genetics%22%2C%20weight%3A%200.5%2C%20propagate%3A%20false%20%7D%5D%0A%20%20%20%20%29%20%7B%0A%20%20%20%20%20%20count%0A%20%20%20%20%20%20rows%20%7B%0A%20%20%20%20%20%20%20%20target%20%7B%0A%20%20%20%20%20%20%20%20%20%20id%0A%20%20%20%20%20%20%20%20%20%20approvedSymbol%0A%20%20%20%20%20%20%20%20%20%20approvedName%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20score%0A%20%20%20%20%20%20%20%20datatypeScores%20%7B%0A%20%20%20%20%20%20%20%20%20%20componentId%3A%20id%0A%20%20%20%20%20%20%20%20%20%20score%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D%0A). For details, take a look at the API documentation and schema.

---

<div class="post-metadata">

**Author:** ![cjb-apis](https://dub1.discourse-cdn.com/flex017/user_avatar/community.opentargets.org/cjb-apis/32/471_2.png) [@cjb-apis](https://community.opentargets.org/u/cjb-apis)\
**Post date:** [16 August 2023 14:35 UTC](https://community.opentargets.org/t/how-to-modify-data-source-weights-in-the-api/1064/3 "2023-08-16T14:35:12Z")

</div>

Hi. I found the above helpful, thank you Philge and Daniel for posting the question and response.

From what I can see, amending these weightings affects only the overall association score, rather than the individual score for each of the 7 evidence types - at least this seems to be the response from my queries. Is there a way to amend the API query to adjust the 7 individual association scores as well as the overall score?

I am also wondering if you could provide an explanation for the ‘propagate’ boolean?

Many thanks,  
Charles

---

<div class="post-metadata">

**Author:** ![irene](https://dub1.discourse-cdn.com/flex017/user_avatar/community.opentargets.org/irene/32/50_2.png) [@irene](https://community.opentargets.org/u/irene)\
**Post date:** [23 August 2023 07:27 UTC](https://community.opentargets.org/t/how-to-modify-data-source-weights-in-the-api/1064/4 "2023-08-23T07:27:55Z")

</div>

Hi @cjb-apis and welcome to our Community!

1. Regarding the weights and association scores  
You are right in observing that amending the weights using the `datasources` parameter in your query directly impacts the overall association score. The purpose behind this design is that these weights are applied to each datasource when combining the associations by datasource. _Only when these are combined do we compute the associations by datatype or the overall associations_. Until that point, they aren’t considered, and hence the API doesn’t return weighted associations by datasource. As described in our documentation:

> “To calculate both data type and overall association scores, evidence is weighted using a factor that aims to calibrate the relevance of each data source relative to others.”

1. The propagate boolean  
The `propagate` boolean determines if the evidence from a given data source should be propagated using the ontology. You can learn more about it [here](https://platform-docs.opentargets.org/associations#ontological-selection-of-evidence). If you set `propagate` to `true`, it means you’re allowing this ontological propagation for that specific datasource in your query. To provide more context, the default values for all datasources with respect to the propagate boolean can be obtained using the following query:

```auto
query associatedTargets {
  disease(efoId: "EFO_0000349") {
    id
    name
    associatedTargets {
      datasources {
        id
        weight
        propagate
      }
    }
  }
}

```

By default, `propagate` is set to `True` for all data sources, except for Expression Atlas (RNA Expression), as mentioned in our documentation.

I hope you found this helpful! We understand the complexity of our API schema, we will work on documenting an accurate description of each endpoint. Let us know if you have further questions.

Best,  
Irene
