Skip to content

Commit

Permalink
BLD: Add unifrac
Browse files Browse the repository at this point in the history
Thanks @mortonjt @wasade!

Add bypass-tips
  • Loading branch information
ElDeveloper committed Sep 21, 2017
1 parent fb0b28b commit e4aa0ef
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ install:
- conda create -q -n test-env --file https://raw.githubusercontent.com/qiime2/environment-files/master/latest/staging/qiime2-latest-conda-linux-64.txt
- source activate test-env
- conda install -q pytest-cov
# temporary solution while we get this into a permanent channel
- conda install -c mortonjt unifrac
- pip install -q flake8 coveralls
- pip install -q https://github.com/qiime2/q2lint/archive/master.zip
- make install
Expand Down
5 changes: 3 additions & 2 deletions q2_diversity/_beta/_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ def beta_phylogenetic(table: biom.Table, phylogeny: skbio.TreeNode,
def beta_phylogenetic_hpc(table: BIOMV210Format, phylogeny: NewickFormat,
metric: str, n_jobs: int=1,
variance_adjusted: bool=False,
alpha=1.0) -> skbio.DistanceMatrix:
alpha=1.0,
bypass_tips: bool=False) -> skbio.DistanceMatrix:
if metric == 'unweighted_unifrac':
f = unifrac.unweighted
elif metric == 'weighted_unnormalized_unifrac':
Expand All @@ -85,7 +86,7 @@ def beta_phylogenetic_hpc(table: BIOMV210Format, phylogeny: NewickFormat,

# unifrac processes tables and trees should be filenames
return f(str(table), str(phylogeny), threads=n_jobs,
variance_adjusted=variance_adjusted)
variance_adjusted=variance_adjusted, bypass_tips=bypass_tips)


def beta(table: biom.Table, metric: str, n_jobs: int=1)-> skbio.DistanceMatrix:
Expand Down
13 changes: 11 additions & 2 deletions q2_diversity/plugin_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
'generalized_unifrac']),
'n_jobs': Int,
'variance_adjusted': Bool,
'alpha': Float},
'alpha': Float, 'bypass_tips': Bool},
outputs=[('distance_matrix', DistanceMatrix % Properties('phylogenetic'))],
input_descriptions={
'table': ('The feature table containing the samples over which beta '
Expand All @@ -111,7 +111,16 @@
'generalized. The value of alpha controls importance of '
'sample proportions. 1.0 is weighted normalized UniFrac. '
'0.0 is close to unweighted UniFrac, but only if the sample '
'proportions are dichotomized.')
'proportions are dichotomized.'),
'bypass_tips': ('Compute will be reduced by ~50% with this option '
'yielding an approximate result. The option '
'disregards computing UniFrac at the tips of the '
'phylogeny and instead only computes it on the '
'internal nodes. In a bifurcating tree, the tips '
'correspond to approximately 50% of the vertices in '
'the tree, which is how the compute time reduction is'
' achieved. The use of this parameter is analogous '
'in concept to switching from 99% OTUs to 97% OTUs.')
},
output_descriptions={'distance_matrix': 'The resulting distance matrix.'},
name='Beta diversity (phylogenetic) - High Performance Computation',
Expand Down

0 comments on commit e4aa0ef

Please sign in to comment.