AnnotatedDataFrame
class.
AnnotatedDataFrame
ScanAnnotationDataFrame(data, metadata)
: data
must be a data.frame containing the scan annotation.
It must contain at least the following column:
metadata
is an optional data.frame containing a description
for each column in data
. It should contain a column
"labelDescription", with row.names(metadata) == names(data)
. The ScanAnnotationDataFrame
constructor creates and returns
a ScanAnnotationDataFrame instance.
object
is a ScanAnnotationDataFrame
object. getScanID(object, index)
: A unique vector of scan
IDs. The optional index
is a logical or
integer vector specifying elements to extract.
getSex(object, index)
: A character vector of sex, with values 'M'
or 'F'. The optional index
is a logical or
integer vector specifying elements to extract.
hasSex(object)
: Returns TRUE
if the column 'sex' is present in
object
.
getVariable(object, varname, index)
: A vector of the
column varname
. The optional index
is a logical or
integer vector specifying elements to extract.
If varname
is itself a vector, returns a data.frame.
Returns NULL
if
varname
is not found in object
.
hasVariable(object, varname)
: Returns TRUE
if
varname
is a column in object
, FALSE
if not.
getVariableNames(object)
: Returns a character vector with
the names of all columns in object
.
getAnnotation(object)
: Returns all annotation variables
as a data frame.
getMetadata(object)
: Returns metadata describing the
annotation variables as a data frame.
AnnotatedDataFrame
:
varLabels(object)
: Returns a character vector with
the names of all columns in object
.
pData(object)
: Returns all annotation variables
as a data frame, or sets the annotation variables with
pData(object) <- df
.
varMetadata(object)
: Returns metadata describing the
annotation variables as a data frame, or sets the metadata with
varMetadata(object) <- df
.
$
and [
work just as they do in
standard data frames, for both retrieval and assignment.
AnnotatedDataFrame
, SnpAnnotationDataFrame
,
GenotypeData
, IntensityData
library(GWASdata)
data(illumina_scan_annot)
scanAnnot <- ScanAnnotationDataFrame(illumina_scan_annot)
scanID <- getScanID(scanAnnot)
sex <- getSex(scanAnnot)
if (hasVariable(scanAnnot, "plate")) plate <- getVariable(scanAnnot, "plate")
subjectID <- getVariable(scanAnnot, "subjectID", index=(sex == "M"))
# list columns
varLabels(scanAnnot)
# add metadata
meta <- varMetadata(scanAnnot)
meta["scanID", "labelDescription"] <- "unique scan ID"
varMetadata(scanAnnot) <- meta
# display data
head(pData(scanAnnot))
# standard operators
scanID <- scanAnnot$scanID
sex <- scanAnnot[["sex"]]
subset <- scanAnnot[1:10, 1:5]
scanAnnot$newVar <- rep(1, nrow(scanAnnot))
# replace data
df <- pData(scanAnnot)
pData(scanAnnot) <- df
Run the code above in your browser using DataLab