R/readPhenotypeTargets.R
readPhenotypeTargets.RdRead the phenotype table used by shared dnaEPICO workflows, validate the
sample identifier column, optionally subset the first nSamples, and return
the targets as a base data.frame.
readPhenotypeTargets(
phenoFile,
sepType = "",
nSamples = NA,
SampleID = "Sample_Name",
verbose = FALSE,
logs = FALSE,
log_dir = NULL,
log_file = "log_readPhenotypeTargets.txt"
)Character. Path to the phenotype table on disk.
Character. Field separator used in phenoFile. Use ""
(default) for a standard comma-separated file, "\\t" for a
tab-delimited file, or another single-character separator accepted by
utils::read.csv().
Integer or NA. Number of rows to keep from the start of the
phenotype table. The default NA reads and returns all rows.
Character. Name of the column containing sample identifiers that will later be used to name methylation-array samples.
Logical. If TRUE, emit progress and preview messages with
message(). The default is FALSE, so the function is quiet unless the
user explicitly requests messages.
Logical. If TRUE, write the same progress messages to a log
file. The default is FALSE.
Character or NULL. Directory where the log file should be
written when logs = TRUE. If NULL, the current working directory is
used.
Character. File name used when logs = TRUE. The default is
"log_readPhenotypeTargets.txt".
A data.frame containing the phenotype targets.
tmp <- tempdir()
pheno <- data.frame(
Sample_Name = c("S1", "S2"),
Sex = c("F", "M"),
stringsAsFactors = FALSE
)
pheno_file <- file.path(tmp, "pheno.csv")
utils::write.csv(pheno, pheno_file, row.names = FALSE)
targets <- readPhenotypeTargets(
phenoFile = pheno_file,
SampleID = "Sample_Name"
)
stopifnot(is.data.frame(targets))
stopifnot(nrow(targets) == 2L)