Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loads tree in NewickFormat, uses BP to parse tree faster #42

Merged
merged 9 commits into from
Apr 4, 2021
10 changes: 9 additions & 1 deletion gemelli/rpca.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@
DEFAULT_OPTSPACE_ITERATIONS,
DEFAULT_MFF)
from scipy.linalg import svd
from q2_types.tree import NewickFormat
from bp import parse_newick, to_skbio_treenode
from empress._plot_utils import get_bp


def phylogenetic_rpca(table: biom.Table,
phylogeny: TreeNode,
phylogeny: NewickFormat,
n_components: Union[int, str] = DEFAULT_COMP,
min_sample_count: int = DEFAULT_MSC,
min_feature_count: int = DEFAULT_MFC,
Expand All @@ -39,6 +42,11 @@ def phylogenetic_rpca(table: biom.Table,
gemelli.
"""

# loads NewickFormat tree as bp.BP tree; loads & parses tree faster
phylogeny = get_bp(phylogeny)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_bp is only like two lines and it is pretty easy to get burned by importing from private modules in python. I would probably recommend just duplicating that code here.

ahdilmore marked this conversation as resolved.
Show resolved Hide resolved
phylogeny = phylogeny.shear(set((table.ids('observation')).flatten()))
phylogeny = to_skbio_treenode(phylogeny)
ahdilmore marked this conversation as resolved.
Show resolved Hide resolved

# use helper to process table
table = rpca_table_processing(table,
min_sample_count,
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ def run(self):
'scikit-learn >= 0.18.1',
'scikit-bio > 0.5.3',
'biom-format',
'h5py', ],
'h5py',
'iow',],
classifiers=classifiers,
entry_points={'qiime2.plugins': q2cmds,
'console_scripts': standalone},
Expand Down