Fork me on GitHub


«  biom.table.Table.to_json   ::   Contents   ::   biom.table.Table.transform  »


Table.to_tsv(header_key=None, header_value=None, metadata_formatter=<type 'str'>, observation_column_name='#OTU ID')

Return self as a string in tab delimited form

Default str output for the Table is just row/col ids and table data without any metadata


header_key : str or None, optional

Defaults to None

header_value : str or None, optional

Defaults to None

metadata_formatter : function, optional

Defaults to str. a function which takes a metadata entry and returns a formatted version that should be written to file

observation_column_name : str, optional

Defaults to “#OTU ID”. The name of the first column in the output table, corresponding to the observation IDs.



tab delimited representation of the Table


>>> import numpy as np
>>> from biom.table import Table

Create a 2x3 BIOM table, with observation metadata and no sample metadata:

>>> data = np.asarray([[0, 0, 1], [1, 3, 42]])
>>> table = Table(data, ['O1', 'O2'], ['S1', 'S2', 'S3'],
...               [{'foo': 'bar'}, {'x': 'y'}], None)
>>> print table.to_tsv() 
# Constructed from biom file
#OTU ID S1      S2      S3
O1      0.0     0.0     1.0
O2      1.0     3.0     42.0

«  biom.table.Table.to_json   ::   Contents   ::   biom.table.Table.transform  »