def diversity_ana(metric,subsample,ids,**kwargs): if metric == 'faith_pd': each = alpha_diversity('faith_pd', subsample, ids=ids, otu_ids=kwargs['otu_ids'], tree=kwargs['tree']) elif metric == 'shannon': each = alpha_diversity('shannon', subsample, ids=ids) elif metric == 'observed_otus': each = alpha_diversity('observed_otus', subsample, ids=ids) else: try: each = alpha_diversity(metric, subsample, ids=ids) except: print 'Metric you can use is listed below: \n' + '\n'.join(get_alpha_diversity_metrics()) exit() return each
def test_get_alpha_diversity_metrics_sorted(self): m = get_alpha_diversity_metrics() n = sorted(list(m)) self.assertEqual(m, n)
def test_get_alpha_diversity_metrics(self): m = get_alpha_diversity_metrics() # basic sanity checks self.assertTrue('faith_pd' in m) self.assertTrue('chao1' in m)
default='class') parser.add_argument('--list_metric', action='store_true', help="List all metric name you could use.") parser.add_argument('--output_fig', help="If you need to remodify figure, you can assign file path, we will pickle it into file.") args = parser.parse_args() threads = args.thread tree_file = args.tree Otu_table = args.input metadata = args.metadata output_dir = args.output if not os.path.isdir(output_dir): os.makedirs(output_dir) if args.list_metric: print 'Metric you can use is listed below: \n' + '\n'.join(get_alpha_diversity_metrics()) exit() metric = args.metric if ',' in metric: metric = metric.split(',') else: metric = [metric] step = args.step repeat = args.repeat col_need = args.cols ori_otu = read_data(Otu_table) if metadata: sample_info = read_data(metadata) if tree_file: tree = TreeNode.read(tree_file, format='newick')
parser.add_argument('--list_metric', action='store_true', help="List all metric name you could use.") parser.add_argument('--output_fig', help="If you need to remodify figure, you can assign file path, we will pickle it into file.") args = parser.parse_args() threads = args.thread tree_file = args.tree Otu_table = args.input metadata = args.metadata output_dir = args.output if not os.path.isdir(output_dir): os.makedirs(output_dir) if args.list_metric: print('Metric you can use is listed below: \n' + '\n'.join(get_alpha_diversity_metrics())) exit() metric = args.metric if ',' in metric: metric = metric.split(',') else: metric = [metric] step = args.step repeat = args.repeat col_need = args.cols ori_otu = read_data(Otu_table) if metadata: sample_info = read_data(metadata) if tree_file: tree = TreeNode.read(tree_file, format='newick')