Tutorials › Pharmacometric Workflows and Reproducible Modeling › Multiple Analytes and Endpoints

Data Specification and Dataset Preparation · Tutorial 12 of 399

Multiple Analytes and Endpoints

Build and check observation records for multiple analytes or endpoints without confusing their values, units, or assay metadata.

Intermediate 9 min read

What You'll Learn

  • Distinguish analytes from response endpoints and define explicit measurement identifiers.
  • Specify a record grain and key that distinguish measurements made at the same time.
  • Match each recorded value and unit to its measurement definition.
  • Organize assay metadata so it can be checked against the correct measurement.
  • Compare long and wide layouts and diagnose mismatches before modeling.

Why Measurement Identity Matters

A subject can provide more than one kind of observation at the same visit. A plasma sample might yield concentrations of two drug analytes, while the same visit includes a laboratory endpoint such as alanine aminotransferase (ALT). These are not interchangeable measurements: each has its own meaning, units, expected range, and possibly assay method or quantification limits. If a record says only “value = 12,” its intended interpretation is unclear.

The earlier material on record grain and longitudinal record keys establishes that a row must represent a clearly specified observation and that its identifying fields must distinguish records. With multiple measurements, subject and time alone may not distinguish two observations at the same time. The dataset therefore needs an explicit measurement identifier, and its definition must connect that identifier to the value’s meaning and relevant metadata.

Definition: A measurement identifier is a controlled, explicit code that identifies what an observation represents, such as a particular analyte concentration or response endpoint. A measurement definition specifies the identifier’s meaning and applicable properties, including the expected value type, unit, and assay information. An observation record is valid only when its value and associated fields agree with that definition.

An analyte is the substance being measured, such as a parent drug or metabolite. An endpoint is the response or outcome being recorded, such as a laboratory result, symptom score, or physiological measurement. An analyte concentration can itself be a response variable in a model, but naming the analyte and endpoint separately in the data specification helps prevent ambiguity. For example, “drug concentration” is less precise than “parent-drug concentration in plasma.”

Specify the Identifier and Record Grain

Choose identifiers from a documented, controlled set rather than relying on spelling variations or row position. Codes such as PARENT_PLASMA, METABOLITE_PLASMA, and ALT are interpretable when the data specification defines them. The code should be stable across records, and its definition should state the sample matrix or endpoint context when that changes the meaning.

For a dataset with one observation per subject, observation time, and measurement, the key must include all three elements. The measurement identifier is essential because two different measurements can occur for one subject at one time.

$$ \text{observation key} = (\text{subject identifier},\ \text{observation time},\ \text{measurement identifier}) $$

This key is appropriate only if the design has at most one record for each such combination. If multiple specimens or replicates are intentionally recorded at the same time for the same measurement, the key must also include a field that distinguishes those records, such as a specimen or replicate identifier. Do not remove valid observations merely to make a key unique; first determine whether the stated record grain omitted a meaningful dimension.

The measurement identifier is not a replacement for the observed value. It describes what the value means; the value field contains the observed result. Likewise, a unit label is not a substitute for an identifier: “mg/L” alone does not distinguish which analyte or endpoint was measured.

Worked Example: Distinguishing Measurements at One Visit

Suppose a hypothetical subject has these records at 2 hours: parent-drug concentration of 1.8 mg/L, metabolite concentration of 0.42 mg/L, and ALT of 28 U/L. Determine whether subject and time alone identify the records, then specify a suitable key.

Check the proposed fields. All three records have the same subject and observation time. Therefore, the pair (subject, time) occurs three times and cannot uniquely identify an observation.

Add a measurement identifier. Use PARENT_PLASMA for the parent-drug concentration, METABOLITE_PLASMA for the metabolite concentration, and ALT for the laboratory endpoint. The resulting key values are (subject, 2 hours, PARENT_PLASMA), (subject, 2 hours, METABOLITE_PLASMA), and (subject, 2 hours, ALT). These are distinct.

Check the values and units. The first two values are concentrations in mg/L, while the third is an enzyme activity result in U/L. The units are not interchangeable, and the identifier makes clear which definition applies to each value.

Match Values, Units, and Assay Metadata

A measurement definition should be detailed enough to test whether each row is coherent. Depending on the measurement, it may specify analyte or endpoint name, matrix, unit, assay method or version, and assay-specific limits or flags. Not every field applies to every endpoint: a concentration assay and a questionnaire score do not necessarily share the same metadata. The specification should say which metadata are required, which are optional, and what each field means.

Metadata can be recorded on each observation or stored once in a measurement-definition table linked by the measurement identifier. A separate table avoids repeating fixed definitions and can reduce contradictory entries, but it is safe only when the link is complete and unambiguous. If method or matrix varies between observations, store that variation at the appropriate record level or include it in a more specific measurement definition. Never infer assay identity from the value alone.

Units must agree with the value and the defined measurement. The earlier material on unit harmonization covers conversion; here, the key validation question is whether the unit recorded for a row is permitted for its identifier. If values are converted to a common unit, record the conversion consistently and retain enough provenance to establish which source measurement and assay produced the value.

Worked Example: Detecting a Unit-Measurement Mismatch

Consider this hypothetical measurement specification: PARENT_PLASMA is a parent-drug concentration reported in mg/L; METABOLITE_PLASMA is a metabolite concentration also reported in mg/L; ALT is an enzyme endpoint reported in U/L. A record has identifier ALT, value 1.6, and unit mg/L. Decide whether it passes validation.

Compare the identifier with its definition. ALT is defined as an enzyme endpoint whose unit is U/L. The recorded unit is mg/L, a concentration unit. Thus the row fails the identifier-unit check, even though the numerical value 1.6 is a valid number.

Do not repair it by guessing. Changing the identifier to PARENT_PLASMA would make mg/L a permitted unit, but that would be justified only if the source record confirms that the value is a parent-drug concentration. Changing the unit to U/L would likewise be unjustified without source confirmation. The record should be flagged for review against the laboratory result and data provenance.

Validation rule. For every record \(i\), check that its unit is among those allowed for its measurement identifier \(m_i\). For this record, \(m_i=\text{ALT}\) and \(u_i=\text{mg/L}\), while the allowed unit for ALT is U/L; therefore, the check fails.

A value’s numeric form can also be inconsistent with its measurement definition. For example, a score endpoint may be restricted to integers from 0 through 10, while a concentration is generally represented as a nonnegative quantitative value. Such checks should be defined only when justified by the endpoint or assay specification; a broad “plausible range” invented without domain support may incorrectly reject valid observations. Assay metadata should be checked the same way: a method code must be valid for the measurement, and any assay-specific limits must refer to the assay that actually generated the result.

Why the Key Must Include the Measurement

The need to include measurement identity in the key follows directly from the record definition. Suppose records are intended to represent one subject, one observation time, and one measurement. If two different measurements share a subject and time, removing the measurement identifier maps both records to the same pair. That mapping is not one-to-one, so the pair cannot uniquely identify records. Adding the identifier distinguishes the observations, provided there are no additional replicates at that grain.

$$ (\text{subject},\text{time})_1 = (\text{subject},\text{time})_2 \quad\text{but}\quad \text{measurement}_1 \ne \text{measurement}_2 \ \Longrightarrow\ (\text{subject},\text{time},\text{measurement})_1 \ne (\text{subject},\text{time},\text{measurement})_2 $$

This is a structural justification, not a statistical assumption. It depends on the stated record grain. If a measurement is repeated from separate specimens, the two records can still share all three fields in the displayed key; that pattern is evidence that the key or record-grain definition needs another distinguishing field, not necessarily evidence of a duplicate error.

Worked Example: Checking a Small Long-Format Dataset

A hypothetical specification defines PARENT_PLASMA and METABOLITE_PLASMA as measurements in mg/L, and ALT as a measurement in U/L. Each row should represent one subject, time, and measurement, with one record per key. Check the following records.

SubjectTime (h)Measurement IDValueUnit
S012PARENT_PLASMA1.8mg/L
S012METABOLITE_PLASMA0.42mg/L
S012ALT28U/L
S012ALT31U/L

Check measurement-unit agreement. The first row has PARENT_PLASMA with mg/L, which is permitted. The second has METABOLITE_PLASMA with mg/L, also permitted. The two ALT rows have U/L, as specified. No row fails this unit check.

Check key uniqueness. The last two records both have the key (S01, 2, ALT). This violates the stated one-record-per-key rule. The duplicate cannot be resolved by choosing one value arbitrarily. Investigate the source to determine whether the rows are accidental duplicates or represent distinct specimens or replicates. If they are distinct intended observations, revise the record grain and include the field that distinguishes them.

Conclusion. The first three records pass both checks. The fourth record’s measurement and unit are coherent, but the two ALT records together fail the uniqueness check. A dataset can therefore contain individually plausible values and still have a structural inconsistency.

Long and Wide Layouts, Diagnostics, and Limits

In a long layout, each row contains one measurement and the measurement identifier states which one. This structure directly expresses a record grain such as subject, time, and measurement, and supports checks that apply to one measurement definition at a time. In a wide layout, separate columns hold different measurements, such as parent concentration, metabolite concentration, and ALT. A wide layout can be convenient for a fixed set of endpoints, but each column’s meaning is implicit in its name, and adding or changing measurements often requires changing the column structure.

Neither layout guarantees correct data. Long format requires explicit, valid measurement identifiers and a properly defined key. Wide format requires clear column definitions and consistent units and metadata for each measurement column. When analysis software requires one layout, derive it through a documented transformation rather than discarding the source identifiers or silently combining distinct measurements.

Useful diagnostics include counting records by measurement identifier, checking for identifiers absent from the definition table, testing each identifier against permitted units and metadata, and checking the declared key for duplicates. Also inspect values by identifier for unexpected patterns and review whether an assay method or matrix changes where the specification says it should be fixed. A sudden change in counts may reflect a real collection difference, but can also reveal misspelled codes that have split one measurement into multiple apparent categories.

These checks cannot establish that a laboratory result is biologically correct. They can find contradictions and missing definitions, but they do not replace source verification or scientific review. Nor does a valid measurement identifier make different analytes or endpoints suitable for pooling: that requires a separate scientific and modeling rationale. A stable code is a data organization tool, not evidence that two measurements have the same interpretation.

  • Do not encode identity only in row order. Sorting or filtering can change row positions; the measurement must remain explicit.
  • Do not reuse one identifier for different meanings. If matrix or endpoint definition changes the measurement’s interpretation, distinguish the definitions or record the variation explicitly.
  • Do not treat a plausible number as proof of a correct row. Validate the identifier, unit, and assay metadata together.
  • Do not delete repeated keys before investigation. A repeated key may expose an incomplete grain, not merely a duplicate.
Key takeaway: Define each analyte or endpoint with an explicit measurement identifier, make the identifier part of the observation key, and validate every value, unit, and applicable assay field against that identifier’s documented definition.

Check Your Understanding

Answer each question, then compare your reasoning with the solutions.

  1. A subject has parent-drug and metabolite concentrations at the same time. Why is subject plus time not a sufficient key, and what field should be added?
  2. A specification defines a biomarker concentration in ng/mL. A row has that measurement identifier, value 4.2, and unit U/L. What can be concluded, and what should not be guessed?
  3. Two records share subject, time, and measurement identifier, but refer to distinct specimens. What does this imply about the record grain or key?
  4. Give one advantage and one limitation of a long layout for multiple measurements.
  5. Why should a measurement identifier not be inferred from the numerical value?

Solutions. (1) Both observations share subject and time, so those fields do not distinguish them. Add an explicit measurement identifier, such as PARENT_PLASMA or METABOLITE_PLASMA, to the key. (2) The unit conflicts with the definition, so the row fails validation. Check the source; do not assume either the identifier or the unit is wrong and edit it without evidence. (3) The stated grain does not distinguish the intended records. If both specimens are valid observations, include a specimen identifier in the key; do not delete either merely to force uniqueness. (4) Long format makes the measurement identity explicit in each row and allows measurement-specific checks. It also depends on valid identifiers and definitions, so an invalid or inconsistent code can still cause errors. (5) Different measurements can have overlapping numerical values, and one measurement can produce a wide range of values. Meaning comes from the documented identifier and metadata, not the number alone.

Clinical Biostats