from feature_table.artifact_types.feature_table import FeatureTable, Frequency
# this is temporarily in place for testing purposes
import biom
biom_path = "/Users/caporaso/code/q2d2/example-data/keyboard/q191/otu-table.tsv"
#table = biom.util.biom_open(open(biom_path))
table = biom.load_table(biom_path)
print(table.head(n=5))
# Constructed from biom file #OTU ID K3.H K3.Z M2.Middle.L K3.A K3.R New.CleanUp.ReferenceOTU0 2.0 0.0 0.0 0.0 0.0 New.CleanUp.ReferenceOTU1 0.0 1.0 6.0 1.0 1.0 New.CleanUp.ReferenceOTU3 0.0 0.0 0.0 0.0 0.0 New.CleanUp.ReferenceOTU6 0.0 0.0 0.0 0.0 0.0 New.CleanUp.ReferenceOTU7 0.0 0.0 0.0 0.0 0.0
from qiime.sdk.artifact import Artifact
Artifact.save(table, FeatureTable[Frequency], "nothing...", "./table.qtf")
!pwd
/Users/caporaso/Dropbox/code/feature-table/feature_table/workflows
a = Artifact('./table.qtf')
a
<qiime.sdk.artifact.Artifact at 0x10dd22438>
a.data
658 x 104 <class 'biom.table.Table'> with 5670 nonzero entries (8% dense)
a.uuid
UUID('6235ce1c-70e8-4559-b6a8-cdcbb6533d33')
a.provenance
'nothing...'
print(a.data.head(n=5))
# Constructed from biom file #OTU ID K3.H K3.Z M2.Middle.L K3.A K3.R New.CleanUp.ReferenceOTU0 2.0 0.0 0.0 0.0 0.0 New.CleanUp.ReferenceOTU1 0.0 1.0 6.0 1.0 1.0 New.CleanUp.ReferenceOTU3 0.0 0.0 0.0 0.0 0.0 New.CleanUp.ReferenceOTU6 0.0 0.0 0.0 0.0 0.0 New.CleanUp.ReferenceOTU7 0.0 0.0 0.0 0.0 0.0
a.type
FeatureTable[Frequency]
a.type.get_columns(a.data)[:5]
New.CleanUp.ReferenceOTU0 None New.CleanUp.ReferenceOTU1 None New.CleanUp.ReferenceOTU3 None New.CleanUp.ReferenceOTU6 None New.CleanUp.ReferenceOTU7 None dtype: object
a.type.get_values(a.data, 'New.CleanUp.ReferenceOTU0')[:5]
K3.H 2 K3.Z 0 M2.Middle.L 0 K3.A 0 K3.R 0 dtype: float64