phenopackets / phenopacket-schema

Repository for the GA4GH phenopacket schema
https://phenopacket-schema.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
78 stars 30 forks source link

Should ReferenceRange include a unit? #289

Closed julesjacobsen closed 3 years ago

julesjacobsen commented 3 years ago

Whist going through the docs I noticed that we needed an example of a Quantity with a ReferenceRange

message Quantity {
    // For instance, NCIT subhierarchy, Unit of Measure (Code C25709), https://www.ebi.ac.uk/ols/ontologies/uo
    OntologyClass unit_class = 1;

    // the  value of the quantity in the units  e.g. 2.0 mg
    double value = 2;

    // Reference range for the quantity
    // e.g. The normal range of platelets is 150,000 to 450,000 platelets/uL.
    ReferenceRange reference_range = 3;
}

message ReferenceRange {
    OntologyClass unit = 1;
    double low = 2;
    double high = 3;
}

Which is serialised to yaml like this

The following example shows a quantity for a platelet count per microliter, with a reference range.

.. code-block:: yaml

  unit:
    id: "UO:0000316"
    label: "cells per microliter"
  value: 300000.0
  referenceRange:
    unit:
      id: "UO:0000316"
      label: "cells per microliter"
    low: 150000.0
    high: 450000.0

From this it is clear that the unit is duplicated needlessly and it could be expressed like this:

unit:
    id: "UO:0000316"
    label: "cells per microliter"
  value: 300000.0
  referenceRange:
    low: 150000.0
    high: 450000.0

This would mean making the ReferenceRange an inner class of Value so that it is no longer a completely independent entity or could simply become a Range (no unit).

pnrobinson commented 3 years ago

Seems that this kind of simplification makes sense and would make things easier to follow.

julesjacobsen commented 3 years ago

Decided to leave things as-is