biom格式的文件如何转化

biom格式的文件如果想要删除某个物种啥的,转换以后直接修改是不行的 先转化成tsv biom convert -i bak/feature_table_tax.biom -o feature_table_tax.tsv --to-tsv --header-key taxonomys l...

biom格式的文件如果想要删除某个物种啥的,转换以后直接修改是不行的

先转化成tsv

biom convert -i bak/feature_table_tax.biom -o feature_table_tax.tsv --to-tsv --header-key taxonomys

less feature_table_tax.tsv 

# Constructed from biom file
#OTU ID FT-1    CKR-4   CK0-1   CKR-5   FTR-4   CK0-5   CKR-1   FTR-5   FT-2    FT-3    CKR-3   CK0-4   CK0-3   FTR-3   FTR-2   FTR-1   FT-5    CK0-2   FT-4    CKR-2   taxonomy
6f8a1344c343b000bbe6c0946ef7af3f        3.0     0.0     0.0     9.0     10.0    0.0     0.0     2.0     0.0     0.0     3.0     0.0     5.0     2.0     0.0     0.0     0.0     0.0     3.0     0.0     k__Fungi; p__Fungi_phy_Inc
549c55efd9ef6cd14bd36400788f522b        34.0    30.0    0.0     0.0     3.0     9.0     7.0     5.0     0.0     19.0    20.0    6.0     0.0     0.0     3.0     10.0    0.0     0.0     4.0     0.0     k__Fungi; p__Basidiomycota
8235cac40e51a49e036c21599774db48        0.0     0.0     0.0     0.0     0.0     0.0     0.0     0.0     0.0     0.0     0.0     0.0     0.0     0.0     0.0     134.0   37.0    0.0     0.0     0.0     k__Fungi; p__Ascomycota; c
3dfbc9a73f75b6dffe7d9d11d0bf5e6e        0.0     3.0     0.0     0.0     3.0     0.0     22.0    0.0     4.0     0.0     4.0     2.0     0.0     0.0     0.0     3.0     0.0     0.0     0.0     0.0     k__Fungi; p__Basidiomycota

处理完以后如果直接转化

biom convert -i feature_table_tax.txt -o feature_table_tax.biom --table-type="OTU table" --to-hdf5 --header-key taxonomy

Traceback (most recent call last):
  File "/share/work/biosoft/python/Python-v2.7.11/bin/biom", line 9, in <module>
    load_entry_point('biom-format==2.1.5', 'console_scripts', 'biom')()
  File "/share/work/biosoft/python/Python-v2.7.11/lib/python2.7/site-packages/click-6.3-py2.7.egg/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/share/work/biosoft/python/Python-v2.7.11/lib/python2.7/site-packages/click-6.3-py2.7.egg/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/share/work/biosoft/python/Python-v2.7.11/lib/python2.7/site-packages/click-6.3-py2.7.egg/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/share/work/biosoft/python/Python-v2.7.11/lib/python2.7/site-packages/click-6.3-py2.7.egg/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/share/work/biosoft/python/Python-v2.7.11/lib/python2.7/site-packages/click-6.3-py2.7.egg/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/share/work/biosoft/python/Python-v2.7.11/lib/python2.7/site-packages/biom_format-2.1.5-py2.7-linux-x86_64.egg/biom/cli/table_converter.py", line 129, in convert
    table_type, process_obs_metadata, tsv_metadata_formatter)
  File "/share/work/biosoft/python/Python-v2.7.11/lib/python2.7/site-packages/biom_format-2.1.5-py2.7-linux-x86_64.egg/biom/cli/table_converter.py", line 207, in _convert
    write_biom_table(result, fmt, output_filepath)
  File "/share/work/biosoft/python/Python-v2.7.11/lib/python2.7/site-packages/biom_format-2.1.5-py2.7-linux-x86_64.egg/biom/cli/util.py", line 35, in write_biom_table
    table.to_hdf5(f, biom.parse.generatedby())
  File "/share/work/biosoft/python/Python-v2.7.11/lib/python2.7/site-packages/biom_format-2.1.5-py2.7-linux-x86_64.egg/biom/table.py", line 3605, in to_hdf5
    self.group_metadata(axis='observation'), 'csr', compression)
  File "/share/work/biosoft/python/Python-v2.7.11/lib/python2.7/site-packages/biom_format-2.1.5-py2.7-linux-x86_64.egg/biom/table.py", line 3577, in axis_dump
    formatter[category](grp, category, md, compression)
  File "/share/work/biosoft/python/Python-v2.7.11/lib/python2.7/site-packages/biom_format-2.1.5-py2.7-linux-x86_64.egg/biom/table.py", line 277, in vlen_list_of_str_formatter
    data[i, :len(value)] = [v.encode('utf8') for v in value]
TypeError: iteration over a 0-d array

会报错,需要加一个--process-obs-metadata参数

  --process-obs-metadata [taxonomy|naive|sc_separated]
                                  Process metadata associated with
                                  observations when converting from a classic
                                  table.


biom convert -i feature_table_tax.txt -o feature_table_tax.biom --table-type="OTU table" --to-hdf5 --header-key taxonomy --process-obs-metadata taxonomy

就可以了

  • 发表于 2024-07-23 15:29
  • 阅读 ( 563 )
  • 分类:宏基因组

你可能感兴趣的文章

相关问题

0 条评论

请先 登录 后评论
xun
xun

电路元件工程师

82 篇文章

作家榜 »

  1. omicsgene 700 文章
  2. 安生水 348 文章
  3. Daitoue 167 文章
  4. 生物女学霸 120 文章
  5. xun 82 文章
  6. 红橙子 78 文章
  7. rzx 75 文章
  8. CORNERSTONE 72 文章