plantbreeding / BrAPI

Repository for version control of the BrAPI specifications
https://brapi.org
MIT License
55 stars 32 forks source link

Add observation attributes #601

Open jframi opened 5 months ago

jframi commented 5 months ago

In the analytics discussion we have been discussing about how to handle summary statistics for a given variable in a study (e.g. heritability, CV, Wald p-value, etc.) One option would be to define an observation at the study level for the same variable having the study general mean as value. If we can define observation attributes, as a combination of a variableDbId (each statistic being defined as a variable) and a value, summary statistics could be handled this way.

daveneti commented 5 months ago

We have generalised 'attributes' in our BrAPI extensions. Now we can apply attrubutes to other enitites as well as Germplasm, for example InventoryLot (SeedLot) and ObservationUnit. Would you like me to share our extensions?

jframi commented 5 months ago

Below is an example of how this could be implemented

POST /observationunits

[
  {
    "locationDbId": "0e208b20",
    "locationName": "Field Station Alpha",
    "observationUnitName": "Purple_Tomato_1",
    "observationUnitPUI": "http://pui.per/plot/1a9afc14",
    "observationUnitPosition": {
      "entryType": "TEST",
      "geoCoordinates": {
        "geometry": {
          "coordinates": [
            -76.506042,
            42.417373,
            123
          ],
          "type": "Point"
        },
        "type": "Feature"
      },
      "observationLevel": {
        "levelCode": "study_1",
        "levelName": "study", <-- observation level is study
        "levelOrder": 0
      },
    },
    "programDbId": "2d763a7a",
    "programName": "The Perfect Breeding Program",
    "studyDbId": "9865addc",
    "studyName": "Purple_Tomato_1",
    "trialDbId": "776a609c",
    "trialName": "Purple Tomato"
  }
]

POST /observations

[
  {
    "collector": "917d3ae0",
    "observationTimeStamp": "2024-04-17T12:47:42.359Z",
    "observationUnitDbId": "598111d4",
    "observationUnitName": "Study name",
    "observationVariableDbId": "c403d107",
    "observationVariableName": "Plant Height in meters",
    "studyDbId": "ef2829db",
    "uploadedBy": "a2f7f60b",
    "value": "350", <-- this is the study average of plant height
    "observationAttributes": [
       {
        "observationAttributeAttributeDbId": "101290",
        "observationAttributeAttributeName": "Heritability", <-- Heritability as an observation attribute
        "value": "0.9"
      },
      {
        "observationAttributeAttributeDbId": "101291",
        "observationAttributeAttributeName": "CV", <-- Any other summary statistics as observation attributes
        "value": "13.2"
      }     
    ]
  }
]