本文整理汇总了Python中biom.table.Table.transpose方法的典型用法代码示例。如果您正苦于以下问题:Python Table.transpose方法的具体用法?Python Table.transpose怎么用?Python Table.transpose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类biom.table.Table
的用法示例。
在下文中一共展示了Table.transpose方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from biom.table import Table [as 别名]
# 或者: from biom.table.Table import transpose [as 别名]
def main():
option_parser, opts, args = parse_command_line_parameters(**script_info)
lower_percentage = opts.lower_percentage
upper_percentage = opts.upper_percentage
otu_table_fp = opts.otu_table_fp
otu_table = load_table(otu_table_fp)
delimiter = opts.delimiter
mapping_fp = opts.mapping
md_as_string = opts.md_as_string
md_identifier = opts.md_identifier
levels = opts.level.split(',')
suppress_classic_table_output = opts.suppress_classic_table_output
suppress_biom_table_output = opts.suppress_biom_table_output
if upper_percentage is not None and lower_percentage is not None:
raise ValueError(
"upper_percentage and lower_percentage are mutually exclusive")
if upper_percentage is not None and lower_percentage is not None and \
mapping:
raise ValueError("upper_percentage and lower_percentage can not be "
"using with mapping file")
if upper_percentage is not None and \
(upper_percentage < 0 or upper_percentage > 1.0):
raise ValueError('max_otu_percentage should be between 0.0 and 1.0')
if lower_percentage is not None and \
(lower_percentage < 0 or lower_percentage > 1.0):
raise ValueError('lower_percentage should be between 0.0 and 1.0')
if mapping_fp:
mapping_file = open(mapping_fp, 'U')
mapping, header, comments = parse_mapping_file(mapping_file)
# use the input Mapping file for producing the output filenames
map_dir_path, map_fname = split(mapping_fp)
map_basename, map_fname_ext = splitext(map_fname)
else:
if suppress_classic_table_output and suppress_biom_table_output:
option_parser.error("Both classic and BIOM output formats were "
"suppressed.")
if not opts.absolute_abundance:
otu_table = otu_table.norm(axis='sample', inplace=False)
# introduced output directory to will allow for multiple outputs
if opts.output_dir:
create_dir(opts.output_dir, False)
output_dir_path = opts.output_dir
else:
output_dir_path = './'
# use the input OTU table to produce the output filenames
dir_path, fname = split(otu_table_fp)
basename, fname_ext = splitext(fname)
# Iterate over the levels and generate a summarized taxonomy for each
for level in levels:
if mapping_fp:
# define output filename
output_fname = join(output_dir_path,
map_basename + '_L%s.txt' % (level))
summary, tax_order = add_summary_mapping(otu_table,
mapping,
int(level),
md_as_string,
md_identifier)
write_add_taxa_summary_mapping(summary, tax_order, mapping,
header, output_fname, delimiter)
else:
# define the output filename. The extension will be added to the
# end depending on the output format
output_fname = join(output_dir_path, basename + '_L%s' % level)
summary, header = make_summary(otu_table,
int(level),
upper_percentage,
lower_percentage,
md_as_string,
md_identifier)
sample_ids = header[1:]
observation_ids = []
data = []
for row in summary:
# Join taxonomic levels to create an observation ID.
observation_ids.append(delimiter.join(row[0]))
data.append(row[1:])
table = Table(np.asarray(data), observation_ids, sample_ids)
if opts.transposed_output:
table = table.transpose()
if not suppress_classic_table_output:
with open(output_fname + '.txt', 'w') as outfile:
#.........这里部分代码省略.........