Load the merged longitudinal phenotype-plus-beta object, ensure that a subject identifier column is available, validate the requested modeling variables, convert selected variables to factors, and return a single in-memory object for downstream mixed-effects modeling helpers.

prepareMethylationGLMM_T1T2Data(
  inputPheno,
  personVar = "person",
  timeVar = "Timepoint",
  phenotypes,
  covariates,
  factorVars,
  prsMap = NULL,
  cpgPrefix = "cg",
  cpgLimit = NA,
  interactionTerm = NULL,
  verbose = FALSE,
  logs = FALSE,
  log_dir = NULL,
  log_file = "log_methylationGLMM_T1T2.txt"
)

Arguments

inputPheno

Character. Path to the merged longitudinal phenotype-plus- beta object created by preprocessingPheno().

personVar

Character. Name of the subject identifier column.

timeVar

Character. Name of the time variable.

phenotypes

Character vector or comma-separated string of phenotype variables to model.

covariates

Character vector or comma-separated string of covariate variables to adjust for.

factorVars

Character vector or comma-separated string of variables that should be converted to factors before modeling.

prsMap

Character vector or comma-separated string of phenotype-to-PRS mappings in the form "Phenotype:PRS".

cpgPrefix

Character. Prefix used to identify methylation columns.

cpgLimit

Integer or NA. Maximum number of CpGs to retain. NA keeps all matching CpGs.

interactionTerm

Character or NULL. Optional interaction term.

verbose

Logical. If TRUE, emit progress messages with message().

logs

Logical. If TRUE, write the same messages to a log file.

log_dir

Character or NULL. Directory used for the log file when logs = TRUE.

log_file

Character. File name used when logs = TRUE.

Value

A list with class "dnaEPICO_methylationGLMM_T1T2_data" containing the prepared analysis data, parsed variable selections, CpG columns, timepoint summaries, and subject-ID diagnostics.

Examples

ex <- dnaEPICO:::exampleMethylationGLMMStateDnaEpico()
prepared_data <- prepareMethylationGLMM_T1T2Data(
  inputPheno = ex$inputPath,
  personVar = "person",
  timeVar = "Timepoint",
  phenotypes = "score",
  covariates = "sex",
  factorVars = "sex,Timepoint",
  cpgLimit = 2,
  verbose = FALSE,
  logs = FALSE
)
names(prepared_data)
#>  [1] "data"                     "personVar"               
#>  [3] "timeVar"                  "phenotypes"              
#>  [5] "covariates"               "factorVars"              
#>  [7] "prsMap"                   "cpgColumns"              
#>  [9] "cpgPrefix"                "cpgLimit"                
#> [11] "interactionTerm"          "requestedInteractionTerm"
#> [13] "personCreated"            "personCounts"            
#> [15] "personMappingPreview"     "timepointSummary"