55from qiime2 .plugins import diversity
66import pandas as pd
77
8- def ordinate (table ,
9- metadata = None ,
10- where = None ,
11- metric = 'jaccard' ,
12- sampling_depth = - 1 ,
13- phylogeny = None ,
14- number_of_dimensions = None ,
15- biplot = False ):
8+ def ordinate (table , metadata = None , metric = 'jaccard' , sampling_depth = - 1 ,
9+ phylogeny = None , number_of_dimensions = None , biplot = False ):
1610 """Perform ordination using principal coordinate analysis (PCoA).
1711
1812 This method wraps multiple QIIME 2 methods to perform ordination and
@@ -22,17 +16,16 @@ def ordinate(table,
2216 rarefying of the feature table (if requested), computes distance matrix,
2317 and then runs PCoA.
2418
25- By default, the method returns PCoAResults. For creating a biplot, make
26- sure to use `biplot=True` which returns PCoAResults % Properties('biplot').
19+ By default, the method returns PCoAResults. For creating a biplot,
20+ use `biplot=True` which returns PCoAResults % Properties('biplot').
2721
2822 Parameters
2923 ----------
3024 table : str or qiime2.Artifact
3125 Artifact file or object corresponding to FeatureTable[Frequency].
3226 metadata : str or qiime2.Metadata, optional
33- Metadata file or object.
34- where : str, optional
35- SQLite WHERE clause specifying sample metadata criteria.
27+ Metadata file or object. All samples in 'metadata' that are also in
28+ the feature table will be retained.
3629 metric : str, default: 'jaccard'
3730 Metric used for distance matrix computation ('jaccard',
3831 'bray_curtis', 'unweighted_unifrac', or 'weighted_unifrac').
@@ -71,21 +64,14 @@ def ordinate(table,
7164 else :
7265 raise TypeError (f"Incorrect feature table type: { type (table )} " )
7366
74- # Perform sample filtration.
75- if where :
76- if metadata is None :
77- m = "To use 'where' argument, you must provide metadata"
78- raise ValueError (m )
79- elif isinstance (metadata , str ):
80- _metadata = Metadata .load (metadata )
81- elif isinstance (metadata , qiime2 .Metadata ):
67+ # If metadata is provided, perform sample filtration.
68+ if metadata is not None :
69+ if isinstance (metadata , Metadata ):
8270 _metadata = metadata
8371 else :
84- raise TypeError (f"Incorrect metadata type: { type (metadata )} " )
85-
86- filter_result = feature_table .methods .filter_samples (
87- table = table , metadata = _metadata , where = where )
88- _table = filter_result .filtered_table
72+ _metadata = Metadata .load (metadata )
73+ _table = feature_table .methods .filter_samples (
74+ table = table , metadata = _metadata ).filtered_table
8975 else :
9076 _table = table
9177
0 commit comments