AnnotationProcessor
AnnotationProcessor
Public fields
QCis it a QC run
prefixname for one factor designs
repeatedis it a repeated measurement
SAINTis it a AP MS experiment, then use Bait_ as prefix
file_patterncolnames for file
grouping_patterncolnames grouping variable
subject_patterncolnames for pairing variable
control_patterncontrast specification columns
control_col_patterncolumns which contains C or T.
sample_name_patternsample name column
sample_name_suffix_lengthmaximum suffix length for display sample names
sample_name_display_columnpreferred derived display sample-name column
shorten_sample_namesderive short display names for long sample names
norm_value_patternnormalization value column (e.g., Creatinine)
strictshould name check be strict
Methods
Method new()
initialize
Usage
AnnotationProcessor$new(
QC = FALSE,
prefix = "G_",
repeated = TRUE,
SAINT = FALSE,
shorten_sample_names = TRUE,
sample_name_suffix_length = 14L,
sample_name_display_column = "sampleName"
)Arguments
QCdefault FALSE
prefixdefault "G_"
repeateddefault TRUE
SAINTdefault FALSE
shorten_sample_namesderive short display sample names from long names
sample_name_suffix_lengthsuffix length used for derived sample names
sample_name_display_columnpreferred derived display sample-name column
Method read_annotation()
read annotation
Method extract_contrasts()
check annotation
Method add_contrasts_vec()
add vector of contrasts to annot table
Examples
# AnnotationProcessor$debug("read_annotation")
ap <- AnnotationProcessor$new(prefix = "G_")
annot <- data.frame(
file = c("a1.raw","a2.raw","a3.raw","a4.raw"),
group = c("a","a","b","b"),
CONTROL = c("C","C","T","T"),
Subject = c("X","Y","X","Y"))
ap$check_annotation(annot)
#> Warning: column starting with :^name is missing.
af <- annot
af$file <- NULL
testthat::expect_error(ap$check_annotation(af), "column starting with :")
af <- annot
af$group <- NULL
testthat::expect_error(ap$check_annotation(af),"column starting with :")
#> Warning: column starting with :^name is missing.
aa <- ap$read_annotation(annot)
#> Warning: column starting with :^name is missing.
#> INFO [2026-06-23 20:42:34] levels: c("a", "b") c("C", "T")
#> b a
stopifnot(length(aa$atable$factor_keys_depth()) == 2)
stopifnot(all(c("atable", "annot", "contrasts") %in% names(aa)))
stopifnot(aa$contrasts == "G_b - G_a")
af <- annot
af$CONTROL <- NULL
testthat::expect_error(ap$check_annotation(af),"you must specify a CONTROL column")
#> Warning: column starting with :^name is missing.
af <- annot
af$Subject <- NULL
testthat::expect_warning(ap$check_annotation(af),"column starting with")
# should not throw exception since QC does not require group or subject
ap <- AnnotationProcessor$new(QC = TRUE)
af <- annot
# af$group <- NULL
af$CONTROL <- NULL
af$Subject <- NULL
ap$check_annotation(af)
#> Warning: column starting with :^name is missing.
aa <- ap$read_annotation(af)
#> Warning: column starting with :^name is missing.
stopifnot(aa$atable$factor_keys() == "G_")
stopifnot(aa$atable$factors == "group")
aa <- ap$read_annotation(annot)
#> Warning: column starting with :^name is missing.
aa$atable$file_name
#> [1] "file"
aa$atable$sample_name
#> [1] "sampleName"
as <- annot
as$sample <- c("s1","s2","s3","s4")
aa <- ap$read_annotation(annot)
#> Warning: column starting with :^name is missing.
aa$atable$sample_name
#> [1] "sampleName"
stopifnot(is.null(aa$annotation))
annot <- data.frame(
file = c("a1.raw","a2.raw","a3.raw","a4.raw"),
Name = c("a1.raw","a2.raw","a3.raw","a4.raw"),
"Grouping Var" = c("a","a","b","b"),
CONTROL = c("C","C","T","T"),
Subject = c("X","Y","X","Y"))
ax <- ap$read_annotation(annot)