View source: R/electrophoresis.R
annotate.electrophoresis | R Documentation |
This function adds columns of annotations to the $samples
table of an electrophoresis
object. These new annotations can be used for subsetting, plot faceting, etc.
annotate.electrophoresis(
electrophoresis,
annotations,
header = TRUE,
row.names = NULL,
sep = "\t",
stringsAsFactors = TRUE,
...
)
electrophoresis |
An |
... |
Additional arguments passed to |
annotation |
Either a data frame or the path of a file that can be read by |
The input annotations can be a data frame or either a connection
or a character
containing the path of a file, which is then read into a data frame by read.table
. Therefore a file will probably need to be in CSV format or similar.
The first column of annotations
is used to identify samples in the matching column of electrophoresis$samples
, so it needs a matching column name, usually sample.name
or well.number
. But you can use any column that exists in the table, such as batch
or reagent.id
or even a column added by a previous call to this function. The elements of this first column are interpreted as class character
and cannot contain any duplicates. However, this column does not need to be in the same order as electrophoresis$samples
and not all identifiers in the sample table (e.g. sample names) need to appear in the annotation table, nor vice versa.
Each additional column of annotations
produces a new column of the same name in electrophoresis$samples
. If there is already a column of that name, it is overwritten. Samples that do not appear in the annotation table receive NA
for their new annotations. Samples with the same identifier (e.g. the same sample.name
because they are replicates) receive the same annotations.
If stringsAsFactors
is true then variables parsed as strings will be cast as factors, but the factor levels will be kept in the order they appear in the table, unlike the behavior of read.table
, which alphabetizes them. Thus the order in the annotation file determines the order of factor levels.
A new electrophoresis
object with additional columns added to its $samples
element.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.