biom.table.Table.to_tsv — biom-format.org

# biom-format.org

## biom.table.Table.to_tsv

`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

  Parameters: | 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.
  Returns: | str tab delimited representation of the Table

  Examples

      >>> 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