标签:top npm fst tts crc lua ahci san nap
import numpy
from biom.table import Table
============================================================================================================
# 10*4 matrix, [0, 39]
data = numpy.arange(40).reshape(10, 4)
sample_ids = [‘S%d‘ % i for i in range(4)]
observ_ids = [‘O%d‘ % i for i in range(10)]
sample_metadata = [{‘environment‘: ‘A‘}, {‘environment‘: ‘B‘},
{‘environment‘: ‘A‘}, {‘environment‘: ‘B‘}]
observ_metadata = [{‘taxonomy‘: [‘Bacteria‘, ‘Firmicutes‘]},
{‘taxonomy‘: [‘Bacteria‘, ‘Firmicutes‘]},
{‘taxonomy‘: [‘Bacteria‘, ‘Proteobacteria‘]},
{‘taxonomy‘: [‘Bacteria‘, ‘Proteobacteria‘]},
{‘taxonomy‘: [‘Bacteria‘, ‘Proteobacteria‘]},
{‘taxonomy‘: [‘Bacteria‘, ‘Bacteroidetes‘]},
{‘taxonomy‘: [‘Bacteria‘, ‘Bacteroidetes‘]},
{‘taxonomy‘: [‘Bacteria‘, ‘Firmicutes‘]},
{‘taxonomy‘: [‘Bacteria‘, ‘Firmicutes‘]},
{‘taxonomy‘: [‘Bacteria‘, ‘Firmicutes‘]}]
# construct table
table = Table(data, observ_ids, sample_ids, observ_metadata, sample_metadata, table_id=‘myTestTable‘)
# print info of table
table
print(table)
#
print column names
print(table.ids())
print(table.ids(axis=‘sample‘))
# print row names
print(table.ids(axis=‘observation‘))
# print number of non-zero entries. Now it’s 39.
print(table.nnz)
============================================================================================================
data = numpy.asarray([[2, 0], [6, 1]])
table = Table(data, [‘O1‘, ‘O2‘], [‘S1‘, ‘S2‘])
# normalize by ‘sample’(column)
new_table = table.norm(inplace=False)
#
normalize by row
new_table = table.norm(axis=‘observation‘, inplace=False)
# if inplace=True, table will change too. Now it stay unchanged. If set table1 = table before norm, and change table1 now, then table will change, too(shallow copy).
============================================================================================================
============================================================================================================
标签:top npm fst tts crc lua ahci san nap
原文地址:http://www.cnblogs.com/pxy7896/p/6386892.html