practical bioinformatics
play

Practical Bioinformatics Mark Voorhies 5/15/2015 Mark Voorhies - PowerPoint PPT Presentation

Practical Bioinformatics Mark Voorhies 5/15/2015 Mark Voorhies Practical Bioinformatics Gotchas Indentation matters Mark Voorhies Practical Bioinformatics Clustering exercises Visualizing the distance matrix Mark Voorhies Practical


  1. Practical Bioinformatics Mark Voorhies 5/15/2015 Mark Voorhies Practical Bioinformatics

  2. Gotchas Indentation matters Mark Voorhies Practical Bioinformatics

  3. Clustering exercises – Visualizing the distance matrix Mark Voorhies Practical Bioinformatics

  4. Loading and re-loading your functions # Use import the f i r s t time you load a module # (And keep using import u n t i l i t loads # s u c c e s s f u l l y ) import my module my module . my function (42) # Once a module has been loaded , use r e l o a d to # f o r c e python to read your new code reload ( my module ) Mark Voorhies Practical Bioinformatics

  5. Setting Canopy’s working/import directory OS X Open a terminal cd path/to/working/directory env PYTHONPATH=”$PYTHONPATH:$PWD” canopy Windows (or OS X) Start canopy %cd path/to/working/directory import sys, os sys.path.append(os.getcwd()) Mark Voorhies Practical Bioinformatics

  6. Pearson distances Pearson similarity N s ( x , y ) = 1 � x i − x offset � � y i − y offset � � N φ x φ y i � N � ( G i − G offset ) 2 � � φ G = � N i Mark Voorhies Practical Bioinformatics

  7. Pearson distances Pearson similarity N � x i − x offset � � y i − y offset � � s ( x , y ) = φ x φ y i � N � � � ( G i − G offset ) 2 φ G = � i Mark Voorhies Practical Bioinformatics

  8. Pearson distances Pearson similarity     N x i − x offset y i − y offset � s ( x , y ) =     �� N �� N i ( x i − x offset ) 2 i ( y i − y offset ) 2 i Mark Voorhies Practical Bioinformatics

  9. Pearson distances Pearson similarity � N i ( x i − x offset )( y i − y offset ) s ( x , y ) = �� N �� N i ( x i − x offset ) 2 i ( y i − y offset ) 2 Mark Voorhies Practical Bioinformatics

  10. Pearson distances Pearson similarity � N i ( x i − x offset )( y i − y offset ) s ( x , y ) = �� N �� N i ( x i − x offset ) 2 i ( y i − y offset ) 2 Pearson distance d uncentered ( x , y ) = 1 − s ( x , y ) Mark Voorhies Practical Bioinformatics

  11. Pearson distances Pearson similarity � N i ( x i − x offset )( y i − y offset ) s ( x , y ) = �� N �� N i ( x i − x offset ) 2 i ( y i − y offset ) 2 Pearson distance d uncentered ( x , y ) = 1 − s ( x , y ) Euclidean distance � N i ( x i − y i ) 2 N Mark Voorhies Practical Bioinformatics

  12. Clustering exercises – Negative controls Write functions to reproduce the shuffling controls in figure 3 of the Eisen paper (removing correlations among genes and/or arrays). Mark Voorhies Practical Bioinformatics

  13. Clustering exercises – Negative controls Write functions to reproduce the shuffling controls in figure 3 of the Eisen paper (removing correlations among genes and/or arrays). s h u f f l e G e n e s ( s e l f , seed = None ) : def ””” S h u f f l e e x p r e s s i o n matrix by row . ””” random import i f ( seed != None ) : random . seed ( seed ) i n d i c e s = range ( len ( s e l f . genes ) ) random . s h u f f l e ( i n d i c e s ) genes = [ s e l f . geneName [ i ] f o r i i n i n d i c e s ] s e l f . geneName = genes a n n o t a t i o n s = [ s e l f . geneAnn [ i ] f o r i i n i n d i c e s ] s e l f . geneAnn = genes num = [ s e l f . num [ i ] f o r i i n i n d i c e s ] s e l f . num = num Mark Voorhies Practical Bioinformatics

  14. Clustering exercises – Negative controls Write functions to reproduce the shuffling controls in figure 3 of the Eisen paper (removing correlations among genes and/or arrays). Mark Voorhies Practical Bioinformatics

  15. Clustering exercises – Negative controls Write functions to reproduce the shuffling controls in figure 3 of the Eisen paper (removing correlations among genes and/or arrays). def shuffleRows ( s e l f , seed = None ) : ””” Permute r a t i o v a l u e s w i t h i n rows . ””” import random i f ( seed != None ) : random . seed ( seed ) i s e l f . num : f o r i n random . s h u f f l e ( i ) Mark Voorhies Practical Bioinformatics

  16. Clustering exercises – Negative controls Write functions to reproduce the shuffling controls in figure 3 of the Eisen paper (removing correlations among genes and/or arrays). def shuffleRows ( s e l f , seed = None ) : ””” Permute r a t i o v a l u e s w i t h i n rows . ””” import random i f ( seed != None ) : random . seed ( seed ) i s e l f . num : f o r i n random . s h u f f l e ( i ) s h u f f l e C o l s ( s e l f , seed = None ) : def ””” Permute r a t i o v a l u e s w i t h i n columns . ””” random import i f ( seed != None ) : random . seed ( seed ) # Transpose the e x p r e s s i o n matrix c o l s = [ ] f o r c o l i n xrange ( len ( s e l f . num [ 0 ] ) ) : c o l s . append ( [ row [ c o l ] f o r row i n s e l f . num ] ) # S h u f f l e f o r i i n c o l s : random . s h u f f l e ( i ) # Transpose back to o r i g i n a l o r i e n t a t i o n s e l f . num = [ ] f o r row i n xrange ( len ( c o l s ) ) : s e l f . num . append ( [ c o l [ row ] f o r c o l i n row ] ) Mark Voorhies Practical Bioinformatics

  17. Comparing all measurements for two genes Comparing two expression profiles (r = 0.97) ● ● 5 ● ● ● YFG1 log2 relative expression ● ● ● ● ● ● ● ● ● ● ● 0 ● ● ● ● ● ● ● ● ● −5 ● ● ● ● ● −5 0 5 TLC1 log2 relative expression Mark Voorhies Practical Bioinformatics

  18. Comparing all genes for two measurements ● ● ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● Array 2, log2 relative expression ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 0 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● −5 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● −10 ● ● −10 −5 0 5 10 Array 1, log2 relative expression Mark Voorhies Practical Bioinformatics

  19. Comparing all genes for two measurements Euclidean Distance ● ● ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● Array 2, log2 relative expression ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 0 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● −5 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● −10 ● ● −10 −5 0 5 10 Array 1, log2 relative expression Mark Voorhies Practical Bioinformatics

  20. Comparing all genes for two measurements Uncentered Pearson ● ● ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● Array 2, log2 relative expression ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 0 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● −5 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● −10 ● ● −10 −5 0 5 10 Array 1, log2 relative expression Mark Voorhies Practical Bioinformatics

  21. Measure all pairwise distances under distance metric Mark Voorhies Practical Bioinformatics

  22. Hierarchical Clustering Mark Voorhies Practical Bioinformatics

  23. Hierarchical Clustering Mark Voorhies Practical Bioinformatics

  24. Hierarchical Clustering Mark Voorhies Practical Bioinformatics

  25. Hierarchical Clustering Mark Voorhies Practical Bioinformatics

  26. Hierarchical Clustering Mark Voorhies Practical Bioinformatics

  27. Scripting Cluster Running Cluster3 from the command line /Applications/Cluster.app/Contents/MacOS/Cluster /Program Files/Stanford University/Cluster3/Cluster.com Command-line programs are like functions “man program” is like “help(function)” Use the subprocess module to run command-line programs from within Python. Mark Voorhies Practical Bioinformatics

  28. Programs as functions USAGE: cluster [options] -f filename File loading -u jobname Allows you to specify a different name for the output files (default is derived from the input file name) -g [0..8] Specifies the distance measure for gene clustering 0: No gene clustering 1: Uncentered correlation 2: Pearson correlation 3: Uncentered correlation, absolute value 4: Pearson correlation, absolute value 5: Spearman’s rank correlation 6: Kendall’s tau 7: Euclidean distance 8: City-block distance (default: 0) -m [msca] Specifies which hierarchical clustering method to use m: Pairwise complete-linkage s: Pairwise single-linkage c: Pairwise centroid-linkage a: Pairwise average-linkage (default: m) Mark Voorhies Practical Bioinformatics

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend