Created
March 8, 2016 20:50
-
-
Save gregcaporaso/edbe4135dd870bb606f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"from feature_table.artifact_types.feature_table import FeatureTable, Frequency" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"# this is temporarily in place for testing purposes\n", | |
"import biom\n", | |
"biom_path = \"/Users/caporaso/code/q2d2/example-data/keyboard/q191/otu-table.tsv\"\n", | |
"#table = biom.util.biom_open(open(biom_path))\n", | |
"table = biom.load_table(biom_path)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"# Constructed from biom file\n", | |
"#OTU ID\tK3.H\tK3.Z\tM2.Middle.L\tK3.A\tK3.R\n", | |
"New.CleanUp.ReferenceOTU0\t2.0\t0.0\t0.0\t0.0\t0.0\n", | |
"New.CleanUp.ReferenceOTU1\t0.0\t1.0\t6.0\t1.0\t1.0\n", | |
"New.CleanUp.ReferenceOTU3\t0.0\t0.0\t0.0\t0.0\t0.0\n", | |
"New.CleanUp.ReferenceOTU6\t0.0\t0.0\t0.0\t0.0\t0.0\n", | |
"New.CleanUp.ReferenceOTU7\t0.0\t0.0\t0.0\t0.0\t0.0\n" | |
] | |
} | |
], | |
"source": [ | |
"print(table.head(n=5))" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"from qiime.sdk.artifact import Artifact" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"Artifact.save(table, FeatureTable[Frequency], \"nothing...\", \"./table.qtf\")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"/Users/caporaso/Dropbox/code/feature-table/feature_table/workflows\r\n" | |
] | |
} | |
], | |
"source": [ | |
"!pwd" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"a = Artifact('./table.qtf')" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 8, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"<qiime.sdk.artifact.Artifact at 0x10dd22438>" | |
] | |
}, | |
"execution_count": 8, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"a" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 9, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"658 x 104 <class 'biom.table.Table'> with 5670 nonzero entries (8% dense)" | |
] | |
}, | |
"execution_count": 9, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"a.data" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 10, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"UUID('6235ce1c-70e8-4559-b6a8-cdcbb6533d33')" | |
] | |
}, | |
"execution_count": 10, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"a.uuid" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 11, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"'nothing...'" | |
] | |
}, | |
"execution_count": 11, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"a.provenance" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 12, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"# Constructed from biom file\n", | |
"#OTU ID\tK3.H\tK3.Z\tM2.Middle.L\tK3.A\tK3.R\n", | |
"New.CleanUp.ReferenceOTU0\t2.0\t0.0\t0.0\t0.0\t0.0\n", | |
"New.CleanUp.ReferenceOTU1\t0.0\t1.0\t6.0\t1.0\t1.0\n", | |
"New.CleanUp.ReferenceOTU3\t0.0\t0.0\t0.0\t0.0\t0.0\n", | |
"New.CleanUp.ReferenceOTU6\t0.0\t0.0\t0.0\t0.0\t0.0\n", | |
"New.CleanUp.ReferenceOTU7\t0.0\t0.0\t0.0\t0.0\t0.0\n" | |
] | |
} | |
], | |
"source": [ | |
"print(a.data.head(n=5))" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 13, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"FeatureTable[Frequency]" | |
] | |
}, | |
"execution_count": 13, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"a.type" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 18, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"New.CleanUp.ReferenceOTU0 None\n", | |
"New.CleanUp.ReferenceOTU1 None\n", | |
"New.CleanUp.ReferenceOTU3 None\n", | |
"New.CleanUp.ReferenceOTU6 None\n", | |
"New.CleanUp.ReferenceOTU7 None\n", | |
"dtype: object" | |
] | |
}, | |
"execution_count": 18, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"a.type.get_columns(a.data)[:5]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 16, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"K3.H 2\n", | |
"K3.Z 0\n", | |
"M2.Middle.L 0\n", | |
"K3.A 0\n", | |
"K3.R 0\n", | |
"dtype: float64" | |
] | |
}, | |
"execution_count": 16, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"a.type.get_values(a.data, 'New.CleanUp.ReferenceOTU0')[:5]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.5.1" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment