Closed amnona closed 8 years ago
The expectation is that taxonomy is a list
of str
. The JSON format is much more flexible on metadata, and this is a known issue. Work on refactoring the HDF5 formatters and parsers is deferred until the Table
migrates to skbio.
09:57:08 (daniel@sandbar):~/Downloads> t = load_table('test.txt')
09:57:21 (daniel@sandbar):~/Downloads> md = {i: {'taxonomy': [d['taxonomy']]} for i, d in zip(t.ids(axis='observation'), t.metadata(axis='observation'))}
09:57:31 (daniel@sandbar):~/Downloads> t.add_metadata(md, axis='observation')
09:57:39 (daniel@sandbar):~/Downloads> f = h5py.File('baz.txt', 'w')
09:57:46 (daniel@sandbar):~/Downloads> t.to_hdf5(f, 'asd')
09:57:52 (daniel@sandbar):~/Downloads> f.close()
Cool. That explains it :) Maybe worth updating the doc for the add_metadata() function to state that?
Thanks! Amnon
On Fri, Jan 29, 2016 at 9:58 AM, Daniel McDonald notifications@github.com wrote:
The expectation is that taxonomy is a list of str. The JSON format is much more flexible on metadata, and this is a known issue. Work on refactoring the HDF5 formatters and parsers is deferred until the Table migrates to skbio.
09:57:08 (daniel@sandbar):~/Downloads> t = load_table('test.txt') 09:57:21 (daniel@sandbar):~/Downloads> md = {i: {'taxonomy': [d['taxonomy']]} for i, d in zip(t.ids(axis='observation'), t.metadata(axis='observation'))} 09:57:31 (daniel@sandbar):~/Downloads> t.add_metadata(md, axis='observation') 09:57:39 (daniel@sandbar):~/Downloads> f = h5py.File('baz.txt', 'w') 09:57:46 (daniel@sandbar):~/Downloads> t.to_hdf5(f, 'asd') 09:57:52 (daniel@sandbar):~/Downloads> f.close()
— Reply to this email directly or view it on GitHub https://github.com/biocore/biom-format/issues/689#issuecomment-176887767 .
Sure, are you able to issue a PR?
On Fri, Jan 29, 2016 at 7:03 PM, amnona notifications@github.com wrote:
Cool. That explains it :) Maybe worth updating the doc for the add_metadata() function to state that?
Thanks! Amnon
On Fri, Jan 29, 2016 at 9:58 AM, Daniel McDonald <notifications@github.com
wrote:
The expectation is that taxonomy is a list of str. The JSON format is much more flexible on metadata, and this is a known issue. Work on refactoring the HDF5 formatters and parsers is deferred until the Table migrates to skbio.
09:57:08 (daniel@sandbar):~/Downloads> t = load_table('test.txt') 09:57:21 (daniel@sandbar):~/Downloads> md = {i: {'taxonomy': [d['taxonomy']]} for i, d in zip(t.ids(axis='observation'), t.metadata(axis='observation'))} 09:57:31 (daniel@sandbar):~/Downloads> t.add_metadata(md, axis='observation') 09:57:39 (daniel@sandbar):~/Downloads> f = h5py.File('baz.txt', 'w') 09:57:46 (daniel@sandbar):~/Downloads> t.to_hdf5(f, 'asd') 09:57:52 (daniel@sandbar):~/Downloads> f.close()
— Reply to this email directly or view it on GitHub < https://github.com/biocore/biom-format/issues/689#issuecomment-176887767> .
— Reply to this email directly or view it on GitHub https://github.com/biocore/biom-format/issues/689#issuecomment-176889438 .
When trying to save a biom table with observation metadata, i get the following error:
This problem does not happen without the metadata added to the biom table. The metadata is added using: table.add_metadata(taxdict,axis='observation') where taxdict is of the form: taxdict[OBSID]={'taxonomy': 'unknown'}
note that to_json() works fine with this table, but later get the same error if try to convert this json file to hdf5. Attached is the json file test.txt