Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 11 additions & 26 deletions labs/04_machine-learning/04_PCA-analysis_key.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"metadata": {},
"source": [
"## Protein structures\n",
"+ Write a function that loads in the `x`, `y`, and `z` coordinates for all `CA` atoms from a pdb file."
"+ Write a function that loads in the `x`, `y`, and `z` coordinates for all `CA` atoms from a pdb file and returns all the coordinates in an numpy array. (Hint: the shape of this array should be (number-of-`CA`-atoms, 3).)"
]
},
{
Expand Down Expand Up @@ -64,9 +64,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"hm1 = load_pdb(\"homolog-1.pdb\")\n",
Expand All @@ -83,9 +81,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"plt.plot(hm1[:,0],hm1[:,1])\n",
Expand Down Expand Up @@ -120,15 +116,13 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"+ Plot the transformed coordinates on top of one another."
"+ Plot the first 2 transformed coordinates on top of one another."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"plt.plot(t_hm1[:,0],t_hm1[:,1])\n",
Expand All @@ -146,7 +140,6 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [],
Expand All @@ -166,9 +159,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"import pandas\n",
Expand All @@ -184,7 +175,7 @@
"pca_fit = pca.fit(X)\n",
"Q = pca_fit.transform(X)\n",
"\n",
"a = X.shape[0]/num_data_sets\n",
"a = int(X.shape[0]/num_data_sets)\n",
"for i in range(X.shape[1]):\n",
" plt.plot(X[(i*a):((i+1)*a),3],\n",
" X[(i*a):((i+1)*a),4],\"o\")\n",
Expand All @@ -210,9 +201,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"pca_fit.explained_variance_ratio_"
Expand Down Expand Up @@ -240,9 +229,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"for i in range(Q.shape[1]):\n",
Expand Down Expand Up @@ -310,9 +297,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"f = open(\"pca_dataset.csv\")\n",
Expand Down Expand Up @@ -341,7 +326,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
"version": "3.4.3"
}
},
"nbformat": 4,
Expand Down