Summary and Schedule

Introduction to Data Analysis in Python

This is a 4-session introductory Python workshop hosted by the Center for Computational Biomedicine at Harvard Medical School.

Learning Objectives:

  • Apply fundamentals of Python programming including variables, expressions, loops, and conditional statements.
  • Create modular Python programs which handle file I/O, string manipulation, and object manipulation.
  • Manage Conda environments and lookup documentation to utilize built-in and 3rd party Python packages.
  • Manipulate data and objects using Python and Pandas.
  • Visualize data in Python using Matplotlib and Seaborn.

Participants will also be introduced to popular packages for machine learning and bioinformatics analyses in Python, and pointed towards resources to continue their learning.

Week 1 Schedule

Session 1: April 18 from 2:00pm - 4:00pm

Self-Guided Sessions 1

Session 2: April 20 from 2:00pm - 4:00pm

Week 2 Schedule

Session 3: April 25 from 2:00pm - 4:00pm

Self-Guided Sessions 3

Session 4: April 27 from 2:00pm - 4:00pm

Current status: Days 2 and 3 lessons still need a final pass for polish and small fixes.

  • We need to add instructions for using conda environments in jupyter
  • The plotting lesson (not pushed yet) has matplotlib but needs seaborn and some more biological examples like heatmaps.
  • The application example lessons on days 3 and 4 have not been started, though I have existing notebooks I’m planning to base them on.

Day 1

  • Introduction (20 min)
  • Variables (25 min)
  • Break (10 min)
  • Types (25 min)
  • Built-in functions (30 min)
  • Wrap-up (10 min)

At-home Lessons 1

  • Strings
  • Objects

Day 2

  • Lists (45 min)
  • Loops (25 min)
  • Break (10 min)
  • Libraries (20 min)
  • Loading Data (20 min)

At-home Lessons 2

  • Conda
  • Dictionaries

Day 3

  • Conditionals (35 min)
  • Dataframes (40 min)
  • Break (10 min)
  • Writing Functions (25 min)
  • Using scipy for statistics (10 min)

At-home Lessons 3

  • Data Wranging Practice
  • Preparing data for plotting

Day 4

  • Plotting with Seaborn and Matplotlib (60 min) half-done
  • Break (10 min)
  • Using scikit-learn for machine learning (20 min) half-done
  • Using BioMart get gene annotations (15 min) not started
  • Wrap-up and next steps (15 min)

Prerequisite

  • Please follow the steps found here to install the needed software and data for this workshop.

Materials for this workshop have been based on materials from the following:

Learn to Discover Basic Python

Programming with Python

Plotting and Programming with Python

Introduction to Conda for (Data) Scientists

Introduction to data analysis with R and Bioconductor

This lesson is made from the The Carpentries Workbench template.

The actual schedule may vary slightly depending on the topics and exercises chosen by the instructor.

Python 3


It is sometimes claimed that biologist should use Python 2, because most biology related libraries in Python are written for that version. This is wrong. The reason why Python 2 is still out there is that following the release of Python 3.0 in December 2008, the CPython interpreter sustained several problems, and was not backward compatible. This meant that, any code written in Python 2, could not be run using Python 3 without modifications. By now, Python 2 is obsolete. Do not use it.

Why Anaconda?


For the purpose of this course, we recommend the Anaconda distribution of Python released by the Python Software Foundation, and maintained by the Anaconda Cloud.

Anaconda automatically installs many packages needed for scientific purposes (over 250 automatically installed). It is easy to install, and it takes care of dependencies between packages. This is particularly important because some of Python’s scientific libraries require Fortran– and C–based libraries, which may be challenging to install for beginners.

Installation


To install the Anaconda distribution of Python, please visit the installation instructions as outlined in the Anaconda documentations, and follow the instructions for your operating system. Ensure that you use the Python 3.x graphical installer for Windows and MacOSX (there is no graphical installer for Linux). Once downloaded, you can proceed to install the distribution as you would any other application on your computer.

Anaconda Navigator is a desktop graphical user interface (GUI) included in Anaconda distribution that allows users to launch applications and manage conda packages, environments and channels without using command-line commands. Navigator can search for packages on Anaconda Cloud or in a local Anaconda Repository, install them in an environment, run the packages and update them. It is available for Windows, macOS and Linux.

The following applications are available by default in Navigator:

  • JupyterLab

  • Jupyter Notebook

  • QtConsole

  • Spyder

  • Glue

  • Orange

  • RStudio

  • Visual Studio Code

We recommend using JupyterLab for writing and practicing your codes.

Starting with JupyterLab

We will be going over how to use JupyterLab during our first session, but if you want to get started early here is an official video by Jupyter going over some uses and basic shortcuts in Jupyter Lab.