AnnotationProcessor

Description

AnnotationProcessor

AnnotationProcessor

Public fields

QC
is it a QC run
prefix
name for one factor designs
repeated
is it a repeated measurement
SAINT
is it a AP MS experiment, then use Bait_ as prefix
file_pattern
colnames for file
grouping_pattern
colnames grouping variable
subject_pattern
colnames for pairing variable
control_pattern
contrast specification columns
control_col_pattern
columns which contains C or T.
sample_name_pattern
sample name column
sample_name_suffix_length
maximum suffix length for display sample names
sample_name_display_column
preferred derived display sample-name column
shorten_sample_names
derive short display names for long sample names
norm_value_pattern
normalization value column (e.g., Creatinine)
strict
should name check be strict

Methods

Public 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
QC
default FALSE
prefix
default "G_"
repeated
default TRUE
SAINT
default FALSE
shorten_sample_names
derive short display sample names from long names
sample_name_suffix_length
suffix length used for derived sample names
sample_name_display_column
preferred derived display sample-name column

Method check_annotation()

check annotation

Usage
AnnotationProcessor\$check_annotation(annot)
Arguments
annot
annotation

Method read_annotation()

read annotation

Usage
AnnotationProcessor\$read_annotation(dsf)
Arguments
dsf
either dataframe or file path.

Method extract_contrasts()

check annotation

Usage
AnnotationProcessor\$extract_contrasts(annot, group)
Arguments
annot
annotation
group
group column e.g. group

Method add_contrasts_vec()

add vector of contrasts to annot table

Usage
AnnotationProcessor\$add_contrasts_vec(annot, Contrasts)
Arguments
annot
annotation
Contrasts
vector with contrasts

Method clone()

The objects of this class are cloneable with this method.

Usage
AnnotationProcessor\$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.

Examples

library("prolfquapp")


# 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)
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 :")
aa <- ap$read_annotation(annot)
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")
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)
aa <- ap$read_annotation(af)

stopifnot(aa$atable$factor_keys() == "G_")
stopifnot(aa$atable$factors == "group")
aa <- ap$read_annotation(annot)
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)
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)