Did I find the right examples for you? yes no      Crawl my project      Python Jobs

# cogent.maths.unifrac.fast_unifrac.fast_unifrac_one_sample

All Samples(12)  |  Call(8)  |  Derive(0)  |  Import(4)

``` # (unifrac, unnormalized_unifrac,
#    G, unnormalized_G, weighted_unifrac)
from cogent.maths.unifrac.fast_unifrac import fast_unifrac, fast_unifrac_one_sample
from qiime.parse import make_envs_dict
import numpy
```
```        envs = make_envs_dict(data, sample_names, taxon_names)
try:
unifrac_res = fast_unifrac_one_sample(one_sample_name,
tree, envs, weighted=weighted, metric=metric,**kwargs)
except ValueError as e:
```

``` # (unifrac, unnormalized_unifrac,
#    G, unnormalized_G, weighted_unifrac)
from cogent.maths.unifrac.fast_unifrac import fast_unifrac, fast_unifrac_one_sample
from qiime.parse import make_envs_dict
import numpy
```
```        envs = make_envs_dict(data, sample_names, taxon_names)
try:
unifrac_res = fast_unifrac_one_sample(one_sample_name,
tree, envs, weighted=weighted, metric=metric, **kwargs)
except ValueError as e:
```

```from cogent.maths.unifrac.fast_tree import (count_envs, index_tree, index_envs,
get_branch_lengths)
from cogent.maths.unifrac.fast_unifrac import (reshape_by_name,
meta_unifrac, shuffle_tipnames, weight_equally, weight_by_num_tips,
weight_by_branch_length, weight_by_num_seqs, get_all_env_names,
```
```        # then get one sample unifrac vector
one_sam_dvec, one_sam_env_order = \
fast_unifrac_one_sample('B', self.t, self.env_counts)
one_sam_dvec = one_sam_dvec[argsort(one_sam_env_order)]
self.assertFloatEqual(one_sam_dvec, dmtx_vec)
```
```        # then get one sample unifrac vector
one_sam_dvec, one_sam_env_order = \
fast_unifrac_one_sample('B', self.t, self.env_counts,weighted=True)
one_sam_dvec = one_sam_dvec[argsort(one_sam_env_order)]
self.assertFloatEqual(one_sam_dvec, dmtx_vec)
```
```        # then get one sample unifrac vector
one_sam_dvec, one_sam_env_order = \
fast_unifrac_one_sample('C', self.t,
self.missing_env_counts,weighted=False)
one_sam_dvec = one_sam_dvec[argsort(one_sam_env_order)]
```

```from cogent.maths.unifrac.fast_tree import (count_envs, index_tree, index_envs,
get_branch_lengths)
from cogent.maths.unifrac.fast_unifrac import (reshape_by_name,
meta_unifrac, shuffle_tipnames, weight_equally, weight_by_num_tips,
weight_by_branch_length, weight_by_num_seqs, get_all_env_names,
```
```        # then get one sample unifrac vector
one_sam_dvec, one_sam_env_order = \
fast_unifrac_one_sample('B', self.t, self.env_counts)
one_sam_dvec = one_sam_dvec[argsort(one_sam_env_order)]
self.assertFloatEqual(one_sam_dvec, dmtx_vec)
```
```        # then get one sample unifrac vector
one_sam_dvec, one_sam_env_order = \
fast_unifrac_one_sample('B', self.t, self.env_counts,weighted=True)
one_sam_dvec = one_sam_dvec[argsort(one_sam_env_order)]
self.assertFloatEqual(one_sam_dvec, dmtx_vec)
```
```        # then get one sample unifrac vector
one_sam_dvec, one_sam_env_order = \
fast_unifrac_one_sample('C', self.t,
self.missing_env_counts,weighted=False)
one_sam_dvec = one_sam_dvec[argsort(one_sam_env_order)]
```