{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# E164: Introduction to Biological System Design\n", "## Introduction to Biological Data Analysis\n", "### Ayush Pandey\n", "\n", "If you have not setup your computer to run this notebook, make sure to follow steps here: https://docs.google.com/document/d/1js7XQbjorU5LCIoWfrzkUCXjjQkVcITkT0N8osiy4Go/edit?usp=sharing\n", "\n", "The purpose of this interactive Python notebook is to introduce basic data analysis tools available in Python with the help of biological data examples.\n", "\n", "If you have installed numpy, scipy, matplotlib, and pandas already, then you are all set to run this notebook." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Data Analysis with Python\n", "## Introduction to Pandas\n", "\n", "You can think of Pandas as the Python data-management library. It can be used to manage large quantities of data in a structured way so you don't get lost and provides functions to retreive/store/edit your data so that it is easily interfaced with numerical, scientific, and plotting libraries.\n", "\n", "More information on Pandas here: https://pandas.pydata.org/pandas-docs/stable/\n", "\n", "Data is often stored as .csv files. Here's how to import a CSV file with Pandas and structure the data as desired." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "\n", "url = 'https://raw.githubusercontent.com/biocircuits/bioscrape/master/inference%20examples/data/od_data.csv'\n", "# To import a CSV file, you can use the `read_csv` function. \n", "# Either provide a URL as its input or a string of address to the CSV file on your local machine.\n", "df = pd.read_csv(url)\n", "# You get a \"dataframe\" object out that contains all of the data in the CSV file" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### In an IPYNB (like this one), the Pandas dataframes are nicely formatted:" ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | Time | \n", "t | \n", "A1 | \n", "A2 | \n", "A3 | \n", "A4 | \n", "A5 | \n", "A6 | \n", "A7 | \n", "A8 | \n", "A9 | \n", "A10 | \n", "A11 | \n", "A12 | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "0:09:19 | \n", "9.32 | \n", "0.086 | \n", "0.087 | \n", "0.088 | \n", "0.095 | \n", "0.091 | \n", "0.089 | \n", "0.090 | \n", "0.085 | \n", "0.090 | \n", "0.090 | \n", "0.088 | \n", "0.091 | \n", "
1 | \n", "0:19:19 | \n", "19.32 | \n", "0.086 | \n", "0.090 | \n", "0.089 | \n", "0.090 | \n", "0.091 | \n", "0.092 | \n", "0.091 | \n", "0.086 | \n", "0.092 | \n", "0.092 | \n", "0.088 | \n", "0.090 | \n", "
2 | \n", "0:29:19 | \n", "29.32 | \n", "0.086 | \n", "0.088 | \n", "0.090 | \n", "0.089 | \n", "0.089 | \n", "0.092 | \n", "0.093 | \n", "0.087 | \n", "0.089 | \n", "0.093 | \n", "0.089 | \n", "0.092 | \n", "
3 | \n", "0:39:19 | \n", "39.32 | \n", "0.088 | \n", "0.090 | \n", "0.091 | \n", "0.090 | \n", "0.092 | \n", "0.093 | \n", "0.096 | \n", "0.088 | \n", "0.091 | \n", "0.093 | \n", "0.090 | \n", "0.094 | \n", "
4 | \n", "0:49:19 | \n", "49.32 | \n", "0.089 | \n", "0.092 | \n", "0.093 | \n", "0.092 | \n", "0.094 | \n", "0.096 | \n", "0.099 | \n", "0.091 | \n", "0.093 | \n", "0.094 | \n", "0.094 | \n", "0.096 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
68 | \n", "11:29:19 | \n", "689.32 | \n", "0.543 | \n", "0.562 | \n", "0.614 | \n", "0.604 | \n", "0.573 | \n", "0.566 | \n", "0.615 | \n", "0.572 | \n", "0.570 | \n", "0.566 | \n", "0.568 | \n", "0.606 | \n", "
69 | \n", "11:39:19 | \n", "699.32 | \n", "0.543 | \n", "0.563 | \n", "0.615 | \n", "0.605 | \n", "0.574 | \n", "0.568 | \n", "0.616 | \n", "0.572 | \n", "0.570 | \n", "0.568 | \n", "0.569 | \n", "0.607 | \n", "
70 | \n", "11:49:19 | \n", "709.32 | \n", "0.545 | \n", "0.564 | \n", "0.616 | \n", "0.606 | \n", "0.574 | \n", "0.569 | \n", "0.617 | \n", "0.575 | \n", "0.572 | \n", "0.568 | \n", "0.570 | \n", "0.608 | \n", "
71 | \n", "11:59:19 | \n", "719.32 | \n", "0.544 | \n", "0.565 | \n", "0.617 | \n", "0.607 | \n", "0.575 | \n", "0.570 | \n", "0.618 | \n", "0.576 | \n", "0.573 | \n", "0.570 | \n", "0.570 | \n", "0.609 | \n", "
72 | \n", "12:09:19 | \n", "729.32 | \n", "0.544 | \n", "0.566 | \n", "0.618 | \n", "0.608 | \n", "0.576 | \n", "0.571 | \n", "0.619 | \n", "0.577 | \n", "0.574 | \n", "0.570 | \n", "0.571 | \n", "0.610 | \n", "
73 rows × 14 columns
\n", "