With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

Book Description

Welcome to Scientific Python and its community. If you’re a scientist who programs with Python, this practical guide not only teaches you the fundamental parts of SciPy and libraries related to it, but also gives you a taste for beautiful, easy-to-read code that you can use in practice. You’ll learn how to write elegant code that’s clear, concise, and efficient at executing the task at hand.

Throughout the book, you’ll work with examples from the wider scientific Python ecosystem, using code that illustrates principles outlined in the book. Using actual scientific data, you’ll work on real-world problems with SciPy, NumPy, Pandas, scikit-image, and other Python libraries.

• Explore the NumPy array, the data structure that underlies numerical scientific computation
• Use quantile normalization to ensure that measurements fit a specific distribution
• Represent separate regions in an image with a Region Adjacency Graph
• Convert temporal or spatial data into frequency domain data with the Fast Fourier Transform
• Solve sparse matrix problems, including image segmentations, with SciPy’s sparse module
• Perform linear algebra by using SciPy packages
• Explore image alignment (registration) with SciPy’s optimize module
• Process large datasets with Python data streaming primitives and the Toolz library

1. Preface
1. Who Is This Book For?
2. Why SciPy?
3. The Great Cataclysm: Python 2 Versus Python 3
4. SciPy Ecosystem and Community
5. Getting Help
6. Installing Python
7. Diving In
8. Conventions Used in This Book
9. Use of Color
10. Using Code Examples
11. O’Reilly Safari
13. Acknowledgments
2. 1. Elegant NumPy: The Foundation of Scientific Python
1. Introduction to the Data: What Is Gene Expression?
2. NumPy N-Dimensional Arrays
3. Exploring a Gene Expression Dataset
4. Normalization
5. Taking Stock
3. 2. Quantile Normalization with NumPy and SciPy
1. Getting the Data
2. Gene Expression Distribution Differences Between Individuals
3. Biclustering the Counts Data
4. Visualizing Clusters
5. Predicting Survival
4. 3. Networks of Image Regions with ndimage
1. Images Are Just NumPy Arrays
2. Filters in Signal Processing
3. Filtering Images (2D Filters)
4. Generic Filters: Arbitrary Functions of Neighborhood Values
5. Graphs and the NetworkX library
7. Elegant ndimage: How to Build Graphs from Image Regions
8. Putting It All Together: Mean Color Segmentation
5. 4. Frequency and the Fast Fourier Transform
1. Introducing Frequency
2. Illustration: A Birdsong Spectrogram
3. History
4. Implementation
5. Choosing the Length of the DFT
6. More DFT Concepts
7. Real-World Application: Analyzing Radar Data
6. 5. Contingency Tables Using Sparse Coordinate Matrices
1. Contingency Tables
2. scipy.sparse Data Formats
3. Applications of Sparse Matrices: Image Transformations
4. Back to Contingency Tables
5. Contingency Tables in Segmentation
6. Information Theory in Brief
7. Information Theory in Segmentation: Variation of Information
8. Converting NumPy Array Code to Use Sparse Matrices
9. Using Variation of Information
7. 6. Linear Algebra in SciPy
1. Linear Algebra Basics
2. Laplacian Matrix of a Graph
3. Laplacians with Brain Data
4. PageRank: Linear Algebra for Reputation and Importance
5. Concluding Remarks
8. 7. Function Optimization in SciPy
1. Optimization in SciPy: scipy.optimize
2. Image Registration with Optimize
3. Avoiding Local Minima with Basin Hopping
4. “What Is Best?”: Choosing the Right Objective Function
9. 8. Big Data in Little Laptop with Toolz
1. Streaming with yield
2. Introducing the Toolz Streaming Library
3. k-mer Counting and Error Correction
4. Currying: The Spice of Streaming
5. Back to Counting k-mers
6. Markov Model from a Full Genome
10. Epilogue
1. Where to Next?
2. Beyond SciPy
3. Contributing to This Book
4. Until Next Time...
11. Appendix. Exercise Solutions
12. Index