AnnDbObj-objects(AnnotationDbi)
AnnDbObj-objects()所属R语言包:AnnotationDbi
AnnDbObj objects
AnnDbObj对象
译者:生物统计家园网 机器人LoveR
描述----------Description----------
The AnnDbObj class is the most general container for storing any kind of SQLite-based annotation data.
AnnDbObj类是最普通的容器,用于存储任何一种基于SQLite的注释数据。
Details
详情----------Details----------
Many classes in AnnotationDbi inherit directly or indirectly from the AnnDbObj class. One important particular case is the AnnDbBimap class which is the lowest class in the AnnDbObj hierarchy to also inherit the Bimap interface.
许多类AnnotationDbi直接或间接继承从AnnDbObj类。一个重要的特殊情况,这是最低在AnnDbObj层次也继承bimap的接口类的AnnDbBimap类。
像存取,方法----------Accessor-like methods----------
In the code snippets below, x is an AnnDbObj object.
在下面的代码片段,x是AnnDbObj的对象。
dbconn(x): Return a connection object to the SQLite DB containing x's data.
dbconn(x):返回一个连接对象的SQLite数据库包含xs的数据。
dbfile(x): Return the path (character string) to the SQLite DB (file) containing x's data.
dbfile(x):SQLite数据库(文件)xs的数据传回的路径(字符串)。
dbmeta(x, name): Print the value of metadata whose name is 'name'. Also works if x is a DBIConnection object.
dbmeta(x, name):打印元数据的价值,他的名字是名。还可以,如果x是DBIConnection的对象。
dbschema(x, file="", show.indices=FALSE): Print the schema definition of the SQLite DB. Also works if x is a DBIConnection object.
dbschema(x, file="", show.indices=FALSE):打印SQLite数据库的架构定义。还可以,如果x是DBIConnection的对象。
The file argument must be a connection, or a character string naming the file to print to (see the file argument of the cat function for the details).
file参数必须是一个连接,或一个字符串命名的文件打印到(见filecat细节功能参数)。
The CREATE INDEX statements are not shown by default. Use show.indices=TRUE to get them.
CREATE INDEX语句默认情况下不显示。使用show.indices=TRUE让他们。
dbInfo(x): Prints other information about the SQLite DB. Also works if x is a DBIConnection object.
dbInfo(x):打印SQLite数据库有关的其他资料。还可以,如果x是DBIConnection的对象。
参见----------See Also----------
dbConnect, dbListTables, dbListFields, dbGetQuery, Bimap
dbConnect,dbListTables,dbListFields,dbGetQuery,bimap的
举例----------Examples----------
library("hgu95av2.db")
dbconn(hgu95av2ENTREZID) # same as hgu95av2_dbconn()[hgu95av2_dbconn(相同)]
dbfile(hgu95av2ENTREZID) # same as hgu95av2_dbfile()[一样hgu95av2_dbfile()]
dbmeta(hgu95av2_dbconn(), "ORGANISM")
dbmeta(hgu95av2_dbconn(), "DBSCHEMA")
dbmeta(hgu95av2_dbconn(), "DBSCHEMAVERSION")
library("DBI")
dbListTables(hgu95av2_dbconn()) #lists all tables on connection[列出所有表连接]
## If you use dbSendQuery instead of dbGetQuery[#如果你使用dbSendQuery代替dbGetQuery]
## (NOTE: for ease of use, this is defintitely NOT reccomended)[#(注:为便于使用,这是defintitely不reccomended)]
## Then you may need to know how to list results objects[#那么你可能需要知道如何列出结果对象]
dbListResults(hgu95av2_dbconn()) #for listing results objects[上市的结果对象]
## Sometimes you may want to see all the SQLite databases that are[#有时你可能希望看到所有的SQLite数据库]
## presently connected in your session. To do that you have to specify[#目前在你的会话连接。要做到这一点,你必须指定]
## the driver:[#驱动程序:]
library("RSQLite")
drvr <- dbDriver("SQLite") #gets the driver for SQLite[获得SQLite的驱动程序]
dbListConnections(drvr) #List all DB Connections using drvr[列出所有数据库连接使用DRVR]
dbListFields(hgu95av2_dbconn(), "probes")
dbListFields(hgu95av2_dbconn(), "genes")
dbschema(hgu95av2ENTREZID) # same as hgu95av2_dbschema()[作为hgu95av2_dbschema相同()]
## According to the schema, the probes._id column references the genes._id[#根据该模式,probes._id列引用genes._id的]
## column. Note that in all tables, the "_id" column is an internal id with[#列。请注意,在所有表,列“的_id”是一个内部ID]
## no biological meaning (provided for allowing efficient joins between[#没有生物学意义(容许高效之间的连接]
## tables).[#表)。]
## The information about the probe to gene mapping is in probes:[#有关的基因定位探针的信息是在探针:]
dbGetQuery(hgu95av2_dbconn(), "SELECT * FROM probes LIMIT 10")
## This mapping is in fact the ENTREZID map:[#此映射其实是ENTREZID图:]
toTable(hgu95av2ENTREZID)[1:10, ] # only relevant columns are retrieved[只有相关的检索列]
dbInfo(hgu95av2GO) # same as hgu95av2_dbInfo()[一样hgu95av2_dbInfo()]
##Advanced example:[#先进典型:]
##Sometimes you may wish to join data from across multiple databases at[#有时你可能想加入从跨多个数据库的数据]
##once:[#一次:]
## In the following example we will attach the GO database to the[#在下面的例子中,我们将附加GO数据库]
## hgu95av2 database, and then grab information from separate tables[#hgu95av2数据库,然后抢单独的表的信息]
## in each database that meet a common criteria.[#在每个数据库中,以满足一个共同的标准。]
library(hgu95av2.db)
library("GO.db")
attachSql <- paste('ATTACH "', GO_dbfile(), '" as go;', sep = "")
dbGetQuery(hgu95av2_dbconn(), attachSql)
sql <- 'SELECT DISTINCT a.go_id AS "hgu95av2.go_id",
a._id AS "hgu95av2._id",
g.go_id AS "GO.go_id", g._id AS "GO._id",
g.term, g.ontology, g.definition
FROM go_bp_all AS a, go.go_term AS g
WHERE a.go_id = g.go_id LIMIT 10;'
data <- dbGetQuery(hgu95av2_dbconn(), sql)
data
## For illustration purposes, the internal id "_id" and the "go_id"[#为便于说明,内部ID“的_id”和“go_id”]
## from both tables is included in the output. This makes it clear[#从两个表包含在输出。这清楚地]
## that the "go_ids" can be used to join these tables but the internal[#“go_ids”可以用来连接这些表,但内部]
## ids can NOT. The internal IDs (which are always shown as _id) are[#IDS不可能。内部ID(总是显示的_id)]
## suitable for joins within a single database, but cannot be used[#适合在一个单一的数据库连接,但不能使用]
## across databases.[#跨数据库。]
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|