| Preface | p. vii |
| 1 Elegant NumPy: The Foundation of Scientific Python | p. 1 |
| Introduction to the Data: What Is Gene Expression? | p. 2 |
| NumPy N-Dimenstional Arrays | p. 6 |
| Why Use ndarrays Instead of Python Lists? | p. 8 |
| Vectorization | p. 10 |
| Broadcasting | p. 10 |
| Exploring a Gene Expression Dataset | p. 12 |
| Reading in the Data with pandas | p. 12 |
| Normalization | p. 14 |
| Between Samples | p. 14 |
| Between Genes | p. 21 |
| Normalizing Over Samples and Genes: RPKM | p. 24 |
| Taking Stock | p. 30 |
| 2 Quantile Normalization with NumPy and SciPy | p. 31 |
| Getting the Data | p. 33 |
| Gene Expression Distribution Differences Between Individuals | p. 34 |
| Biclustering the Counts Data | p. 37 |
| Visualizing Clusters | p. 39 |
| Predicting Survival | p. 42 |
| Further Work: Using the TCGA's Patient Clusters | p. 46 |
| Further Work: Reproducing the TCGA's clusters | p. 46 |
| 3 Networks of Image Regions with ndimage | p. 49 |
| Images Are Just NumPy Arrays | p. 50 |
| Exercise: Adding a Grid Overlay | p. 55 |
| Filters in Signal Processing | p. 56 |
| Filtering Images (2D Filters) | p. 63 |
| Generic Filters: Arbitrary Functions of Neighborhood Values | p. 66 |
| Exercise: Conway's Game of Life | p. 67 |
| Exercise: Sobel Gradient Magnitude | p. 68 |
| Graphs and the NetworkX library | p. 68 |
| Exercise: Curve Fitting with SciPy | p. 72 |
| Region Adjacency Graphs | p. 73 |
| Elegant ndimage: How to Build Graphs from Image Regions | p. 76 |
| Putting It All Together: Mean Color Segmentation | p. 78 |
| 4 Frequency and the Fast Fourier Transform | p. 81 |
| Introducing Frequency | p. 81 |
| Illustration: A Birdsong Spectrogram | p. 84 |
| History | p. 90 |
| Implementation | p. 91 |
| Choosing the Length of the DFT | p. 92 |
| More DFT Concepts | p. 94 |
| Frequencies and Their Ordering | p. 94 |
| Windowing | p. 100 |
| Real-World Application; Analyzing Radar Data | p. 105 |
| Signal Properties in the Frequency Domain | p. 111 |
| Windowing, Applied | p. 115 |
| Radar Images | p. 117 |
| Further Applications of the EFT | p. 122 |
| Further Reading | p. 122 |
| Exercise: Image Convolution | p. 123 |
| 5 Contingency Tables Using Sparse Coordinate Matrices | p. 125 |
| Contingency Tables | p. 127 |
| Exercise: Computational Complexity of Confusion Matrices | p. 128 |
| Exercise: Alternative Algorithm to Compute the Confusion Matrix | p. 128 |
| Exercise: Multiclass Confusion Matrix | p. 128 |
| Scipy.sparse Data Formats | p. 129 |
| COO Format | p. 129 |
| Exercise: COO Representation | p. 130 |
| Compressed Sparse Row Format | p. 130 |
| Applications of Sparse Matrices: Image Transformations | p. 133 |
| Exercise: Image Rotation | p. 138 |
| Back to Contingency Tables | p. 139 |
| Exercise: Reducing the Memory Footprint | p. 140 |
| Contingency Tables in Segmentation | p. 140 |
| Information Theory in Brief | p. 142 |
| Exercise: Computing Conditional Entropy | p. 144 |
| Information Theory in Segmentation: Variation of Information | p. 145 |
| Converting NumPy Array Code to Use Sparse Matrices | p. 147 |
| Using Variation of Information | p. 149 |
| Further Work: Segmentation in Practice | p. 156 |
| 6 Linear Algebra in SciPy | p. 157 |
| Linear Algebra Basics | p. 157 |
| Laplacian Matrix of a Graph | p. 158 |
| Exercise: Rotation Matrix | p. 159 |
| Laplacians with Brain Data | p. 165 |
| Exercise: Showing the Affinity View | p. 170 |
| Exercise Challenge: Linear Algebra with Sparse Matrices | p. 170 |
| PageRank: Linear Algebra for Reputation and Importance | p. 171 |
| Exercise: Dealing with Dangling Nodes | p. 176 |
| Exercise: Equivalence of Different Eigenvector Methods | p. 176 |
| Concluding Remarks | p. 176 |
| 7 Function Optimization in SciPy | p. 177 |
| Optimization in SciPy: scipy.optimize | p. 179 |
| An Example: Computing Optimal Image Shift | p. 180 |
| Image Registration with Optimize | p. 186 |
| Avoiding Local Minima with Basin flopping | p. 190 |
| Exercise: Modify the align Function | p. 190 |
| "What Is Best?": Choosing the Right Objective Function | p. 191 |
| 8 Big Data in Little Laptop with Toolz | p. 199 |
| Streaming with yield | p. 200 |
| Introducing the Toolz Streaming Library | p. 203 |
| k-mer Counting and Error Correction | p. 206 |
| Currying: The Spice of Streaming | p. 210 |
| Back to Counting k-mers | p. 212 |
| Exercise: PCA of Streaming Data | p. 214 |
| Markov Model from a Full Genome | p. 214 |
| Exercise: Online Unzip | p. 217 |
| Epilogue | p. 221 |
| Appendix: Exercise Solutions | p. 225 |
| Index | p. 247 |