biom_data-methods: Access main data observation matrix data from 'biom-class'.

Description Usage Arguments Value Examples

Description

Retrieve and organize main data from biom-class, represented as a matrix with index names.

Usage

1
  biom_data(x, rows, columns, parallel=FALSE)

Arguments

x

(Required). An instance of the biom-class.

rows

(Optional). The subset of row indices described in the returned object. For large datasets, specifying the row subset here, rather than after creating the whole matrix first, can improve speed/efficiency. Can be vector of index numbers (numeric-class) or index names (character-class).

columns

(Optional). The subset of column indices described in the returned object. For large datasets, specifying the column subset here, rather than after creating the whole matrix first, can improve speed/efficiency. Can be vector of index numbers (numeric-class) or index names (character-class).

parallel

(Optional). Logical. Whether to perform the accession parsing using a parallel-computing backend supported by the plyr-package via the foreach-package. Note: At the moment, the header accessor does not need nor does it support parallel-computed parsing.

Value

A matrix containing the main observation data, with index names. The type of data (numeric or character) will depend on the results of matrix_element_type(x). The class of the matrix returned will depend on the sparsity of the data, and whether it has numeric or character data. For now, only numeric data can be stored in a Matrix-class, which will be stored sparsely, if possible. Character data will be returned as a vanilla matrix-class.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
min_dense_file   = system.file("extdata", "min_dense_otu_table.biom", package = "biom")
min_sparse_file  = system.file("extdata", "min_sparse_otu_table.biom", package = "biom")
rich_dense_file  = system.file("extdata", "rich_dense_otu_table.biom", package = "biom")
rich_sparse_file = system.file("extdata", "rich_sparse_otu_table.biom", package = "biom")
min_dense_file   = system.file("extdata", "min_dense_otu_table.biom", package = "biom")
rich_dense_char  = system.file("extdata", "rich_dense_char.biom", package = "biom")
rich_sparse_char  = system.file("extdata", "rich_sparse_char.biom", package = "biom")
# Read the biom-format files
x1 = read_biom(min_dense_file)
x2 = read_biom(min_sparse_file)
x3 = read_biom(rich_dense_file)
x4 = read_biom(rich_sparse_file)
x5 = read_biom(rich_dense_char)
x6 = read_biom(rich_sparse_char)
# Extract the data matrices
biom_data(x1)
biom_data(x2)
biom_data(x3)
biom_data(x4)
biom_data(x5)
biom_data(x6)

Example output

5 x 6 Matrix of class "dgeMatrix"
         Sample1 Sample2 Sample3 Sample4 Sample5 Sample6
GG_OTU_1       0       0       1       0       0       0
GG_OTU_2       5       1       0       2       3       1
GG_OTU_3       0       0       1       4       2       0
GG_OTU_4       2       1       1       0       0       1
GG_OTU_5       0       1       1       0       0       0
5 x 6 sparse Matrix of class "dgCMatrix"
         Sample1 Sample2 Sample3 Sample4 Sample5 Sample6
GG_OTU_1       .       .       1       .       .       .
GG_OTU_2       5       1       .       2       3       1
GG_OTU_3       .       .       1       4       .       2
GG_OTU_4       2       1       1       .       .       1
GG_OTU_5       .       1       1       .       .       .
5 x 6 Matrix of class "dgeMatrix"
         Sample1 Sample2 Sample3 Sample4 Sample5 Sample6
GG_OTU_1       0       0       1       0       0       0
GG_OTU_2       5       1       0       2       3       1
GG_OTU_3       0       0       1       4       2       0
GG_OTU_4       2       1       1       0       0       1
GG_OTU_5       0       1       1       0       0       0
5 x 6 sparse Matrix of class "dgCMatrix"
         Sample1 Sample2 Sample3 Sample4 Sample5 Sample6
GG_OTU_1       .       .       1       .       .       .
GG_OTU_2       5       1       .       2       3       1
GG_OTU_3       .       .       1       4       .       2
GG_OTU_4       2       1       1       .       .       1
GG_OTU_5       .       1       1       .       .       .
         Sample1 Sample2     Sample3 Sample4 Sample5  Sample6 
GG_OTU_1 "0"     "sky"       "1"     "0"     "clouds" "0"     
GG_OTU_2 "5"     "1"         "0"     "2"     "3"      "1"     
GG_OTU_3 "0"     "lightning" "1"     "4"     "2"      "0"     
GG_OTU_4 "2"     "1"         "1"     "0"     "gray"   "1"     
GG_OTU_5 "0"     "1"         "1"     "0"     "0"      "bottle"
         Sample1  Sample2     Sample3 Sample4 Sample5  Sample6
GG_OTU_1 NA       NA          "sky"   NA      NA       NA     
GG_OTU_2 "clouds" "lightning" NA      "gray"  "bottle" "1"    
GG_OTU_3 NA       NA          "1"     "4"     NA       "2"    
GG_OTU_4 "2"      "1"         "1"     NA      NA       "1"    
GG_OTU_5 NA       "1"         "1"     NA      NA       NA     

biom documentation built on Jan. 15, 2017, 9:30 a.m.