本文整理汇总了Python中qiime.rarefaction.RarefactionMaker类的典型用法代码示例。如果您正苦于以下问题:Python RarefactionMaker类的具体用法?Python RarefactionMaker怎么用?Python RarefactionMaker使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RarefactionMaker类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
def main():
option_parser, opts, args = parse_command_line_parameters(**script_info)
if not os.path.exists(opts.output_path):
os.makedirs(opts.output_path)
maker = RarefactionMaker(opts.input_path, opts.depth, opts.depth, 1, opts.num_reps)
maker.rarefy_to_files(
opts.output_path, False, include_lineages=opts.lineages_included, empty_otus_removed=(not opts.keep_empty_otus)
)
示例2: test_rarefy_to_list
def test_rarefy_to_list(self):
"""rarefy_to_list should rarefy correctly, same names, rm empty samples
"""
maker = RarefactionMaker(self.otu_tuple, 0, 1, 1, 1)
res = maker.rarefy_to_list(include_full=True)
self.assertFloatEqual(res[-1][2], self.sample_names)
self.assertFloatEqual(res[-1][3], self.taxon_names)
self.assertFloatEqual(res[-1][4], self.otu_table_transpose.T)
# each sample should have 1 seq, sample z should be removed
self.assertFloatEqual((res[1][4]).sum(0),[1.0,1.0] )
示例3: main
def main():
option_parser, opts, args = parse_command_line_parameters(**script_info)
if opts.step <= 0:
option_parser.error("nonpositive step not allowed (%s was supplied)" % \
(opts.step,))
create_dir(opts.output_path, fail_on_exist=False)
maker = RarefactionMaker(opts.input_path, opts.min, opts.max,
opts.step, opts.num_reps)
maker.rarefy_to_files(opts.output_path, False,
include_lineages=opts.lineages_included,
empty_otus_removed=(not opts.keep_empty_otus))
示例4: test_rarefy_to_files
def test_rarefy_to_files(self):
"""rarefy_to_files should write valid files
"""
maker = RarefactionMaker(self.otu_table_fp, 0, 1, 1, 1)
maker.rarefy_to_files(self.rare_dir,include_full=True,include_lineages=False)
fname = os.path.join(self.rare_dir,"rarefaction_1_0.biom")
otu_table = parse_biom_table(open(fname,'U'))
self.assertFloatEqual(otu_table.SampleIds, self.otu_table.SampleIds[:2])
# third sample had 0 seqs, so it's gone
self.assertFloatEqual(otu_table.ObservationIds, self.otu_table.ObservationIds)
示例5: test_rarefy_to_list
def test_rarefy_to_list(self):
"""rarefy_to_list should rarefy correctly, same names
"""
maker = RarefactionMaker(self.otu_table_fp, 0, 1, 1, 1)
res = maker.rarefy_to_list(include_full=True)
self.assertFloatEqual(res[-1][2].SampleIds, self.otu_table.SampleIds)
self.assertFloatEqual(res[-1][2].ObservationIds, self.otu_table.ObservationIds)
self.assertEqual(res[-1][2], self.otu_table)
sample_value_sum = []
for val in res[1][2].iterSampleData():
sample_value_sum.append(val.sum())
self.assertFloatEqual(sample_value_sum, [1.0, 1.0])
示例6: test_rarefy_to_files
def test_rarefy_to_files(self):
"""rarefy_to_files should write valid files
"""
maker = RarefactionMaker(self.otu_table_fp, 1, 2, 1, 1)
maker.rarefy_to_files(
self.rare_dir,
include_full=True,
include_lineages=False)
fname = os.path.join(self.rare_dir, "rarefaction_1_0.biom")
otu_table = load_table(fname)
self.assertItemsEqual(
otu_table.ids(),
self.otu_table.ids()[:2])
示例7: test_rarefy_to_list
def test_rarefy_to_list(self):
"""rarefy_to_list should rarefy correctly, same names
"""
maker = RarefactionMaker(self.otu_table_fp, 0, 1, 1, 1)
res = maker.rarefy_to_list(include_full=True)
self.assertItemsEqual(res[-1][2].ids(), self.otu_table.ids())
self.assertItemsEqual(
res[-1][2].ids(axis='observation'),
self.otu_table.ids(axis='observation'))
self.assertEqual(res[-1][2], self.otu_table)
sample_value_sum = []
for val in res[1][2].iter_data(axis='sample'):
sample_value_sum.append(val.sum())
npt.assert_almost_equal(sample_value_sum, [1.0, 1.0])
示例8: test_rarefy_to_files
def test_rarefy_to_files(self):
"""rarefy_to_files should write valid files
"""
maker = RarefactionMaker(self.otu_table_fp, 0, 1, 1, 1)
maker.rarefy_to_files(
self.rare_dir,
include_full=True,
include_lineages=False)
fname = os.path.join(self.rare_dir, "rarefaction_1_0.biom")
with biom_open(fname, 'U') as biom_file:
otu_table = Table.from_hdf5(biom_file)
self.assertItemsEqual(
otu_table.sample_ids,
self.otu_table.sample_ids[:2])
示例9: main
def main():
option_parser, opts, args = parse_command_line_parameters(**script_info)
if opts.step <= 0:
option_parser.error("step must be greater than 0")
create_dir(opts.output_path, fail_on_exist=False)
maker = RarefactionMaker(opts.input_path, opts.min, opts.max,
opts.step, opts.num_reps)
if opts.subsample_multinomial:
subsample_f = partial(subsample, replace=True)
else:
subsample_f = subsample
maker.rarefy_to_files(opts.output_path,
False,
include_lineages=opts.lineages_included,
empty_otus_removed=(not opts.keep_empty_otus),
subsample_f=subsample_f)
示例10: get_rarefactions
def get_rarefactions(biom_object, minimum, maximum, iterations, steps):
"""rarify biom object and return rarefactions
Inputs:
biom_object: object to rarefy
minimum: starting point for the rarefactions
maximum: ending point for the rarefactions
iterations: repetitions per rarefaction depth
steps: number of levels between minimum and maximum
Outputs:
list of 3 element tuples, where each tuple contains as a 1st element the
rarefaction depth, as a 2nd element the iteration number and as a 3rd
element the rarefied biom corresponding to this depth
"""
rarefaction_step_size = int((maximum - minimum)/steps)
rarefaction_maker = RarefactionMaker(biom_object, minimum, maximum,\
rarefaction_step_size, iterations)
rarefactions = rarefaction_maker.rarefy_to_list()
return rarefactions