Phenomics, repeated records and decision-time alignment

Practical 28: Genomics, systems biology and multi-omics

Learning objectives

Define a time-window phenotype; calculate animal-level summaries and coverage; avoid future-information leakage and pseudoreplication.

Biological question and data

How should repeated sensor records be summarized for a molecular sample collected on day 3?

Sensor values are fictional measurements in arbitrary units. Six animals have five daily records. One value is missing by construction. Diet or treatment allocation is animal-level, so daily rows are not independent treatment replicates.

No biological download is required. Numerical inputs are hypothetical, not observed animal data. The runnable examples use base R. Count and abundance units are specified where used.

1. Create and inspect the repeated data

Keep animal and day as separate keys; define a missing value rather than silently replacing it.

Show R code
set.seed(2801)
records <- data.frame(animal=rep(paste0("a",1:6),each=5),day=rep(1:5,6))
records$value <- rep(seq(8,13),each=5)+.2*records$day+rnorm(30,sd=.3)
records$value[2] <- NA_real_
stopifnot(!anyDuplicated(records[c("animal","day")]))
head(records,10)
   animal day     value
1      a1   1  8.115756
2      a1   2        NA
3      a1   3  8.672927
4      a1   4  8.890654
5      a1   5  8.791706
6      a2   1  8.998369
7      a2   2  9.611914
8      a2   3  9.961972
9      a2   4 10.397363
10     a2   5 10.092766

The second record of animal a1 is unobserved. Its baseline summary therefore uses fewer recorded times.

2. Define pre-sampling and future windows

Use days1–3 as information available at day3 and days4–5 as a future response. Report coverage.

Show R code
baseline <- subset(records,day<=3)
future <- subset(records,day>3)
mean_recorded <- aggregate(value~animal,baseline,mean)
coverage <- aggregate(observed~animal,transform(baseline,observed=!is.na(value)),sum)
future_mean <- aggregate(value~animal,future,mean)
summary <- merge(merge(mean_recorded,coverage,by="animal"),future_mean,by="animal",
 suffixes=c("_baseline","_future"))
summary
  animal value_baseline observed value_future
1     a1       8.394342        2      8.84118
2     a2       9.524085        3     10.24506
3     a3      10.661245        3     10.90361
4     a4      11.256687        3     12.22160
5     a5      12.519463        3     13.06386
6     a6      13.221000        3     13.89132
Show R code
stopifnot(nrow(summary)==6,summary$observed[summary$animal=="a1"]==2)

The mean summarizes observed times, not necessarily the full target interval. Coverage policies should be specified before comparing animals.

3. Check the eligible prediction information

A day3 predictor can use baseline records, while future measurements belong to evaluation outcomes.

Show R code
eligible_predictor <- records$day<=3
c(sensor_rows=nrow(records),independent_animals=length(unique(records$animal)),
 eligible_predictor_rows=sum(eligible_predictor))
            sensor_rows     independent_animals eligible_predictor_rows 
                     30                       6                      18 
Show R code
stopifnot(max(records$day[eligible_predictor])==3)

Counting thirty rows as thirty independently allocated animals would overstate replication.

4. Compare observed and target-window means

Missing high-value days can shift a recorded mean. Use a small constructed time window to expose the issue.

Show R code
period <- c(8,9,12,13,8)
recorded <- period;recorded[c(3,4)] <- NA
c(full_window_mean=mean(period),observed_mean=mean(recorded,na.rm=TRUE),
 fraction_observed=mean(!is.na(recorded)))
 full_window_mean     observed_mean fraction_observed 
        10.000000          8.333333          0.600000 

5. Include result availability in the timeline

Collection date and result availability are different. A baseline specimen processed after the decision cannot supply a real-time feature for that decision. Record assay turnaround as well as sensor windows.

Repeated measurements can improve an animal summary while retaining animal-level dependence. For irregular intervals, a simple arithmetic mean may weight densely sampled periods more heavily. Document the summary and coverage policy and examine whether missingness depends on illness or device behavior. Future-window observations belong to the outcome or a different task, not a retrospective predictor at an earlier time.

Interpretation challenge

Could a day-20 sample with a day-40 result be used for a day-30 management prediction?

Only if that information would actually be available by day 30. Collection before the decision alone is insufficient; redefine the task or use eligible information.

Interpretation and limits

Actual sensor pipelines need calibration, physical units, time zones/time stamps, unequal observation windows, serial dependence and missingness investigation. Repeated records may need mixed or longitudinal models; this practical illustrates grouping and timing rather than fitting such a model.

Exercises

  1. Why report coverage with the mean?
  2. Can future records be included to improve a day3 prediction?
  3. What changes when animals share a pen-level intervention?
  1. Animals with different observation windows may have non-comparable summaries.
  2. Not if they were unavailable at day3; that would change the prediction task or leak information.
  3. The intervention unit is the pen, requiring pen-level replication/dependence handling.

Continue learning

B11 Phenomics and B02 Design.

Continue with prediction or study proposal. Return to the practical index or the unified map.