ScanAnnotationSQLite | R Documentation |
The ScanAnnotationSQLite class stores annotation data associated with scans, as well as metadata describing each column, in an SQLite database.
ScanAnnotationSQLite(dbpath)
:
dbpath
is the path to a SQLite database with tables
"Annotation" and "Metadata." "Annotation" must contain at least the
following column:
"scanID": vector containing unique scan ids.
If a column representing sex is present, it must have the following format:
"sex": character vector with values 'M' or 'F'.
"Metadata" must contain at least the following columns:
"varname": name of variable in annotation
"description": description of column in annotation
If the database does not yet exist, a database is created with tables "Annotation" and "Metadata."
The ScanAnnotationSQLite
constructor creates and returns
a ScanAnnotationSQLite instance.
In the code snippets below, object
is a ScanAnnotationSQLite
object.
open(object)
: Opens a connection to the database.
close(object)
: Closes the database connection.
nscan(object)
: The number of scans in the database.
getScanID(object, index, condition)
: A unique vector of scan
IDs. The optional index
is a logical or
integer vector specifying elements to extract. The optional
condition
is a character string with an SQL clause used to
select data (e.g., "LIMIT 10", "WHERE sex='M'").
getSex(object, index, condition)
: A character vector of sex, with values 'M'
or 'F'. The optional index
is a logical or
integer vector specifying elements to extract. The optional
condition
is a character string with an SQL clause used to
select data.
hasSex(object)
: Returns TRUE
if the column 'sex' is present in
object
.
getVariable(object, varname, index, condition)
: A vector of the
column varname
. The optional index
is a logical or
integer vector specifying elements to extract. The optional
condition
is a character string with an SQL clause used to
select data (e.g., "LIMIT 10", "WHERE sex='M'").
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.
getQuery(object, statement)
: Returns result of the SQL
query statement
.
writeAnnotation(object, value, append=FALSE,
overwrite=TRUE)
: Writes value
to the scan annotation
table. value
must be a data.frame containing a column "scanID".
writeMetadata(object, value, append=FALSE,
overwrite=TRUE)
: Writes value
to the metadata table.
value
should be a data.frame containing
columns "varname" and "description".
Stephanie Gogarten
SnpAnnotationSQLite
,
ScanAnnotationDataFrame
,
GenotypeData
, IntensityData
library(GWASdata)
dbpath <- tempfile()
scanAnnot <- ScanAnnotationSQLite(dbpath)
data(illumina_scan_annot)
writeAnnotation(scanAnnot, illumina_scan_annot)
# list columns
vars <- getVariableNames(scanAnnot)
# add metadata
metadf <- data.frame(varname=vars, description=rep(NA, length(vars)),
row.names=vars, stringsAsFactors=FALSE)
metadf["scanID", "description"] <- "unique id"
writeMetadata(scanAnnot, metadf)
scanID <- getScanID(scanAnnot)
sex <- getSex(scanAnnot)
if (hasVariable(scanAnnot, "plate")) plate <- getVariable(scanAnnot, "plate")
subjectID <- getVariable(scanAnnot, "subjectID", condition="WHERE sex='M'")
# display data
head(getAnnotation(scanAnnot))
getMetadata(scanAnnot)
close(scanAnnot)
file.remove(dbpath)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.