Last data update: 2014.03.03

R: Class '"BuxcoDB"'
BuxcoDB-classR Documentation

Class "BuxcoDB"

Description

This is the main class of the plethy package. Each object of this class simply holds the name of the database as well as the name(s) of any additional tables added through addAnnotation.

Objects from the Class

Objects should be created by calls of the form makeBuxcoDb(db.name=NULL, annotation.table="Additional_labels").

Slots

db.name:

Object of class "character" Stores the path to the database.

annotation.table:

Object of class "character" Stores the name of the additional annotation table in the database to be created if addAnnotation is called.

Methods

addAnnotation

signature(obj = "BuxcoDB"): Carry out an additional query to populate columns in a new or existing table. Each query should be specified by a function taking a BuxcoDB object as an argument and returning valid SQL. Additionally if the index argument is set to TRUE, indexes will be placed on the columns in the table. See the vignette for an example of how this function should be used in practice.

annoTable

signature(obj = "BuxcoDB"): Retrieve the name of the table where the additional annotation is to be stored. This table will not exist until the addAnnotation method is called first.

annoCols

signature(obj = "BuxcoDB"): Returns a vector of the column names in the additional annotation table.

annoLevels

signature(obj = "BuxcoDB"): Returns a list of the same length as the number of annotation columns in the additional annotation table with each element containing the unique values for each column.

dbName

signature(obj = "BuxcoDB"): Retrieve the path to the plethy database

retrieveData

signature(obj = "BuxcoDB"): With no arguments, this method will retrieve all available data in the database as a data.frame. Specifying single or a vector of values to one or more of samples, variables, tables, phase or one of the addtional annotation names specified using addAnnotation will retrieve a subset of Buxco data. Note that the valid variable (column) names for the annotation table can be found through the annoCols method and the valid variables for each variable name can be found through annoLevels.

retrieveMatrix

signature{obj = "BuxcoDB"}: This method first uses 'retrieveData' to retrieve the specified subset of data and then summarizes it into a matrix or array by first applying the specified 'summary.func'. The default form of the array is Samples x Timepoint x Variable though this can be changed by supplying a different formula.

samples

signature(obj = "BuxcoDB"): Returns a vector of the unique samples in the database

tables

signature(obj = "BuxcoDB"): Returns a vector of the unique tables in the database

variables

signature(obj = "BuxcoDB"): Returns a vector of the unique Buxco measurement variables in the database

tsplot

signature(obj = "BuxcoDB"): Produces a line plot of the subset of the subset of the data as specified in 'retrieveData' after summarizing each sample for each timepoint by the function specified in 'summary.func'. Colors and a legend can be added for a single experimental variable specified in 'exp.factor'. The x,y and legend labels can be modified using the 'xlab', 'ylab' and 'legend.name' arguments respecitively.

mvtsplot

signature(obj = "BuxcoDB"): Produces a multivariate timeseries plot adapted from the function in the 'mvtsplot' CRAN package. By default it will produce a plot containing a heatmap like image for each sample centered and scaled by row along with a boxplot depicting the overall distribution of the variable specified in 'plot.value'. At the bottom of the plot, a line plot shows the median trend over time. The data can also optionally be grouped as either an 'inner.group' or an 'outer.group'. The 'inner.group.name' defaults at the sample name though it can be used to specify a group in its own right. The 'outer.group.name' subdivides the plot visualy and the medians are computed over each group seperately. Colors of the 'outer.group' can be changed by supplying a color vector to 'outer.col' named by the levels of 'outer.group.name'. The colors used in the heatmap image can be influenced by supplying a different palette from RColorBrewer to 'colorbrewer.pal'. Note that the data is first summarized by sample and day using the function supplied to 'summary.func'.

summaryMeasures

signature(obj = "BuxcoDB"), summary.type=c("time.to.max.response", "max.response", "auc.response", "mean.response"), sample.summary.func=function(x) data.frame(Value=mean(x$Value)), samples=NULL, variables=NULL, tables=NULL, Break_type_label="EXP", day.summary.column="Days": Returns a data.frame containing a summaries of the variables for each sample with respect to the main time element specified in 'day.summary.column' after first summarizing each variable and timepoint for each sample by 'sample.summary.func'. The data can be subsetted ahead of time using the samples, variables, tables and Break_type_label arguments. Note this assumes that break.type.query was previously run using addAnnotation.

Author(s)

Daniel Bottomly

See Also

parse.buxco

Examples


samp.file <- sample.db.path()
new.file <- file.path(tempdir(), basename(samp.file))

stopifnot(file.copy(samp.file, new.file, overwrite=TRUE))

bux.db <- makeBuxcoDB(new.file)

show(bux.db)

head(retrieveData(bux.db))

annoCols(bux.db)

annoLevels(bux.db)

dbName(bux.db)

samples(bux.db)

tables(bux.db)

variables(bux.db)

addAnnotation(bux.db, query=day.infer.query, index=FALSE)

annoCols(bux.db)
annoLevels(bux.db)

addAnnotation(bux.db, query=break.type.query, index=TRUE)

annoCols(bux.db)
annoLevels(bux.db)

head(retrieveData(bux.db))

retrieveMatrix(bux.db)[1:5,1,1:5]

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(plethy)
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: 'BiocGenerics'

The following objects are masked from 'package:parallel':

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked from 'package:stats':

    IQR, mad, xtabs

The following objects are masked from 'package:base':

    Filter, Find, Map, Position, Reduce, anyDuplicated, append,
    as.data.frame, cbind, colnames, do.call, duplicated, eval, evalq,
    get, grep, grepl, intersect, is.unsorted, lapply, lengths, mapply,
    match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, rank,
    rbind, rownames, sapply, setdiff, sort, table, tapply, union,
    unique, unsplit

Loading required package: S4Vectors
Loading required package: stats4

Attaching package: 'S4Vectors'

The following objects are masked from 'package:base':

    colMeans, colSums, expand.grid, rowMeans, rowSums

> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/plethy/BuxcoDB.Rd_%03d_medium.png", width=480, height=480)
> ### Name: BuxcoDB-class
> ### Title: Class '"BuxcoDB"'
> ### Aliases: BuxcoDB-class BuxcoDB addAnnotation,BuxcoDB-method
> ###   addAnnotation annoTable,BuxcoDB-method annoTable
> ###   annoCols,BuxcoDB-method annoCols annoLevels,BuxcoDB-method annoLevels
> ###   dbName,BuxcoDB-method dbName retrieveData,BuxcoDB-method retrieveData
> ###   samples,BuxcoDB-method samples tables,BuxcoDB-method tables
> ###   variables,BuxcoDB-method variables makeBuxcoDB summaryMeasures
> ###   summaryMeasures,BuxcoDB-method retrieveMatrix,BuxcoDB-method
> ###   retrieveMatrix tsplot tsplot,BuxcoDB-method mvtsplot
> ###   mvtsplot,BuxcoDB-method
> ### Keywords: classes
> 
> ### ** Examples
> 
> 
> samp.file <- sample.db.path()
> new.file <- file.path(tempdir(), basename(samp.file))
> 
> stopifnot(file.copy(samp.file, new.file, overwrite=TRUE))
> 
> bux.db <- makeBuxcoDB(new.file)
> 
> show(bux.db)
BuxcoDB object
Database: /tmp/Rtmp9qbGYe/BuxcoR_sample.db 
Annotation Table: Additional_labels 
No metadata is available
> 
> head(retrieveData(bux.db))
   Sample_Name              P_Time Break_sec_start Variable_Name Bux_table_Name
1 8034x13140_5 2012-09-28 10:07:17               0             f          WBPth
2 8034x13140_5 2012-09-28 10:07:17               0           TVb          WBPth
3 8034x13140_5 2012-09-28 10:07:17               0           MVb          WBPth
4 8034x13140_5 2012-09-28 10:07:17               0          Penh          WBPth
5 8034x13140_5 2012-09-28 10:07:17               0           PAU          WBPth
6 8034x13140_5 2012-09-28 10:07:17               0          Rpef          WBPth
  Rec_Exp_date Break_number       Value
1          D-3            1 384.3611755
2          D-3            1   0.1556593
3          D-3            1  59.8293839
4          D-3            1   0.5106936
5          D-3            1   1.6047863
6          D-3            1   0.0828647
> 
> annoCols(bux.db)
character(0)
> 
> annoLevels(bux.db)
character(0)
> 
> dbName(bux.db)
[1] "/tmp/Rtmp9qbGYe/BuxcoR_sample.db"
> 
> samples(bux.db)
[1] "8034x13140_5"  "8034x13140_11" "8034x13140_2"  "8034x13140_3" 
[5] "8034x13140_1"  "8034x13140_9"  "8034x13140_4"  "8034x13140_10"
> 
> tables(bux.db)
[1] "WBPth"
> 
> variables(bux.db)
 [1] "f"     "TVb"   "MVb"   "Penh"  "PAU"   "Rpef"  "Comp"  "PIFb"  "PEFb" 
[10] "Ti"    "Te"    "EF50"  "Tr"    "Tbody" "Tc"    "RH"    "Rinx" 
> 
> addAnnotation(bux.db, query=day.infer.query, index=FALSE)
[1] TRUE
> 
> annoCols(bux.db)
[1] "Days"
> annoLevels(bux.db)
$Days
[1] 0

> 
> addAnnotation(bux.db, query=break.type.query, index=TRUE)
[1] TRUE
> 
> annoCols(bux.db)
[1] "Days"             "Break_type_label"
> annoLevels(bux.db)
$Days
[1] 0

$Break_type_label
[1] "ACC" "EXP"

> 
> head(retrieveData(bux.db))
   Sample_Name              P_Time Break_sec_start Variable_Name Bux_table_Name
1 8034x13140_5 2012-09-28 10:07:17               0             f          WBPth
2 8034x13140_5 2012-09-28 10:07:17               0           TVb          WBPth
3 8034x13140_5 2012-09-28 10:07:17               0           MVb          WBPth
4 8034x13140_5 2012-09-28 10:07:17               0          Penh          WBPth
5 8034x13140_5 2012-09-28 10:07:17               0           PAU          WBPth
6 8034x13140_5 2012-09-28 10:07:17               0          Rpef          WBPth
  Rec_Exp_date Break_number Days Break_type_label       Value
1          D-3            1    0              ACC 384.3611755
2          D-3            1    0              ACC   0.1556593
3          D-3            1    0              ACC  59.8293839
4          D-3            1    0              ACC   0.5106936
5          D-3            1    0              ACC   1.6047863
6          D-3            1    0              ACC   0.0828647
> 
> retrieveMatrix(bux.db)[1:5,1,1:5]
                  Comp       EF50      MVb          PAU     PEFb
8034x13140_1  2.560317 -1.0652255 4.926139 -0.057365138 1.846020
8034x13140_10 2.479401 -2.5683880 3.414403  0.013619735 0.562947
8034x13140_11 2.536534 -1.4970349 4.516881  0.008631076 1.452450
8034x13140_2  2.530732 -0.8779912 4.968516 -0.028844451 1.936628
8034x13140_3  2.559969 -1.4127304 4.558202  0.045366430 1.508704
> 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>