本文整理汇总了Python中biom.table.Table.to_hdf5方法的典型用法代码示例。如果您正苦于以下问题:Python Table.to_hdf5方法的具体用法?Python Table.to_hdf5怎么用?Python Table.to_hdf5使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类biom.table.Table
的用法示例。
在下文中一共展示了Table.to_hdf5方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build_OTU_table_biom
# 需要导入模块: from biom.table import Table [as 别名]
# 或者: from biom.table.Table import to_hdf5 [as 别名]
def build_OTU_table_biom(OTU_table_classic, OTU_table_biom, dataset_ID):
# Builds a BIOM format OTU table from an OTU table in classic dense format (sample IDs in the first row, OTU IDs in the first column). For some reason, 'biom convert' command fails to recognize some OTU tables, and therefore the method classic2biom (above) fails.
with open(OTU_table_classic,'r') as fidin:
otu_table_data = fidin.readlines()
firstrow = otu_table_data[0].split('\t')
sample_labels = firstrow[1:]
sample_labels[len(sample_labels)-1] = sample_labels[len(sample_labels)-1].rstrip('\n')
OTU_labels = [otu_table_data[i].split('\t')[0] for i in range(1,len(otu_table_data))]
nOTUs = len(OTU_labels)
nSamples = len(sample_labels)
# Load OTU table row major order
OTU_table_data = np.zeros((nOTUs, nSamples))
for i in range(1,nOTUs+1):
OTU_table_data[i-1,:] = otu_table_data[i].split('\t')[1:]
# Write in BIOM format
t = Table(OTU_table_data, OTU_labels, sample_labels, observ_metadata=None, sample_metadata=None, table_id=dataset_ID)
with biom_open(OTU_table_biom, 'w') as f:
t.to_hdf5(f, "Generated by processing layer", compress=False)