library(GWASdata)
dbpath <- tempfile()
snpAnnot <- SnpAnnotationSQLite(dbpath)
data(illumina_snp_annot)
writeAnnotation(snpAnnot, illumina_snp_annot)
# list columns
vars <- getVariableNames(snpAnnot)
# add metadata
metadf <- data.frame(varname=vars, description=rep(NA, length(vars)),
row.names=vars, stringsAsFactors=FALSE)
metadf["snpID", "description"] <- "integer id"
writeMetadata(snpAnnot, metadf)
# get snpID and chromosome
snpID <- getSnpID(snpAnnot)
chrom <- getChromosome(snpAnnot)
# get positions only for chromosome 22
pos22 <- getPosition(snpAnnot, condition="WHERE chromosome = 22")
# get rsID
if (hasVariable(snpAnnot, "rsID")) rsID <- getVariable(snpAnnot, "rsID")
# display data
head(getAnnotation(snpAnnot))
getMetadata(snpAnnot)
close(snpAnnot)
file.remove(dbpath)
Run the code above in your browser using DataLab