MakeColdata {grandR} | R Documentation |
Extract an annotation table from a formatted names vector
Description
If columns (i.e. sample or cell) follow a specific naming pattern, this can be used to conveniently set up an annotation table.
Usage
MakeColdata(
names,
design,
semantics = DesignSemantics(),
rownames = TRUE,
keep.originals = TRUE
)
Arguments
names |
Formatted names vector (see details) |
design |
Titles for the columns of the annotation table |
semantics |
Additional semantics to apply to given annotations (see details) |
rownames |
Add rownames to the annotation table |
keep.originals |
To not discard the original values for all annotations where semantics were applied |
Details
The names have to contain dots (.) to separate the fields for the column annotation table.
E.g. the name Mock.4h.A will be split into the fields Mock, 4h and A.
For such names, a design vector of length 3 has to be given, that describes the meaning of each field.
A reasonable design vector for the example would be c("Treatment","Time","Replicate")
.
Some names are predefined in the list Design.
The names given in the design vector might even have additional semantics: E.g. for the name duration.4sU the values are interpreted (e.g. 4h is converted into the number 4, or 30min into 0.5, or no4sU into 0).
Semantics can be user-defined via the semantics list: For each name in the design vector matching to a name in this list, the corresponding function in the list is run. Functions must accept 2 parameters, the first is the original column in the annotation table, the second the original name. The function must return a data.frame with the number of rows matching to the annotation table. In most cases it is easier to manipulate the returned data frame instead of changing the semantics. However, the build-in semantics provide a convenient way to reduce this kind of manipulation in most cases.
Value
A data frame representing the annotation table
See Also
ReadGRAND,DesignSemantics,Coldata
Examples
coldata <- MakeColdata(c("Mock.0h.A","Mock.0h.B","Mock.2h.A","Mock.2h.B"),
design=c("Cell",Design$dur.4sU,Design$Replicate))