Graphics & Plots: matplotlib & pylab

Slides:



Advertisements
Similar presentations
Week 1 basic Python programs, defining functions Special thanks to Scott Shawcroft, Ryan Tucker, and Paul Beck for their work on these slides. Except where.
Advertisements

SW318 Social Work Statistics Slide 1 Using SPSS for Graphic Presentation  Various Graphics in SPSS  Pie chart  Bar chart  Histogram  Area chart 
Assumption of Homoscedasticity
INTRODUCTION TO PYTHON PART 5 - GRAPHICS CSC482 Introduction to Text Analytics Thomas Tiahrt, MA, PhD.
SW388R7 Data Analysis & Computers II Slide 1 Analyzing Missing Data Introduction Problems Using Scripts.
Python plotting for lab folk Only the stuff you need to know to make publishable figures of your data. For all else: ask Sourish.
Recitation 1 Programming for Engineers in Python.
Quantitative Research in Education Sohee Kang Ph.D., lecturer Math and Statistics Learning Centre.
R-Graphics Day 2 Stephen Opiyo. Basic Graphs One of the main reasons data analysts turn to R is for its strong graphic capabilities. R generates publication-ready.
Yuval Hart, Weizmann 2010© 1 Introduction to Matlab & Data Analysis Tutorial 13: That’s all, Folks! Please change directory to directory E:\Matlab (cd.
The R Language How to find scientific truths buried between the spots.
732A44 Programming in R.  Self-studies of the course book  2 Lectures (1 in the beginning, 1 in the end)  Labs (computer). Compulsory submission of.
BIF Group Project Group (A)rabidopsis: David Nieuwenhuijse Matthew Price Qianqian Zhang Thijs Slijkhuis Species: C. Elegans Project: Advanced.
Introduction to Python By Neil Cook Twitter: njcuk Slides/Notes:
Copyright OpenHelix. No use or reproduction without express written consent1.
Instruction Guides for David Howell’s Textbook Examples Boxplots and Stem-and-Leaf Plots Sign Test using the Binomial Distribution.
Introduction to MATLAB Damon Tomlin February 22, 2008 Lecture 3: Data Visualization & User Interfaces.
Introduction to Biostatistics and Bioinformatics Exploring Data and Descriptive Statistics.
Simulation. Downloads  Today’s work is in: matlab_lec03.m  Datasets we need today: data_msft.m.
Math 15 Lecture 9 University of California, Merced Scilab A Short Introduction – No. 3 Today – Quiz #4.
Learning R hands on. Organization of Folders: Class Data folder has datasets (end in.csv or.rda) Rcode has the scripts of R commands that can cut and.
9/23/2015BCHB Edwards Advanced Python Data Structures BCHB Lecture 7.
Week 1 basic Python programs, defining functions Special thanks to Scott Shawcroft, Ryan Tucker, and Paul Beck for their work on these slides. Except where.
9/28/2015BCHB Edwards Basic Python Review BCHB Lecture 8.
R-Graphics Stephen Opiyo. Basic Graphs One of the main reasons data analysts turn to R is for its strong graphic capabilities. R generates publication-ready.
Unit 1 Basic Python programs, functions Special thanks to Roy McElmurry, John Kurkowski, Scott Shawcroft, Ryan Tucker, Paul Beck for their work. Except.
OCR Computing GCSE © Hodder Education 2013 Slide 1 OCR GCSE Computing Python programming 4: Writing programs.
You Need an Interpreter!. Closing the GAP Thus far, we’ve been struggling to speak to computers in “their” language, maybe its time we spoke to them in.
1 Installing Cantera 1.7, Python 2.5, and Python SDToolbox for Windows J. Ziegler, S. Browne, and J. E. Shepherd Caltech Revised August, 2007.
9/2/2015BCHB Edwards Introduction to Python BCHB524 Lecture 1.
Practical Kinetics Exercise 0: Getting Started Objectives: 1.Install Python and IPython Notebook 2.print “Hello World!”
Matplotlib SANTHOSH Boggarapu.
Xi Wang Yang Zhang. 1. Easy to learn 2. Clean and readable codes 3. A lot of useful packages, especially for web scraping and text mining 4. Growing popularity.
Introduction to CADStat. CADStat and R R is a powerful and free statistical package [
9/11/2015BCHB Edwards Introduction to Python BCHB Lecture 3.
Python Lab Matplotlib - I Proteomics Informatics, Spring 2014 Week 9 25 th Mar, 2014
Graphics & Plots: matplotlib & pylab BCHB Lecture 24 11/30/2015BCHB Edwards.
Introducing Tim Sheerman-Chase This work is licensed under a Creative Commons Attribution 3.0 Unported License 28 th Sept 2011.
Relational Databases: Basic Concepts
Supplementary figure 5.
Graphics & Plots: matplotlib & pylab
Introduction to Python
Using Local Tools: BLAST
Module 5 Working with Data
Advanced Python Data Structures
Introduction to Python
Advanced Python Data Structures
Introduction to Python
Introduction to Python
basic Python programs, defining functions
Univariate Data Exploration
basic Python programs, defining functions
The Laptop Instrument Meeting 2 January 22, 2018.
Basic Python Review BCHB524 Lecture 8 BCHB524 - Edwards.
Measuring Variation 2 Lecture 17 Sec Mon, Oct 3, 2005.
Lecture 01: Introduction
Advanced Python Concepts: Exceptions
Advanced Python Data Structures
Relational Databases: Basic Concepts
Using Local Tools: BLAST
Basic Python Review BCHB524 Lecture 8 BCHB524 - Edwards.
Advanced Python Concepts: Exceptions
Introduction to Python
Using Local Tools: BLAST
Graphics & Plots: matplotlib & pylab
Assignment 1: Classification by K Nearest Neighbors (KNN) technique
Numpy, pylab, matplotlib (follow-up)
Matplotlib and Pandas
Installations for Course
Installations for Course
Presentation transcript:

Graphics & Plots: matplotlib & pylab BCHB524 Lecture 24 BCHB524 - Edwards

Outline Testing pylab Download data Basic plots Exercises scatter plots, histograms, boxplots Exercises BCHB524 - Edwards

Test the pylab installation Create the python script shown on the right python test_pylab.py test_pylab.py from pylab import * x = randn(10000) hist(x, 100) show() BCHB524 - Edwards

Download some data Download the data and the module for handling it, from the course homepage data.txt, data.py Take a look! Open data.txt in a text-editor (IDLE or notepad) Run look.py look.py from data import * print genes print data['AA055368'] print t1data['AA055368'] BCHB524 - Edwards

Scatter plot Use the plot function for a scatter plot list of values x vs y Choose to plot dots or lines with last argument '.' for dots '-' for lines (default) scatter_plot1.py from pylab import * from data import * plot(data['AA055368']) show() scatter_plot2.py from pylab import * from data import * plot(data['AA055368'],      data['R31679'],'.') show() BCHB524 - Edwards

Heatmap Use the pcolor function for a heatmap Choose colormap heatmap1.py from pylab import * from data import * pcolor(tmdata) show() Use the pcolor function for a heatmap list of lists, or numpy 2-D matrix Choose colormap cool() hot() Lots of tweaking options to make it look just right from pylab import * from data import * pcolor(tmdata) clim((-6,6)) gci().set_cmap(cm.RdYlGn) colorbar() ylim([nsmpl,0]) axis('tight') xlabel('Gene') ylabel('Sample') show() # savefig('colormap.png',dpi=150) heatmap2.py BCHB524 - Edwards

Histogram & Boxplot Use the hist function for a histogram list of values number of bins Use the boxplot function for a boxplot useful for comparing distributions list of list of values hist_plot1.py from pylab import * from data import * hist(data['AA055368']) show() hist_plot2.py from pylab import * from data import * hist(data['AA055368'],5) show() box_plot.py from pylab import * from data import * boxplot([t1data['AA055368'],          t2data['AA055368']]) show() BCHB524 - Edwards

Check out the matplotlib gallery! BCHB524 - Edwards

Lets analyze this dataset! Find differentially expressed genes! differential.py from pylab import * from data import * g2t = {} for g in genes:     g2t[g] = tstatistic(t1data[g],t2data[g]) x = g2t.values() hist(x) show() bytstat = sorted(genes,key=g2t.get) print "Min:", bytstat[0], min(x) print "Max:", bytstat[-1], max(x) BCHB524 - Edwards

Lets analyze this dataset! Find differentially expressed genes! differential1.py from pylab import * from data import * g2t = {} for g in genes:     g2t[g] = tstatistic(t1data[g],t2data[g])      bytstat = sorted(genes,key=g2t.get) gene = bytstat[0] boxplot([t1data[gene],t2data[gene]]) title(gene) show() BCHB524 - Edwards

Find correlated genes correlated.py from pylab import * from data import * gp2rho = {} for i in range(ngene):     for j in range(i+1,ngene):         gi = genes[i]         gj = genes[j]         gp2rho[(gi,gj)] = corrcoef(data[gi],data[gj])[0,1] hist(gp2rho.values()) show() sx = sorted(gp2rho.keys(),key=gp2rho.get) print sx[0],sx[-1] BCHB524 - Edwards

Find correlated genes correlated1.py from pylab import * from data import * gp2rho = {} for i in range(ngene):     for j in range(i+1,ngene):         gi = genes[i]         gj = genes[j]         gp2rho[(gi,gj)] = corrcoef(data[gi],data[gj])[0,1] sx = sorted(gp2rho.keys(),key=gp2rho.get) bestpair = sx[-1] gi = bestpair[0] gj = bestpair[1] plot(data[gi],data[gj],'.') show() BCHB524 - Edwards

Exercises Try each of the examples shown in these slides. Check out the gallery of figures on the matplotlib web-site. Write a program to plot the GC % of 20-mer DNA windows from a DNA sequence. BCHB524 - Edwards