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

# cogent.maths.unifrac.fast_unifrac.fast_unifrac

All Samples(22)  |  Call(16)  |  Derive(0)  |  Import(6)

``` # (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)
unifrac_res = fast_unifrac(tree, envs, weighted=weighted, metric=metric,
is_symmetric=is_symmetric, modes=["distance_matrix"],**kwargs)
dist_mtx = _reorder_unifrac_res(unifrac_res['distance_matrix'],
```

``` # (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)
unifrac_res = fast_unifrac(
tree, envs, weighted=weighted, metric=metric,
is_symmetric=is_symmetric, modes=["distance_matrix"], **kwargs)
dist_mtx = _reorder_unifrac_res(unifrac_res['distance_matrix'],
```

```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,
```
```    def test_fast_unifrac(self):
"""Should calc unifrac values for whole tree."""
#Note: results not tested for correctness here as detailed tests
#in fast_tree module.
res = fast_unifrac(self.t, self.env_counts)
res = fast_unifrac(self.t, self.missing_env_counts)
res = fast_unifrac(self.t, self.extra_tip_counts)
```
```    def test_fast_unifrac_one_sample(self):
""" fu one sample should match whole unifrac result, for env 'B'"""
# first get full unifrac matrix
res = fast_unifrac(self.t, self.env_counts)
dmtx, env_order =  res['distance_matrix']
```

```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,
```
```    def test_fast_unifrac(self):
"""Should calc unifrac values for whole tree."""
#Note: results not tested for correctness here as detailed tests
#in fast_tree module.
res = fast_unifrac(self.t, self.env_counts)
res = fast_unifrac(self.t, self.missing_env_counts)
res = fast_unifrac(self.t, self.extra_tip_counts)
```
```    def test_fast_unifrac_one_sample(self):
""" fu one sample should match whole unifrac result, for env 'B'"""
# first get full unifrac matrix
res = fast_unifrac(self.t, self.env_counts)
dmtx, env_order =  res['distance_matrix']
```

```import numpy
from cogent.util.unit_test import TestCase, main
from cogent.maths.unifrac.fast_unifrac import fast_unifrac
from qiime.parse import make_envs_dict
from qiime.beta_metrics import (_reorder_unifrac_res, make_unifrac_metric, make_unifrac_row_metric)
```
```        envs = make_envs_dict(self.l19_data, self.l19_sample_names,
self.l19_taxon_names)
unifrac_mat, unifrac_names = fast_unifrac(tree, envs,
modes=['distance_matrix'])['distance_matrix']
self.assertFloatEqual(res, _reorder_unifrac_res([unifrac_mat,
```

```from unittest import TestCase, main
from numpy.testing import assert_almost_equal
from cogent.maths.unifrac.fast_unifrac import fast_unifrac
from qiime.parse import make_envs_dict
from qiime.beta_metrics import (
```
```        envs = make_envs_dict(self.l19_data, self.l19_sample_names,
self.l19_taxon_names)
unifrac_mat, unifrac_names = fast_unifrac(tree, envs,
modes=['distance_matrix'])['distance_matrix']
assert_almost_equal(res, _reorder_unifrac_res([unifrac_mat,
```