File: biom-2.0.rst

package info (click to toggle)
python-biom-format 2.1.7%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 51,820 kB
  • sloc: python: 12,757; makefile: 155; sh: 79
file content (255 lines) | stat: -rw-r--r-- 11,321 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
.. _biom-2.0:

===========================================
The biom file format: Version 2.0
===========================================
    
The ``biom`` format is based on `HDF5 <http://www.hdfgroup.org>`_ to provide the overall structure for the format. HDF5 is a widely supported binary format with native parsers available within many programming languages. 

Required top-level attributes::

    id                  : <string or null> a field that can be used to id a table (or null)
    format              : <string> The name and version of the current biom format
    format-url          : <url> A string with a static URL providing format details
    type                : <string> Table type (a controlled vocabulary)
                          Acceptable values:
                           "OTU table"
                           "Pathway table"
                           "Function table"
                           "Ortholog table"
                           "Gene table"
                           "Metabolite table"
                           "Taxon table"
    generated-by        : <string> Package and revision that built the table
    creation-date       : <datetime> Date the table was built (ISO 8601 format)
    nnz                 : <int> The number of non-zero elements in the table
    shape               : <list of ints>, the number of rows and number of columns in data

Required groups::

    observation/        : The HDF5 group that contains observation specific information and an observation oriented view of the data
    observation/matrix  : The HDF5 group that contains matrix data oriented for observation-wise operations (e.g., in compressed sparse row format)
    sample/             : The HDF5 group that contains sample specific information and a sample oriented data oriented view of the data
    sample/matrix       : The HDF5 group that contains matrix data oriented for sample-wise operations (e.g., in compressed sparse column format)

Required datasets::

    observation/ids            : <string> or <variable length string> A (N,) dataset of the observation IDs, where N is the total number of IDs
    observation/matrix/data    : <float64> A (nnz,) dataset containing the actual matrix data
    observation/matrix/indices : <int32> A (nnz,) dataset containing the column indices (e.g., maps into samples/ids)
    observation/matrix/indptr  : <int32> A (M+1,) dataset containing the compressed row offsets
    sample/ids                 : <string> or <variable length string> A (M,) dataset of the sample IDs, where M is the total number of IDs
    sample/matrix/data         : <float64> A (nnz,) dataset containing the actual matrix data
    sample/matrix/indices      : <int32> A (nnz,) dataset containing the row indices (e.g., maps into observation/ids)
    sample/matrix/indptr       : <int32> A (N+1,) dataset containing the compressed column offsets

Optional datasets::

    observation/metadata       : <variable length string or null> If specified, a (1,) dataset containing a JSON-string representation of the metadata
    sample/metadata            : <variable length string or null> If specified, a (1,) dataset containing a JSON-string representation of the metadata


The metadata for each axis (observation and sample) are described with JSON. The required structure, if the metadata are specified, is a list of objects, where the list is in index order with respect to the axis (e.g, the object at element 0 corresponds to ID 0 for the given axis). Any metadata that corresponds to the ID, such as taxonomy, can be represented in the object. For instance, the following JSON string describes taxonomy for three IDs:

Metadata description::

    [
        {"taxonomy": ["k__Bacteria", "p__Proteobacteria", "c__Gammaproteobacteria", "o__Enterobacteriales", "f__Enterobacteriaceae", "g__Escherichia", "s__"]}},
        {"taxonomy": ["k__Bacteria", "p__Cyanobacteria", "c__Nostocophycideae", "o__Nostocales", "f__Nostocaceae", "g__Dolichospermum", "s__"]}},
        {"taxonomy": ["k__Archaea", "p__Euryarchaeota", "c__Methanomicrobia", "o__Methanosarcinales", "f__Methanosarcinaceae", "g__Methanosarcina", "s__"]}}
    ]

Example biom files
==================

Below is an example of a rich biom file before binary compression into HDF5. Example binary files are located in the `github repository <https://github.com/biocore/biom-format/tree/master/examples>`_.

BIOM 2.0 OTU table in the HDF5 data description langauge (DDL)
--------------------------------------------------------------

::

    HDF5 "rich_sparse_otu_table_hdf5.biom" {
    GROUP "/" {
       ATTRIBUTE "creation-date" {
          DATATYPE  H5T_STRING {
             STRSIZE H5T_VARIABLE;
             STRPAD H5T_STR_NULLTERM;
             CSET H5T_CSET_ASCII;
             CTYPE H5T_C_S1;
          }
          DATASPACE  SCALAR
          DATA {
          (0): "2014-05-13T14:50:32.052446"
          }
       }
       ATTRIBUTE "format-url" {
          DATATYPE  H5T_STRING {
             STRSIZE H5T_VARIABLE;
             STRPAD H5T_STR_NULLTERM;
             CSET H5T_CSET_ASCII;
             CTYPE H5T_C_S1;
          }
          DATASPACE  SCALAR
          DATA {
          (0): "http://biom-format.org"
          }
       }
       ATTRIBUTE "format-version" {
          DATATYPE  H5T_STD_I64LE
          DATASPACE  SIMPLE { ( 2 ) / ( 2 ) }
          DATA {
          (0): 2, 0
          }
       }
       ATTRIBUTE "generated-by" {
          DATATYPE  H5T_STRING {
             STRSIZE H5T_VARIABLE;
             STRPAD H5T_STR_NULLTERM;
             CSET H5T_CSET_ASCII;
             CTYPE H5T_C_S1;
          }
          DATASPACE  SCALAR
          DATA {
          (0): "example"
          }
       }
       ATTRIBUTE "id" {
          DATATYPE  H5T_STRING {
             STRSIZE H5T_VARIABLE;
             STRPAD H5T_STR_NULLTERM;
             CSET H5T_CSET_ASCII;
             CTYPE H5T_C_S1;
          }
          DATASPACE  SCALAR
          DATA {
          (0): "No Table ID"
          }
       }
       ATTRIBUTE "nnz" {
          DATATYPE  H5T_STD_I64LE
          DATASPACE  SCALAR
          DATA {
          (0): 15
          }
       }
       ATTRIBUTE "shape" {
          DATATYPE  H5T_STD_I64LE
          DATASPACE  SIMPLE { ( 2 ) / ( 2 ) }
          DATA {
          (0): 5, 6
          }
       }
       ATTRIBUTE "type" {
          DATATYPE  H5T_STRING {
             STRSIZE H5T_VARIABLE;
             STRPAD H5T_STR_NULLTERM;
             CSET H5T_CSET_ASCII;
             CTYPE H5T_C_S1;
          }
          DATASPACE  SCALAR
          DATA {
          (0): "otu table"
          }
       }
       GROUP "observation" {
          DATASET "ids" {
             DATATYPE  H5T_STRING {
                STRSIZE H5T_VARIABLE;
                STRPAD H5T_STR_NULLTERM;
                CSET H5T_CSET_ASCII;
                CTYPE H5T_C_S1;
             }
             DATASPACE  SIMPLE { ( 5 ) / ( 5 ) }
             DATA {
             (0): "GG_OTU_1", "GG_OTU_2", "GG_OTU_3", "GG_OTU_4", "GG_OTU_5"
             }
          }
          GROUP "matrix" {
             DATASET "data" {
                DATATYPE  H5T_IEEE_F64LE
                DATASPACE  SIMPLE { ( 15 ) / ( 15 ) }
                DATA {
                (0): 1, 5, 1, 2, 3, 1, 1, 4, 2, 2, 1, 1, 1, 1, 1
                }
             }
             DATASET "indices" {
                DATATYPE  H5T_STD_I32LE
                DATASPACE  SIMPLE { ( 15 ) / ( 15 ) }
                DATA {
                (0): 2, 0, 1, 3, 4, 5, 2, 3, 5, 0, 1, 2, 5, 1, 2
                }
             }
             DATASET "indptr" {
                DATATYPE  H5T_STD_I32LE
                DATASPACE  SIMPLE { ( 6 ) / ( 6 ) }
                DATA {
                (0): 0, 1, 6, 9, 13, 15
                }
             }
          }
          DATASET "metadata" {
             DATATYPE  H5T_STRING {
                STRSIZE H5T_VARIABLE;
                STRPAD H5T_STR_NULLTERM;
                CSET H5T_CSET_ASCII;
                CTYPE H5T_C_S1;
             }
             DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }
             DATA {
             (0): "[{"taxonomy": ["k__Bacteria", "p__Proteobacteria", "c__Gammaproteobacteria", "o__Enterobacteriales", "f__Enterobacteriaceae", "g__Escherichia", "s__"]}, {"taxonomy": ["k__Bacteria", "p__Cyanobacteria", "c__Nostocophycideae", "o__Nostocales", "f__Nostocaceae", "g__Dolichospermum", "s__"]}, {"taxonomy": ["k__Archaea", "p__Euryarchaeota", "c__Methanomicrobia", "o__Methanosarcinales", "f__Methanosarcinaceae", "g__Methanosarcina", "s__"]}, {"taxonomy": ["k__Bacteria", "p__Firmicutes", "c__Clostridia", "o__Halanaerobiales", "f__Halanaerobiaceae", "g__Halanaerobium", "s__Halanaerobiumsaccharolyticum"]}, {"taxonomy": ["k__Bacteria", "p__Proteobacteria", "c__Gammaproteobacteria", "o__Enterobacteriales", "f__Enterobacteriaceae", "g__Escherichia", "s__"]}]"
             }
          }
       }
       GROUP "sample" {
          DATASET "ids" {
             DATATYPE  H5T_STRING {
                STRSIZE H5T_VARIABLE;
                STRPAD H5T_STR_NULLTERM;
                CSET H5T_CSET_ASCII;
                CTYPE H5T_C_S1;
             }
             DATASPACE  SIMPLE { ( 6 ) / ( 6 ) }
             DATA {
             (0): "Sample1", "Sample2", "Sample3", "Sample4", "Sample5",
             (5): "Sample6"
             }
          }
          GROUP "matrix" {
             DATASET "data" {
                DATATYPE  H5T_IEEE_F64LE
                DATASPACE  SIMPLE { ( 15 ) / ( 15 ) }
                DATA {
                (0): 5, 2, 1, 1, 1, 1, 1, 1, 1, 2, 4, 3, 1, 2, 1
                }
             }
             DATASET "indices" {
                DATATYPE  H5T_STD_I32LE
                DATASPACE  SIMPLE { ( 15 ) / ( 15 ) }
                DATA {
                (0): 1, 3, 1, 3, 4, 0, 2, 3, 4, 1, 2, 1, 1, 2, 3
                }
             }
             DATASET "indptr" {
                DATATYPE  H5T_STD_I32LE
                DATASPACE  SIMPLE { ( 7 ) / ( 7 ) }
                DATA {
                (0): 0, 2, 5, 9, 11, 12, 15
                }
             }
          }
          DATASET "metadata" {
             DATATYPE  H5T_STRING {
                STRSIZE H5T_VARIABLE;
                STRPAD H5T_STR_NULLTERM;
                CSET H5T_CSET_ASCII;
                CTYPE H5T_C_S1;
             }
             DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }
             DATA {
             (0): "[{"LinkerPrimerSequence": "CATGCTGCCTCCCGTAGGAGT", "BarcodeSequence": "CGCTTATCGAGA", "Description": "human gut", "BODY_SITE": "gut"}, {"LinkerPrimerSequence": "CATGCTGCCTCCCGTAGGAGT", "BarcodeSequence": "CATACCAGTAGC", "Description": "human gut", "BODY_SITE": "gut"}, {"LinkerPrimerSequence": "CATGCTGCCTCCCGTAGGAGT", "BarcodeSequence": "CTCTCTACCTGT", "Description": "human gut", "BODY_SITE": "gut"}, {"LinkerPrimerSequence": "CATGCTGCCTCCCGTAGGAGT", "BarcodeSequence": "CTCTCGGCCTGT", "Description": "human skin", "BODY_SITE": "skin"}, {"LinkerPrimerSequence": "CATGCTGCCTCCCGTAGGAGT", "BarcodeSequence": "CTCTCTACCAAT", "Description": "human skin", "BODY_SITE": "skin"}, {"LinkerPrimerSequence": "CATGCTGCCTCCCGTAGGAGT", "BarcodeSequence": "CTAACTACCAAT", "Description": "human skin", "BODY_SITE": "skin"}]"
             }
          }
       }
    }
    }