EGA-archive / beacon2-ri-api

Beacon v2 Reference Implementation (API)
Apache License 2.0
16 stars 38 forks source link

Numerical filtering on the individuals endpoint #200

Open DavidCroftDKFZ opened 1 year ago

DavidCroftDKFZ commented 1 year ago

Hi,

I would like to apply a filter to find all individuals with a BMI greater than 25. However, my attempts so far always give me zero results, even though I know that there is at least one individual with a BMI greater than 25. Could you help?

Here is the endpoint I was using: POST http://localhost:5050/api/individuals

Here is what I sent in the body of my request:

{ "query": { "filters": [ { "id": "LOINC:35925-4", "operator": ">", "value": "25.0" } ], "includeResultsetResponses": "HIT", "testMode": false, "requestedGranularity": "count" } }

(I also tried id=NCIT:C49671, with the same results)

I looked at the RI BFF for individuals that was uploaded to Beacon, and found this:

  "measures" : [
     {
        "assayCode" : {
           "id" : "LOINC:35925-4",
           "label" : "BMI"
        },
        "date" : "2021-09-24",
        "measurementValue" : {
           "quantity" : {
              "unit" : {
                 "id" : "NCIT:C49671",
                 "label" : "Kilogram per Square Meter"
              },
              "value" : 26.63838307
           }
        }
     },

Regards,

David Croft.

costero-e commented 11 months ago

Hi David,

here is the POST I am using and it's getting me results:

curl \
  -H 'Content-Type: application/json' \
  -X POST \
  -d '{
    "meta": {
        "apiVersion": "2.0"
    },
    "query": {
        "filters": [{
        "id": "LOINC:35925-4",
        "operator": ">",
        "value": "25.0"
    }],
        "includeResultsetResponses": "HIT",
        "pagination": {
            "skip": 0,
            "limit": 10
        },
        "testMode": false,
        "requestedGranularity": "record"
    }
}' \
  http://localhost:5050/api/individuals

Maybe you can try this and tell me if you get some results. Checking your POST everything seems right but the difference between yours and mine is requestedGranularity: record instead of count maybe is what makes the difference.

Best,

Oriol

DavidCroftDKFZ commented 11 months ago

Hi Oriol,

I tried the body you proposed, with requestedGranularity set to record. I still got zero results. Do you have the BFF for individuals? If so, could you give me an example of how the measure for BMI should look? I would like to compare it with what I have, to see if the problem lies there.

Regards,

David.

P.S. Here is an example of what we have in the BFF:

     {
        "assayCode" : {
           "id" : "LOINC:35925-4",
           "label" : "BMI"
        },
        "date" : "2021-09-24",
        "measurementValue" : {
           "quantity" : {
              "unit" : {
                 "id" : "NCIT:C49671",
                 "label" : "Kilogram per Square Meter"
              },
              "value" : 26.63838307
           }
        }
     },

From: Oriol López-Doriga @.***> Sent: Monday, September 18, 2023 3:58 PM To: EGA-archive/beacon2-ri-api Cc: Croft, David; Author Subject: [Extern] - Re: [EGA-archive/beacon2-ri-api] Numerical filtering on the individuals endpoint (Issue #200)

Hi David,

here is the POST I am using and it's getting me results:

curl \ -H 'Content-Type: application/json' \ -X POST \ -d '{ "meta": { "apiVersion": "2.0" }, "query": { "filters": [{ "id": "LOINC:35925-4", "operator": ">", "value": "25.0" }], "includeResultsetResponses": "HIT", "pagination": { "skip": 0, "limit": 10 }, "testMode": false, "requestedGranularity": "record" } }' \ http://localhost:5050/api/individuals

Maybe you can try this and tell me if you get some results. Checking your POST everything seems right but the difference between yours and mine is requestedGranularity: record instead of count maybe is what makes the difference.

Best,

Oriol

— Reply to this email directly, view it on GitHubhttps://github.com/EGA-archive/beacon2-ri-api/issues/200#issuecomment-1723480054, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ALE7AZC2OOIGKIJCR5CDPX3X3BHPVANCNFSM6AAAAAA4OOCYC4. You are receiving this because you authored the thread.Message ID: @.***>

costero-e commented 11 months ago

Hi David,

at first sight, I don't see any differences between your BFF and mine.

Did you use RI to do the queries?

If so, please checkout to "develop" branch and try the query I sent you, it should work as expected.

Other possible solution is to see the logs of your beacon to see what it's throwing to the database but I can't help you more without this information.

Best,

Oriol

albodrug commented 3 months ago

Hello,

I cannot make use of the BMI filter either. I updated yesterday and used the cineca data. The filter on sex seems to work though...

bodrug-a ▶ pp-irs1-4071ylt ▶~/bin/beacon2-ri-api/deploy 
(itx)> curl   -H 'Content-Type: application/json'   -X POST   -d '{
    "meta": {
        "apiVersion": "2.0"
    },
    "query": {
        "filters": [{
        "id": "LOINC:35925-4",
        "operator": ">",
        "value": "25.0"
    }],
        "includeResultsetResponses": "HIT",
        "pagination": {
            "skip": 0,
            "limit": 10
        },
        "testMode": false,
        "requestedGranularity": "count"
    }
}'   http://localhost:5050/api/individuals
{"meta":{"beaconId":"itx.french.beacon","apiVersion":"v2.0.1","returnedGranularity":"count","receivedRequestSummary":{"apiVersion":"2.0","requestedSchemas":[],"filters":["LOINC:35925-4",">","25.0"],"requestParameters":{},"includeResultsetResponses":"HIT","pagination":{"skip":0,"limit":10},"requestedGranularity":"count","testMode":false},"returnedSchemas":[{"entityType":"individual","schema":"beacon-individual-v2.0.0"}]},"responseSummary":{"exists":true,"numTotalResults":2504},"beaconHandovers":[{"handoverType":{"id":"CUSTOM:000001","label":"Project description"},"note":"Project description","url":"https://www.nist.gov/programs-projects/genome-bottle"}]}
bodrug-a ▶ pp-irs1-4071ylt ▶~/bin/beacon2-ri-api/deploy 
(itx)> curl   -H 'Content-Type: application/json'   -X POST   -d '{
    "meta": {
        "apiVersion": "2.0"
    },
    "query": {
        "filters": [{
        "id": "LOINC:35925-4",
        "operator": ">",
        "value": "45.0"
    }],
        "includeResultsetResponses": "HIT",
        "pagination": {
            "skip": 0,
            "limit": 10
        },
        "testMode": false,
        "requestedGranularity": "count"
    }
}'   http://localhost:5050/api/individuals
{"meta":{"beaconId":"itx.french.beacon","apiVersion":"v2.0.1","returnedGranularity":"count","receivedRequestSummary":{"apiVersion":"2.0","requestedSchemas":[],"filters":["LOINC:35925-4",">","45.0"],"requestParameters":{},"includeResultsetResponses":"HIT","pagination":{"skip":0,"limit":10},"requestedGranularity":"count","testMode":false},"returnedSchemas":[{"entityType":"individual","schema":"beacon-individual-v2.0.0"}]},"responseSummary":{"exists":true,"numTotalResults":2504},"beaconHandovers":[{"handoverType":{"id":"CUSTOM:000001","label":"Project description"},"note":"Project description","url":"https://www.nist.gov/programs-projects/genome-bottle"}]}
bodrug-a ▶ pp-irs1-4071ylt ▶~/bin/beacon2-ri-api/deploy 
(itx)> curl   -H 'Content-Type: application/json'   -X POST   -d '{
    "meta": {
        "apiVersion": "2.0"
    },
    "query": {
        "filters": [{
        "id": "NCIT:C16576"
    }],                 
        "includeResultsetResponses": "HIT",
        "pagination": {
            "skip": 0,
            "limit": 10
        },             
        "testMode": false,
        "requestedGranularity": "count"
    }                                  
}'   http://localhost:5050/api/individuals
{"meta":{"beaconId":"itx.french.beacon","apiVersion":"v2.0.1","returnedGranularity":"count","receivedRequestSummary":{"apiVersion":"2.0","requestedSchemas":[],"filters":["NCIT:C16576"],"requestParameters":{},"includeResultsetResponses":"HIT","pagination":{"skip":0,"limit":10},"requestedGranularity":"count","testMode":false},"returnedSchemas":[{"entityType":"individual","schema":"beacon-individual-v2.0.0"}]},"responseSummary":{"exists":true,"numTotalResults":1271},"beaconHandovers":[{"handoverType":{"id":"CUSTOM:000001","label":"Project description"},"note":"Project description","url":"https://www.nist.gov/programs-projects/genome-bottle"}]}

Kind regards, Alex

costero-e commented 3 months ago

Hi @albodrug,

thanks for the comment. Recently, we changed the query by the ontology in the alphanumeric filters queries and we only allow to query for the specific label. We are doing it like this to not mix concepts of ontologies and alphanumeric terms. So, if you want to query for a measurement and its value, use the label for the assayCode, please. For example:

curl \
  -H 'Content-Type: application/json' \
  -X POST \
  -d '{
    "meta": {
        "apiVersion": "2.0"
    },
    "query": {
        "filters": [{
        "id": "BMI",
        "operator": ">",
        "value": "25"
    }],
        "includeResultsetResponses": "HIT",
        "pagination": {
            "skip": 0,
            "limit": 10
        },
        "testMode": false,
        "requestedGranularity": "record"
    }
}' \
  http://localhost:5050/api/individuals

Let me know if this solved your issue.

Thanks,

Oriol

albodrug commented 3 months ago

Thanks Oriol, query is working!