100% found this document useful (2 votes)
39 views

Hands on Data Science for Biologists Using Python 1st Edition Yasha Hasija pdf download

The document is a promotional material for the book 'Hands-On Data Science for Biologists Using Python' by Yasha Hasija and Rajkumar Chakraborty, published by CRC Press in 2021. It includes links to download the book and other related titles, along with a detailed table of contents outlining various chapters covering Python programming, data analysis, visualization, and machine learning applications in biology. The book aims to provide biologists with practical skills in data science using Python.

Uploaded by

metrefberkta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
39 views

Hands on Data Science for Biologists Using Python 1st Edition Yasha Hasija pdf download

The document is a promotional material for the book 'Hands-On Data Science for Biologists Using Python' by Yasha Hasija and Rajkumar Chakraborty, published by CRC Press in 2021. It includes links to download the book and other related titles, along with a detailed table of contents outlining various chapters covering Python programming, data analysis, visualization, and machine learning applications in biology. The book aims to provide biologists with practical skills in data science using Python.

Uploaded by

metrefberkta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 47

Hands on Data Science for Biologists Using

Python 1st Edition Yasha Hasija pdf download

https://ebookmeta.com/product/hands-on-data-science-for-
biologists-using-python-1st-edition-yasha-hasija/

Download more ebook from https://ebookmeta.com


We believe these products will be a great fit for you. Click
the link to download now, or visit ebookmeta.com
to discover even more!

All About Bioinformatics: From Beginner to Expert Yasha


Hasija

https://ebookmeta.com/product/all-about-bioinformatics-from-
beginner-to-expert-yasha-hasija/

Translational Biotechnology: A Journey from Laboratory


to Clinics 1st Edition Yasha Hasija (Editor)

https://ebookmeta.com/product/translational-biotechnology-a-
journey-from-laboratory-to-clinics-1st-edition-yasha-hasija-
editor/

Data-Driven SEO with Python: Solve SEO Challenges with


Data Science Using Python 1st Edition Andreas Voniatis

https://ebookmeta.com/product/data-driven-seo-with-python-solve-
seo-challenges-with-data-science-using-python-1st-edition-
andreas-voniatis/

Curse and Craving (Of Myth and Man #1) 1st Edition Jill
Ramsower

https://ebookmeta.com/product/curse-and-craving-of-myth-and-
man-1-1st-edition-jill-ramsower/
Coherence: In Signal Processing and Machine Learning
Ramírez

https://ebookmeta.com/product/coherence-in-signal-processing-and-
machine-learning-ramirez/

Mine 2nd Edition Pieces of Gray Book 1 Connors Lydia

https://ebookmeta.com/product/mine-2nd-edition-pieces-of-gray-
book-1-connors-lydia/

Snow Ridge Mystery Box Set Books 1 5 Emma Lee

https://ebookmeta.com/product/snow-ridge-mystery-box-set-
books-1-5-emma-lee/

Canvas LMS For Dummies Marcus Painter Eddie Small

https://ebookmeta.com/product/canvas-lms-for-dummies-marcus-
painter-eddie-small/

Cybersecurity Duane C Wilson

https://ebookmeta.com/product/cybersecurity-duane-c-wilson/
Common Pool Resources Strategic Behavior Inefficiencies
and Incomplete Information Ana Espinola-Arredondo

https://ebookmeta.com/product/common-pool-resources-strategic-
behavior-inefficiencies-and-incomplete-information-ana-espinola-
arredondo/
Hands-On Data Science for
Biologists Using Python
Hands-On Data Science for
Biologists Using Python

Yasha Hasija and Rajkumar Chakraborty


First edition published 2021
by CRC Press
6000 Broken Sound Parkway NW, Suite 300, Boca Raton, FL 33487-2742
and by CRC Press
2 Park Square, Milton Park, Abingdon, Oxon, OX14 4RN
© 2021 Taylor & Francis Group, LLC
CRC Press is an imprint of Taylor & Francis Group, LLC
Reasonable efforts have been made to publish reliable data and information, but the author and publisher
cannot assume responsibility for the validity of all materials or the consequences of their use. The authors and
publishers have attempted to trace the copyright holders of all material reproduced in this publication and
apologize to copyright holders if permission to publish in this form has not been obtained. If any copyrighted
material has not been acknowledged please write and let us know so we may rectify in any future reprint.
Except as permitted under US Copyright Law, no part of this book may be reprinted, reproduced, transmitted,
or utilized in any form by any electronic, mechanical, or other means, now known or hereafter invented,
including photocopying, microfilming, and recording, or in any information storage or retrieval system,
without written permission from the publishers.
For permission to photocopy or use material electronically from this work, access www.copyright.com or
contact the Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA 01923, 978-750-
8400. For works that are not available on CCC please contact [email protected]
Trademark notice: Product or corporate names may be trademarks or registered trademarks, and are used only
for identification and explanation without intent to infringe.
Library of Congress Cataloging‑in‑Publication Data
Names: Hasija, Yasha, author. | Chakraborty, Rajkumar, author.
Title: Hands on data science for biologists using Python / Yasha Hasija and Rajkumar Chakraborty.
Description: First edition. | Boca Raton : CRC Press, 2021. | Includes bibliographical references and index.
Identifiers: LCCN 2020044939 | ISBN 9780367546793 (hardback) | ISBN 9780367546786 (paperback) |
ISBN 9781003090113 (ebook)
Subjects: LCSH: Biology–Data processing. | Python (Computer program language)
Classification: LCC QH324.2 .H373 2021 | DDC 570.285‐‐dc23
LC record available at https://lccn.loc.gov/2020044939
ISBN: 978-0-367-54679-3 (hbk)
ISBN: 978-0-367-54678-6 (pbk)
ISBN: 978-1-003-09011-3 (ebk)

Typeset in Times
by MPS Limited, Dehradun
Contents

Preface................................................................................................................................ xi
Author Bio ........................................................................................................................ xii

1. Python: Introduction and Environment Setup ....................................................................1


Why Learn Python..................................................................................................................... 1
Installing Python ........................................................................................................................ 2
Installing Anaconda Distribution .............................................................................................. 3
Running the Jupyter Notebook ................................................................................................. 3
The Building Blocks of Programs ............................................................................................ 5
Errors in Python......................................................................................................................... 5
Exercise ...................................................................................................................................... 6

2. Basic Python Programming....................................................................................................7


Datatypes and Operators ........................................................................................................... 7
Variables .................................................................................................................................... 9
Strings ...................................................................................................................................... 11
Lists and Tuples....................................................................................................................... 16
Dictionary in Python ............................................................................................................... 22
Conditional Statements ............................................................................................................ 26
Loops in Python....................................................................................................................... 29
Functions .................................................................................................................................. 33
Classes and Objects ................................................................................................................. 37
File Handling in Python .......................................................................................................... 40
Exercise .................................................................................................................................... 43

3. Biopython ................................................................................................................................45
Introduction .............................................................................................................................. 45
Installing Biopython ................................................................................................................ 45
Biopython Seq Class ............................................................................................................... 45
Parsing Sequence Files ............................................................................................................ 47
Writing Files ............................................................................................................................ 51
Pairwise Sequence Alignment................................................................................................. 53
BLAST with Biopython .......................................................................................................... 57
Multiple Sequence Alignment................................................................................................. 59
Construction of a Phylogenetic Tree ...................................................................................... 62
Handling PDB Files................................................................................................................. 64
Exercise .................................................................................................................................... 70

4. Python for Data Analysis......................................................................................................71


Introduction .............................................................................................................................. 71
NumPy ..................................................................................................................................... 71
NumPy Arrays versus Lists..................................................................................................... 71
Two-Dimensional Matrices ..................................................................................................... 73

v
vi Contents

Matrix Operations .................................................................................................................... 74


Comparing Matrices ................................................................................................................ 77
Generating Data Using NumPy............................................................................................... 78
Speed Test................................................................................................................................ 79
“Pandas” Dataframe................................................................................................................. 80
Selecting Rows and Columns ................................................................................................. 81
Conditional Filtering in Dataframe ......................................................................................... 84
Writing CSV Files from Pandas Dataframe ........................................................................... 85
Apply() Function ..................................................................................................................... 85
Concatenating and Merging .................................................................................................... 87
Exercise .................................................................................................................................... 89

5. Python for Data Visualization..............................................................................................91


Introduction .............................................................................................................................. 91
Matplotlib................................................................................................................................. 91
Matplotlib Functional Method................................................................................................. 92
Matplotlib Object-Oriented Method........................................................................................ 93
Resolution and Saving Figures ............................................................................................... 97
Legend...................................................................................................................................... 98
Customization of the Plot Appearance ................................................................................... 99
Scatterplot .............................................................................................................................. 102
Histogram............................................................................................................................... 102
Boxplot................................................................................................................................... 104
Seaborn................................................................................................................................... 104
Distribution Plots ................................................................................................................... 105
Joint Plots............................................................................................................................... 106
Pairplot ................................................................................................................................... 108
Barplot.................................................................................................................................... 111
Boxplot................................................................................................................................... 113
Violin Plot.............................................................................................................................. 114
Heatmaps................................................................................................................................ 114
Cluster Maps .......................................................................................................................... 116
Regression Plot ...................................................................................................................... 117
Plotly – Interactive Data Visualization................................................................................. 118
Geographical Plotting ............................................................................................................ 120
Exercise .................................................................................................................................. 122

6. Principal Component Analysis ...........................................................................................123


Introduction ............................................................................................................................ 123
Variance as Information ........................................................................................................ 123
Data Transformation .............................................................................................................. 124
Case Study ............................................................................................................................. 125
PCA: Step-by-Step................................................................................................................. 127
Standardization of the Features............................................................................................. 127
Obtain the Eigenvectors and Eigenvalues ............................................................................ 128
Choosing Axes with Maximum Variance............................................................................. 130
Programing Drive .................................................................................................................. 133
Exercise .................................................................................................................................. 135
Contents vii

7. Hands-On Projects...............................................................................................................137
Differential Gene Expression Analysis................................................................................. 137
Quality Control ...................................................................................................................... 138
Normalization......................................................................................................................... 141
Differential Expression Analysis........................................................................................... 146
Cluster Map ........................................................................................................................... 151
Gene Enrichment Analysis .................................................................................................... 152
SNP Analysis ......................................................................................................................... 153
Exercise .................................................................................................................................. 160

8. Machine Learning and Linear Regression .......................................................................161


Introduction to Machine Learning and Its Applications in Biology ................................... 161
Types of Machine Learning Systems ................................................................................... 161
Optimization of Models......................................................................................................... 165
Challenges in Machine Learning Projects ............................................................................ 167
Linear Regression .................................................................................................................. 169
General Workflow of a Machine Learning Project .............................................................. 171
Implementation of Linear Regression Using Scikit-Learn................................................... 172
Loading Dataset ..................................................................................................................... 172
Train-Test Split ...................................................................................................................... 173
Training Model ...................................................................................................................... 173
Model Evaluation................................................................................................................... 174
Predicting Child Height Based on Parents Height ............................................................... 176
Predicting the Height of Sons ............................................................................................... 178
Predicting the Height of Daughters ...................................................................................... 180
Exercise .................................................................................................................................. 181
References .............................................................................................................................. 181

9. Logistic Regression ..............................................................................................................183


Introduction ............................................................................................................................ 183
Implementation of Logistic Regression Using Sklearn........................................................ 184
Train-Test Split ...................................................................................................................... 187
Training the Logistic Regression Model .............................................................................. 187
Evaluation of Model .............................................................................................................. 187
Retrieving Intercept and Coefficient ..................................................................................... 188
Data Scaling........................................................................................................................... 189
Predicting a New Result........................................................................................................ 192
Breast Cancer Prediction Using Logistic Regression........................................................... 193
Model Evaluation................................................................................................................... 194
Exercise .................................................................................................................................. 196
References .............................................................................................................................. 196

10. K-Nearest Neighbors (K-NN) .............................................................................................. 197


Introduction ............................................................................................................................ 197
Implemention of K-NN Using Sklearn ................................................................................. 198
Loading the Dataset............................................................................................................... 198
Splitting the Dataset into the Training Set and the Test Set ............................................... 198
Training the K-NN Model on the Training Set.................................................................... 199
Evaluation with K 1 .............................................................................................................. 199
Choosing a K-Value .............................................................................................................. 199
viii Contents

Data Scaling........................................................................................................................... 201


Predicting New Values .......................................................................................................... 202
Diagnosing the Liver Disease Using K-NN ......................................................................... 203
Missing Value Imputation ..................................................................................................... 204
Data Scaling........................................................................................................................... 205
Splitting the Dataset into the Training Set and the Test Set ............................................... 205
Choosing a K-Value .............................................................................................................. 205
Evaluation of the Model........................................................................................................ 206
Exercise .................................................................................................................................. 208
References .............................................................................................................................. 208

11. Decision Trees and Random Forests .................................................................................209


Introduction ............................................................................................................................ 209
Random Forests ..................................................................................................................... 211
Implementation of Decision Tree and Random Forest Using Sklearn................................ 212
Train Test Split ...................................................................................................................... 212
Decision Trees ....................................................................................................................... 212
Prediction and Evaluation ..................................................................................................... 213
Predicting New Values .......................................................................................................... 213
Random Forests ..................................................................................................................... 214
Prediction and Evaluation of Random Forest Model........................................................... 214
Predicting Prognosis of Diabetes Using Random Forest ..................................................... 214
Loading Dataset ..................................................................................................................... 214
Train-Test Split ...................................................................................................................... 215
Training Classifier ................................................................................................................. 215
Cross-Validation .................................................................................................................... 216
Exercise .................................................................................................................................. 217
Reference ............................................................................................................................... 217

12. Support Vector Machines ...................................................................................................219


Introduction ............................................................................................................................ 219
Kernel Trick........................................................................................................................... 219
Implementation of Support Vector Machines Using Sklearn .............................................. 221
Train Test Split ...................................................................................................................... 221
Train the Support Vector Classifier ...................................................................................... 221
Predictions and Evaluations .................................................................................................. 221
Grid Search ............................................................................................................................ 222
Prediction of Wheat Species Based on Wheat Seed Data ................................................... 223
Train Test Split ...................................................................................................................... 224
Training Support Vector Classifier and Tuning Its Parameters Using a Grid Search ........ 224
Exercise .................................................................................................................................. 225
References .............................................................................................................................. 225

13. Neural Nets and Deep Learning ........................................................................................227


Introduction ............................................................................................................................ 227
Neural Networks Architecture............................................................................................... 227
The Working Principle of Neural Networks ........................................................................ 228
Activation Functions.............................................................................................................. 228
Steps of Forward Propagation............................................................................................... 229
Gradient Descent ................................................................................................................... 229
Contents ix

Backpropagation .................................................................................................................... 230


Implementing Neural Networks Using TensorFlow............................................................. 231
Data Scaling........................................................................................................................... 232
TensorFlow 2.0 ...................................................................................................................... 232
Creating a Model ................................................................................................................... 232
Model – As a List of Layers................................................................................................. 232
Model – Adding in Layers One by One............................................................................... 233
Building Model ...................................................................................................................... 233
Training Model ...................................................................................................................... 234
Overfitting .............................................................................................................................. 235
Dropout and Early Stopping ................................................................................................. 235
Model Evaluation................................................................................................................... 238
Predicting New Instance........................................................................................................ 239
Predicting Breast Cancer Using Neural Networks ............................................................... 239
Separating the Dependent and Independent Dataset ............................................................ 239
Data Scaling........................................................................................................................... 239
Splitting the Dataset into the Training Set and Test Set ..................................................... 239
Creating the Model ................................................................................................................ 240
Model Evaluation................................................................................................................... 241
Convolutional Neural Network ............................................................................................. 241
Implementation of CNN Using TensorFlow ........................................................................ 243
Import Libraries ..................................................................................................................... 243
Importing the Dataset ............................................................................................................ 244
Splitting the Dataset into the Training Set and Test Set ..................................................... 245
Building Model ...................................................................................................................... 246
Training Model ...................................................................................................................... 247
Model Evaluation................................................................................................................... 248
Exercise .................................................................................................................................. 249
Reference ............................................................................................................................... 249

14. The Machine Learning Project ..........................................................................................251


Introduction ............................................................................................................................ 251
Importing the Libraries.......................................................................................................... 251
Importing the Dataset ............................................................................................................ 251
PCA ........................................................................................................................................ 252
Splitting the Dataset into the Training Set and the Test Set ............................................... 253
Training the Logistic Regression Model and Evaluation..................................................... 254
Training the K-NN Model and Evaluation ........................................................................... 254
Choosing K-Value ................................................................................................................. 254
Training the Random Forest Model and Evaluation ............................................................ 255
Training the SVM Model and Evaluation ............................................................................ 256
Training the ANN Model and Evaluation ............................................................................ 257
Exercise .................................................................................................................................. 259
Reference ............................................................................................................................... 259

15. Natural Language Processing............................................................................................. 261


Introduction ............................................................................................................................ 261
Vectorizing the Text .............................................................................................................. 261
Bag of Words......................................................................................................................... 261
TF-IDF ................................................................................................................................... 262
x Contents

Classification of Abstracts into Various Categories Using NLP ......................................... 263


Importing the Dataset ............................................................................................................ 263
Text Processing...................................................................................................................... 264
Label Encoding ...................................................................................................................... 265
Text Tokenization Bag-of-Words ......................................................................................... 265
Splitting the Dataset into the Training Set and the Test Set ............................................... 267
Building Model ...................................................................................................................... 267
Model Evaluation................................................................................................................... 267
TF-IDF Implementation......................................................................................................... 267
Splitting the Dataset into the Training Set and the Test Set ............................................... 268
Building Model ...................................................................................................................... 268
Model Evaluation................................................................................................................... 268
Artificial Neural Networks in NLP....................................................................................... 270
Splitting the Dataset into the Training Set and the Test Set ............................................... 271
Building Model ...................................................................................................................... 271
Training Model ...................................................................................................................... 271
Model Evaluation................................................................................................................... 272
New Prediction ...................................................................................................................... 272
Exercise .................................................................................................................................. 273
References .............................................................................................................................. 273

16. K-Means Clustering .............................................................................................................275


Introduction ............................................................................................................................ 275
Implementation of K-Means Clustering Using Sklearn ....................................................... 275
Choosing the Number of Clusters......................................................................................... 277
K-Means Clustering of Genes Based on the Co-Expression ............................................... 279
Exercise .................................................................................................................................. 283

Index..............................................................................................................................................285
Preface

Yasha Hasija Ph.D.

Data science is rapidly becoming a vital discipline involving the use of big data to extract meaningful
information. With the advent of high throughput technologies in the field of healthcare, it is becoming
increasingly imperative for life science researchers to analyze the massive amount of data being
generated. Researchers with little or no computational skills often find the task challenging. In order to
overcome this challenge, we have meticulously drafted this book, using illustrative examples, as a
stepwise guide to ease newcomers from the field of life sciences to the field of data science. We have
chosen Python as our programming language of choice because of its easy accessibility on all operating
systems, versatility, comprehensible interface, ease of use, object-oriented features, and wide range of
applicability.
This book will serve as a beginner’s guide for anyone interested in the basics of programming, data
science, and Machine Learning. Every topic has an intuitive explanation of concepts and is accompanied
by the implementation of the concepts using biological examples. This book can also serve as a
handbook for biological data analysis using standard Python code templates for model building -
facilitated with supplementary files for each chapter. The text is made to be as interactive as possible
with accompanying Jupyter Notebooks for every section, to help readers practice the codes in their local
systems. Each chapter is specially designed with examples.
The book is divided into two sections. The first section deals with an introduction to basic Python
programming and a hands-on tutorial for data handling. Chapters in this section elaborate on the usage
of some of the basic Python libraries and packages. One of the important libraries for life sciences data -
Biopython - is explained in this section with examples of reading and writing various biological file
formats, performing Pairwise and Multiple Sequence Alignments, handling protein and sequence data,
etc. The subsequent sections elaborate on data handling using NumPy and Pandas, data visualization
techniques, and dimensionality reduction methods that are common to all data analyzes and also provide
illustrative examples for biological data.
Machine Learning is an integral part of several research projects today and has numerous applications in
the present-day era. Almost all of the disciplines of technology have been transformed by Machine
Learning and artificial networks, and life sciences are no exception, with Machine Learning applications in
fields ranging from agriculture to diagnostics to personalized medicine to drug development to biological
imaging - the list is mounting. The second section of the book deals with Python implementation in
Machine Learning algorithms. Chapters in this section contain an introduction to Machine Learning to
make readers comfortable with the various terminologies used in Machine Learning. This section also
explores popular supervised and unsupervised Machine Learning algorithms - such as logistic regression,
k-nearest neighbors, decision trees, random forests, support vector machines, artificial neural networks,
convoluted neural networks, natural language processing, and k-means clustering - and shows their
implementation in Python.
The book is written considering the need for biologists to learn programming in light of handling
massive data, analyzing it, and deriving useful insights from it. I hope our readers will benefit from this
hands-on book on data science for biologists using Python.

Yasha Hasija, Ph.D.

xi
Author Bio

Dr. Yasha Hasija (B.Tech, M.Tech, Ph.D.) is an Associate Professor at the Department of
Biotechnology and the Associate Dean of Alumni Affairs at the Delhi Technological University. Her
research interests include genome informatics, genome annotation, microbial informatics, integration of
genome-scale data for systems biology, and personalized genomics. Several of her works have been
published in international journals of high repute, and she has made noteworthy contributions in the area
of biotechnology and bioinformatics as author and editor of notable books. Her expertise, through her
book chapters and conference papers, is of significance to other academic scholarship and teaching. She
is also on the editorial boards of numerous international journals.
Dr. Hasija’s work has brought her recognition and several prestigious awards - including the Human
Gene Nomenclature Award at the Human Genome Meeting (2010) held in Montpellier, France. She is
the project investigator for several research projects sponsored by the Government of India - including
DST-SERB, CSIR-OSDD, and DBT. As Dr. Hasjia continues conducting research, her passion for
finding the translational implications of her findings grows.
Mr. Rajkumar Chakraborty (B.Tech, M.Tech) received his Bachelor of Technology Degree in
Biotechnology from the Bengal College of Engineering and Technology, West Bengal, India and
completed his Masters of Technology Degree in Bioinformatics from the Delhi Technological
University, Delhi, India. He is currently pursuing his Ph.D. in the field of bioinformatics. He was a
part of the 4-member team which won “Promising Innovative Implementable Idea Award” at the
SAMHAR-COVID19 Hackathon 2020 for innovating a solution towards drug repurposing against
COVID-19. His research interests are in applied Machine Learning and the integration of big data in
biological science.

xii
1
Python: Introduction and
Environment Setup

Why Learn Python


Before knowing about Python, we should first understand why people working in the area of life
sciences should learn to program. As we are in the era of information technology, we have seen a
massive explosion in biological data like sequences, annotations, interactions, biologically active
compounds, etc. For instance, while this chapter was being written last April 2019, the Gene Bank
(NCBI) - which is one of the largest databases for nucleotide sequences - contains 212 million se­
quences in its repository (https://www.ncbi.nlm.nih.gov/genbank/statistics/). EMBL, which is also a raw
nucleotide sequence repository, contains 2,253.8 million annotated sequence data which are expected to
double in about 19.9 months (https://www.ebi.ac.uk/ena/about/statistics). This extensive data is being
generated by the advent of high-throughput technologies. For the analysis of this massive amount of
data, we need the help of computers. Computers consist of a central processing unit (CPU), a primary
memory, and a secondary memory storage device. The CPU is the component that does operations on
the data stored in primary and secondary memory. Primary memory is as fast as the CPU and is
designed to keep up with its speed, but it loses its memory as soon as the power is switched off. A
secondary memory storage device can store data after the computer shuts down. These make up our
digital assistant - which is pretty fast and accurate in its tasks and does not get bored with repetitive jobs.
However, in order to assign the job to computers and to receive the desired output, we need to com­
prehend their language, which is also known as the programming language. Every biological research
involves using different datasets and has unique problems to solve - from filtering, merging, subsetting,
finding commonalities between lists, and may even require customization of data formats for preserving
and using information. Programming gives a free hand to users to think and implement innovative
algorithms and solve various problems.
Over time, data science has also found its applications in life sciences. Data science helps in finding
patterns in a huge amount of structured or unstructured data which can help in providing valuable
insights in almost all frontiers of biology - ranging from finding putative variations, predicting amino
acid substitution consequences, diagnosing diseases quickly, predicting lead drug toxicity, predicting
pharmacophores, personalized, or precision medicine, prediction in the field of protein secondary and
tertiary structure, microRNA interaction with their targets, epigenetics, etc. The very first step in
generating a hypothesis from a big amount of data is the curation of large datasets. A task like curating
data is very tedious and time-consuming work. It consists of repetitive searching of data from certain
database’s websites, literature, and others. Here comes our digital assistant to the rescue, saving us from
this tedious job as it can work much faster than how humans think and perform things manually. A 3.0-
gigahertz CPU can process 3 billion instructions per second - that is an example of the tremendous
power of computing.
The central theme of this book is to provide a practical approach to biologists in applying data science
techniques on omics data. Data science usually consists of data analysis, data visualization, data pre­
paration, Machine Learning, and more. We will discuss each aspect in relation to relevant biological
problems along with their solutions - starting with basic Python programming so that readers can get
accustomed to programming terminologies.

1
2 Hands on Data Science for Biologists

Programming skills are a valuable asset for any biologist. There are many programming lan­
guages that have been developed. Some are for instantaneous computation, website creation, and
database generation, among others, and some are general-purpose programming languages that
were developed to be used in a variety of application domains. Python is one example of a general-
purpose programming language. Guido van Rossum developed it as a hobby in the Netherlands
around 30 years ago and named it after a famous British comedian group called “Monty Python’s
Circus”. Now, Python has applications in various domains like data science, web development,
data visualization, and desktop applications, to name a few. Python is one of the popular pro­
gramming languages in the data science and Machine Learning area, and it is community-driven.
Since it has a very steady learning curve, it is recommended by many experts for beginners as their
first programming language to learn. Primarily, Python has simple English-like readable syntax
which is easily understandable by users. For example, if one wants to find the proportion of the
amino acid Leucine with a symbol “L” contained in a protein sequence, the following Python
code will do that:

Protein = “MKLFWLLFTIGFCWAQYSSNTQQGRTSIVHLFEWRWVDIALECERY”
Leu_contain = Protein.count(‘L’)/len(Protein)
print(Leu_contain)

The code is very much similar to the English language. The first line is the protein sequence. The
second line calculates the Leucine residues (denoted by the letter “L”) by counting the number of times
“L” appears in the sequence and then dividing it by the total length of the sequence. Moreover, at last
printing the value, it turns out to be 0.108
Thanks to the readability of Python codes, learners can concentrate on the concepts of programming
and problems more than learning the syntax of the language. As Python is community-driven and it has
one of the largest communities, Python has evolved to contain several important libraries that are pre-
installed or are freely available to install. These libraries help in the quick and efficient development of
complex applications, because these do not need to be written from scratch.
Another advantage of learning Python is that it can be used for various purposes due to the devel­
opment of popular libraries, such as:

• Frameworks like Django, Flask, Pylons are used for creating static and dynamic websites.
• Libraries like Pandas, NumPy, and Matplotlib are accessible for data science and visualization.
• Scikit-Learn and TensorFlow are advanced libraries for Machine Learning and deep learning
• Desktop applications can be built using packages like PyQt, Gtk, and wxWidgets, among others.
• Modules like BeeWare or Kivy are taking the lead in mobile applications.

Learning programming is the same as learning a new language; we have to first understand the
vocabulary and syntaxes. Next, we learn how to construct some meaningful but terse sentences.
Using those sentences, we then form paragraphs, and finally, we write our own story. In this book,
we will start with Python syntaxes and vocabulary. Then, we will construct small programs with
biological relevance to help biologists learn programming with problems that are important
to them.

Installing Python
We are using Python 3.7, which is the current and stable version of Python. Most of the operating
systems either already have Python installed by default, or it can be downloaded from the Python
Software Foundation’s website (https://www.python.org/), where it is freely available. After installing
Python, open the Python Shell in Windows or type “python3” in the terminal of Mac or Linux as
follows:
Other documents randomly have
different content
being established from a point in the plane of the section to the
knee, I obtained contractions similar to those which had been
produced before the limb was separated from the body. I then
formed an arc of moisture, by applying the amputated limb to the
trunk; and having determined the action of the pile to the spinal
marrow and the foot, I obtained very sensible contractions. I
observed, on this occasion, that a frog, prepared some time before,
and which was accidentally lying on the table, at each application of
the metallic arcs moved like an electrometer, and thus confirmed the
action of an arc of moisture.

EXPERIMENT LIV.
After a considerable time had been employed in the preceding
experiment, I endeavoured to revive the action of the Galvanism by
moistening the muscles with a solution of opium. By these means
the contractions seemed to be increased; and the case was the
same in other warm-blooded animals. A series of similar
experiments, if carefully made, would no doubt be attended with
important results; as they might enable us to ascertain the action of
the different stimulants proposed by Dr. Brown. But I must, in the
mean time, observe, that the before-mentioned effects of opium
fully correspond with those long ago observed by Galvani.
It results, in general, from my experiments, that moisture performs a
conspicuous part in producing contractions; and that it is even of
more importance than animal heat. I indeed find that muscular
contractions may be obtained after the body has thrown out a great
deal of its heat, even when it has cooled for several hours, and when
it has been exposed to a temperature below zero; for, if Galvanism
be communicated to a body in that state, muscular contractions will
be immediately excited; but they soon cease by the privation of
animal moisture. If a muscle, indeed, which has been laid bare
resists the Galvanic influence, its action may be speedily renewed by
making an incision into it, or into some of the muscles which
surround it. I can assert, that by this process partial contractions
were produced in the human body five hours after death, every time
that the arcs were applied to the muscular fibres.
Being worn out with this long series of experiments, I found it
necessary to abandon them; but, from the force of the contractions,
it could easily be seen that they might have been produced much
longer.
Having communicated these results to the celebrated Caldani,
Professor of Anatomy in the University of Padua, he requested that I
would confirm the observations I had made by again applying
Galvanism to the membranes and to the cortical substance of the
brain. He was unwilling to give up the system of Haller without very
positive proofs; and his doubts were to me of great utility, as they
induced me to establish the action of Galvanism on these parts by
the following experiments:

EXPERIMENT LV.
As these doubts related to a delicate point, which would have
produced some variation in the theory of a celebrated physiologist, I
repeated the experiment on the head of an ox newly killed, in the
presence of Professor Mondini, who made the necessary
preparations. The dura mater was laid bare; and the action of the
Galvanism being conducted to it, strong contractions were
immediately produced. The same phænomenon took place when the
cortical substance was brought into contact with one of the arcs. I
repeated this experiment with the same success on the heads of
several oxen and lambs.

EXPERIMENT LVI.
When I passed through Turin, Professors Vassalli, Giulio, and Rossi
requested me to perform, in their presence, my principal
experiments, and those in particular which related to the membranes
and the cortical substance of the brain. They observed, at the same
time, that in uncovering the brain of an ox with a cleaver, some
derangement, in consequence of the agitation, might be effected in
that organ, which would perhaps produce an alteration in the
results. Professors Giulio and Rossi proposed therefore to uncover
the brain by the trepan, which gave a greater degree of precision to
the experiment. The dura mater of an ox being uncovered in this
manner, it was subjected to the action of Galvanism, and even with
this mode of preparation the muscular contractions every time the
arc was applied were pretty strong. The arc being determined to the
cortical substance, the force of the contractions seemed to be
increased; and in general they appeared to be more considerable in
proportion as the arc was plunged to a greater depth into the
substance of the brain.
These gentlemen, in whose presence I performed my principal
experiments, having pursued my method after my departure, made
some observations which may be of great use to physiology. They
had before entertained strong doubts whether the heart was
susceptible of the Galvanic action, by means of simple armatures
applied to the different parts of that muscle; and such irregularity
had been observed in the results, that it appeared difficult to
determine the question. I was therefore exceedingly happy that I
had had an opportunity of exciting in others a desire to make new
researches in regard to this point, of so much importance. Professors
Vassalli, Giulio and Rossi repeated and modified my experiments on
the heart in such a manner, that they obtained in man, and warm-
blooded animals, contractions similar to those which I had observed
only in cold-blooded animals. I wait for a detailed account of these
experiments, as well as of others made on decapitated criminals[2],
which were subjected to my processes. The bodies were removed to
the large hospital; and notwithstanding the long period which had
elapsed between the time of the execution and that when the
experiments were performed, they observed almost the same
phænomena.
The observation made on this criminal, that the vital powers exist so
long in the body after death, induces me to hope that I shall be able
to obtain similar results by the application of my method, in common
cases of suspended animation. But when employed for this laudable
purpose it should be modified in such a manner as to render
unnecessary those operations which are so painful to humanity. On
this account, I have invented a method by which muscular
contractions may be produced without the least incision or
separation of the muscles. It is so combined, that it cannot be
rejected by the most rigorous medical jurisprudence.

[2] Some account of the latter, from the Journal de Physique, will be found
in the Appendix.—Trans.

EXPERIMENT LVII.
In order to try the vital force existing in the human body after death,
I immerse the hand in a solution of muriate of soda, and establish
an arc, one of the extremities of which is made to pass round the
fore-arm, while the other is brought into contact with the bottom of
the pile. I adapt to the extremity of another arc an elastic probe,
which is applied to one of the ears, moistened by means of a syringe
with the same solution, and connect the other extremity of the arc
with the summit of the pile. By this arrangement various
contractions, according to the different degrees of vitality in the
bodies, are observed, sometimes in the fingers, sometimes in the
hand, and sometimes in the whole arm. The fingers bend, and move
in a sensible manner; and sometimes the whole of the fore-arm
proceeds towards the breast. The importance of this method for
determining the duration of the vital powers after death may be
readily comprehended. Should means be found hereafter to make
further discoveries in regard to this interesting point, physiologists
may then be able to determine with certainty those cases when
interment ought to be retarded; and those where the good of
society requires that every possible means of resuscitation should be
employed. In the large hospital of Bologna, I made several
observations on this subject; and remarked in particular, how much
the nature of the disease contributes, cæteris paribus, to produce a
difference in the duration of the muscular contractions. I tried the
case of death produced by putrid fevers, by pleurisies, by wounds in
the pericardium, by the scurvy, and by the consequences of
parturition; and I found a great difference in the degrees of vitality,
according to the circumstances of the disease, the age and
temperament of the individual; which confirms me in the opinion I
entertain, that these experiments, if long continued without
intermission by able physiologists, might be of the greatest benefit
to medicine.
These researches are not an object of mere curiosity; they seem to
open an extensive field for promoting the welfare of the human race,
and may be of service in cases of apparent death, occasioned by an
alteration of the brain, and sometimes in cases of asphyxia. Various
learned academies are entitled to great praise for having turned
their attention to this subject, and for having already recommended
different stimulants as proper for being used on such occasions. But
I must take the liberty of requesting that in similar cases the action
of Galvanism maybe tried, by employing the new method here
proposed. It is of great importance that the means of affording relief
to the sufferings of mankind should be multiplied, and especially in
cases in which the old system of medicine presents to us so few
resources. In the mean time I conceive it may be useful to make
some trials on animals thrown into a state of asphyxia different
ways. These researches may lead to valuable discoveries, and
produce some light to direct us in our attempts to save the lives of
men. If the encouragement I have received from the medical and
philosophical world, in general, induce others to pursue the same
path, it will give me great satisfaction. Galvanism is yet in its infancy;
and when we reflect on the slow progress which many other
branches of science have made, and how long they remained almost
stationary before the full importance of them was known, it would
be presumption to set bounds to that which is the subject of the
present work. For my part, I spared no pains during my short stay at
Paris to exhibit my method, and to make it publicly known. Dr. Pinel
assisted at my experiments with the utmost zeal, and was witness to
muscular contractions excited in the body of an old woman, who had
died of a malignant putrid fever. The interest which he took in my
researches induced me to communicate to him several plans I had
formed for giving relief to some of those unfortunate beings
committed to his skill and beneficent care in the Hôpital des Foux. I
pointed out to him some particular cases where the individuals, in
consequence of a deep rooted melancholy, were reduced almost to a
state of idiotism, and in which Galvanism seemed likely to be
attended with the greatest benefit. In the last public sitting of the
Institute of Bologna, at which I was present, I announced the
complete cure of two lunatics performed in the Public Hospital, in
the presence of many of the medical pupils, and with the assistance
of the professors who superintend that establishment, and who are
now employed in confirming my method on other patients. I am well
aware that two cures are not sufficient to make operations of this
kind be admitted as general remedies; but they ought to encourage
physicians to prosecute this subject in order to ascertain how far
Galvanism can be considered as of utility in such cases, and to
endeavour by their labours to fill up the vacuity which still exists in
this part of medicine. I am ready to acknowledge that great caution
ought to be employed in performing such experiments; and for this
reason I purpose, in the third part of the present work, to lay before
the reader the reflections and observations of various ingenious men
who have made this department of Galvanism an object of their
researches.
But before I proceed further, I think it necessary to deduce from
what has been already said a few general corollaries.

COROLLARY I.
The muscles are affected by the action of the pile in a much more
powerful manner when they are laid entirely bare, and when the arc
is made to penetrate to a considerable depth in their substance.

COROLLARY II.
These convulsions are increased in proportion to the number of the
points of contact between the arc and the muscle.

COROLLARY III.
In many cases, muscular contractions are obtained by forming an
arc from one muscle to another.

COROLLARY IV.
Muscular contractions are almost always speedily obtained by the
pile, even when the means proposed by Haller fail to produce them.

COROLLARY V.
The heart, which, according to Haller’s principle, is the first muscle
that receives life and the last to lose it, in comparison of the other
muscles, can with difficulty be made to feel the influence of the
Galvanic action; while the other muscles always retain, a long time
after death, that vital force which it has never been found possible
to excite but by the impulse of Galvanism.

COROLLARY VI.
The partisans of Haller, to excite these contractions, often employ
stimulants, which alter the texture of the muscular fibre, and destroy
its continuity; an inconvenience which may be avoided by applying
Galvanism.
COROLLARY VII.
As the kinds of apparatus before mentioned are not applied to the
spinal marrow alone, but to the different nerves of the animal
machine, they may afford to the anatomist an experimental
myology; by means of which he can render sensible to the eye the
fixed and moveable points of the muscles, and the real extent of
their action.

COROLLARY VIII.
The experiments made on the bodies of persons who died a natural
death, are of the greatest importance to physiology. I am strongly
inclined to think that, by pursuing these researches more in detail,
they will one day make us better acquainted with the character of
the vital powers, and the difference of their duration, according to
diversity of sex, age, temperament and disease, and even according
to diversity of climate and to the nature of the atmosphere.
PART THE THIRD.

ON THE POWER OF GALVANISM AS


APPLIED TO MEDICINE.

IF the doctrine of Galvanism have thrown considerable light on


various parts of philosophy and chemistry, it gives us reason to hope
that it may also be of benefit to medicine. The labours indeed of
Galvani, whose most ardent desire was that his discovery might be
rendered useful to mankind, were at length directed to this object,
and his wishes now begin to be realized; but I must request the
reader not to be too sanguine in his expectations, or to imagine that
I here mean to entertain him with a long series of wonderful or
extraordinary cures performed by means of Galvanism. I have no
intention to decorate the discovery of my late uncle with false glory.
Though I possess neither the same depth of knowledge, nor the
same superiority of talents, I have always endeavoured to imitate his
moderation and prudence in the application of his theory. I am fully
convinced that much still remains to be done, in order to discover
the best methods of employing this new agent; and that the facts
respecting it, though numerous, have not been reduced to principles
sufficiently certain and satisfactory. There are, nevertheless, some
results and observations exceedingly curious, which, if confirmed by
new experiments and researches, may enable us to obtain
convincing proofs of its utility. New facts, however surprising, are not
to be despised merely on account of their being different from any
before observed. Those who reject them, as some have done, ought
first to show that they are inconsistent with the principles of sound
philosophy. Guided by these reflections, and desirous of contributing,
as far as possible, towards the illustration of a new and very obscure
subject, I shall lay before the reader the result of my researches in
the following articles.
SECTION I.
Advantages which the medical administration of Galvanism has over
that of common electricity.

Several reasons have induced me to prefer the medical


administration of Galvanism by means of the pile, to that of artificial
electricity. In regard to the action of the common electric machine,
the difficulty of calling it forth properly during damp weather; the
time required for exciting it; the necessity of charging the jar every
time it is applied to the patient, are so many obstacles which render
the administration of common electricity inconvenient; and on this
account it is now much less used than formerly. On the other hand
the pile, according to the observations which I have had an
opportunity of making, acts in a uniform manner; is not sensible to
the effects of moisture; and forms a sort of Leyden flask, which has
a continued action that may be a long time employed. It may be
considered as an apparatus, which in itself contains a series of jars
charged in succession with different degrees of electricity.
I might here enumerate many differences which are found between
the administration of Galvanism and that of electricity. If electricity
be administered to a patient directly from the conductor, he receives
very little of its action; if a shock be given with the Leyden flask, the
action is exceedingly strong, but not permanent. On the other hand,
the pile has a strong and continued action, and occasions a powerful
circulation of the Galvanic matter, which after some time produces
very striking effects on the animal fluids. I might here refer, by way
of example, to the experiments made with Galvanism on the blood,
the bile, and the urine, which gave results I was never able to obtain
by common electricity. I shall mention, in the last place, the great
convenience of the pile, and the short space of time in which
Galvanism may be administered by it to a great number of persons;
and this advantage is sufficient, cæteris paribus, to render it
preferable in this respect to common electricity.
SECTION II.
Application of Galvanism to the organs of hearing and of sight.

By applying Galvanism to different parts of the face, a flash of light


is excited in the eyes, which is stronger or weaker according to the
nature of the parts to which it is directed. These organs, though
delicate, are always affected in such a manner that the mechanism
of the eye sustains no injury from the metallic arcs when they are
made to communicate with only two plates of different metals. I
received an account of this phænomenon at Milan, several years
ago, from the celebrated Volta, who produced it by applying a
conductor of zinc in such a manner, that one end of it touched the
bulb of the eye, and the other the tip of the tongue armed with a
plate of tin. In administering Galvanism for diseases of the eyes, it is
much better to employ the pile. To excite the appearance of a flash
of light, it is not necessary that the eyes should be open; it takes
place even if they are shut, and covered with a bandage in a
darkened apartment. Some of the partisans of Euler, perhaps, may
here maintain, that this phænomenon of Galvanism is a deception,
and that no light can be really excited in such cases, as the
production of light depends on the emanation of rays from a
luminous body which penetrate into the interior part of the eye. But
without entering into the examination of this question, which is
foreign to my principal object, I shall only observe, that long before
the theory of Galvanism was known, the celebrated Darwin had
found that when the eyes are shut, there are certain internal
stimulants which are capable of producing the appearance of light
and of colours.
In no case is the difference between Galvanism and electricity more
apparent than in the application of the former to the sight. Very little
benefit had been obtained by means of a metallic point inclosed in a
glass tube, which directed the electric charge from a jar to the
cornea; and besides, the shock of a Leyden jar applied directly to so
delicate an organ as the eye could not but be attended with danger.
Galvanism applied to the exterior part of the eye, in the same place
where a stream of electricity would have had no influence whatever,
has always produced a certain effect on the organ of sight, as is
proved by the following experiments.

EXPERIMENT I.
If you touch with one hand the bottom of the pile, and at the same
time apply to the summit different parts of the face moistened with
salt water, a flash of light will be excited in the eyes. The same result
will be obtained, if instead of touching the bottom of the pile with
the hand you touch it with the sole of your foot. No flash of light is
observed when the Leyden flask is employed in the same manner.

EXPERIMENT II.
Having observed the preceding phænomenon in myself, and excited
it in others, I was desirous of proving it in regard to several persons
at the same time during the course of my public lectures, and for
that purpose I made use of the following apparatus. I arranged two
metallic plates in a horizontal position, at the distance of nine inches
from each other, so that six persons with their hands dipped in salt
water could touch the lower plate, and the upper one with the tips
of their tongue. A charged Leyden flask placed between the two
plates being then discharged, the whole of the persons experienced
a violent shock, but perceived no flash of light. It is well known
however that, when a similar arc is formed with the interposition of
a very strong pile, a flash of light is constantly observed; though the
force in the second case is much less than that excited by the
explosion of the Leyden flask. The same result will be obtained by
bringing the upper plate into contact with the nose.

EXPERIMENT III.
As my pupils took much interest in this research, some of them
suspected that the light of the apartment might perhaps have
effaced that excited by the electricity. I therefore made the
apartment entirely dark; and one of them taking a Leyden flask
applied it to the point of the nose of another person with whom he
was in communication, by laying hold of him with the other hand. By
these means a very strong shock was given, but no flash of light was
observed. This experiment was repeated, making the person who
received the shock of the Leyden flask to remain some time before
in the dark, that his eyes might be better enabled to perceive any
faint light that might be excited: but the result was still the same. To
those who refer Galvanism to the common laws of electricity, it will
be difficult to comprehend the cause of the different action exercised
by the latter on the organ of sight. But as it is not my intention at
present to enter into any discussion on this subject, I shall leave it to
philosophers to assign a reason for this phænomenon, and only
observe, that the properties above indicated will be sufficient to
authorize medical practitioners to prefer, in certain cases, the
administration of Galvanism by the pile to that of common electricity.
Before I proceed directly to the medical administration of Galvanism
to the organ of sight, I think it necessary to distinguish four classes
of blind persons whose cases ought to be considered separately.
The first belongs to those who from their birth have been deprived
of the valuable blessing of sight.
The second comprehends those become blind in consequence of
some great læsion, or some derangement in the solids or in the
fluids which constitute the mechanism of the eye.
The third, those who have become blind by some morbid action,
though the mechanism of the eye has been little affected, and
though no impediment has occurred but in regard to the action of
the optic nerve.
The fourth class comprehends those who, though not actually
deprived of sight, have it much weakened in consequence of
disease, or of some other cause.
The administration of Galvanism does not hold forth much hope of a
cure to persons belonging to the first two classes. I however
resolved to attempt some experiments on this subject at Bologna;
but though there were a great many blind in that city, I found that
they had become so by the malignant influence of the small pox.
This observation will, I hope, be of service to the pursuits of the
celebrated Dr. Jenner, and of all those who exert themselves to
promote the beneficial practice of vaccine inoculation.
Being deprived, at Bologna, of any opportunity of trying the effects
of Galvanism in cases of persons born blind, I galvanised several
who had lost their sight at a very early age. I first applied the
Galvanism to the arms of five blind persons, some of whom had lost
their sight thirty, and others forty years and even more. By this
method they were familiarised with the idea of its mechanical action,
and learned to distinguish it from every other sensation. I then
applied Galvanism to the lips, and to the tip of the nose, in a
darkened apartment; but in three instances only the patients had a
real perception of light, to which they had been so long strangers. I
then applied it to cases of amaurosis, and at first had confident
expectation of effecting a perfect cure. One of my patients was a
woman, whom this disorder had deprived of the sight of one eye,
while that of the other was much weakened. After administering the
Galvanism different ways, I observed that the eye totally blind began
to have a perception of light, and that the sight of the one which
was weakened became much stronger. I then took a book, which I
held at a considerable distance from her; and removing it gradually
further as the Galvanism was administered, I observed, in
consequence of this method, that the patient’s sight daily improved.
But I must freely confess that the success obtained, though at first
flattering, was not of long duration; and that when the Galvanism
was discontinued a great deal of the benefit which had been
obtained was again lost. On this account, I was discouraged from
administering Galvanism any more in such cases. I am however of
opinion, that by varying the method of administration it may be
attended with some utility. I shall here observe, that having once
had occasion to administer common electricity in a similar case of
amaurosis, I was never able to excite the perception of a flash in the
eyes of the patient, though the electricity was applied directly to the
eye itself.
I have had few opportunities of applying Galvanism in diseases of
the organs of hearing. Besides, I thought it almost needless to try a
method which had been already brought to a state of perfection by
some of the most celebrated professors of Germany and Berlin. I
admired in particular a very ingenious machine, invented for that
purpose by a German philosopher, and lately constructed in England
by Mr. John Cuthbertson, an eminent philosophical and mathematical
instrument maker, and celebrated for having constructed the large
electrical machine of Harlem. The apparatus consists of a metal
lever, which by means of certain wheels and machinery rises and
falls every minute or second, and at each time of falling forms a
communication between certain parts of the patient and the pile. In
consequence of this arrangement, the interrupted action of the
Galvanism is renewed every time that the communication between
the patient and the pile is re-established. Before my departure from
London, I made several changes and improvements in the usual
construction of this apparatus, in order to give it as much simplicity
as possible. The following is the manner in which I caused it to be
constructed lately for my own use. One extremity of the lever which
forms the communication (Plate III. fig. 1.), is fixed to the base or
negative end of the pile, and the other terminates in a small
hammer, so placed as to strike a bell, which by means of a bason of
water is in communication with certain parts of the patient, while an
arc extends from the patient to the summit or positive end of the
pile. In consequence of this arrangement, every time that the small
hammer strikes the bell the Galvanic action of the pile is repeated.
In cases of deafness, I cause the patient to hold in one hand an
insulated metallic arc, one end of which is brought into contact with
the affected ear, and the other with the positive end of the pile; and
to immerse the other hand in a bason of salt water placed above the
bell. When this disposition has been made, the wheel-work is turned
round, which gives motion to the lever; and every time that the
hammer strikes the bell, a communication is formed between the
positive and negative ends of the pile: consequently there will then
be a circulation of the fluid, and the Galvanism will exercise a direct
action on the organ of hearing. The apparatus, constructed in this
manner, appears to me to be reduced to great simplicity: and
therefore I propose to extend the use of it, by employing it to
administer medical Galvanism to other diseased parts of the body.
Before I conclude this article, I must suggest a hint respecting the
application of Galvanism to diseases of the teeth, founded on
information communicated to me on this subject by Mr. Fowler, an
eminent dentist of London. When the caries is concealed from the
sight, Mr. Fowler employs the following method to discover the
affected tooth. He first insulates the patient; and having put into his
hand the electric chain, he applies a small piece of wire to the dens
sapientiæ, drawing it gradually over its surface: he then applies it to
the next tooth, repeating the operation, and proceeds in like manner
with the rest till he comes to the diseased tooth, which discovers
itself by a violent pain producing an involuntary commotion in the
body. It is always remarked, that when this tooth is extracted it
exhibits a carious part not before visible. This method, therefore, is
of great importance, as it frequently happens in such cases that the
dentist, not being able to distinguish the diseased tooth from the
rest, is obliged to draw some that are sound before he can discover
it.
SECTION III.
Application of Galvanism in cases of asphyxia and drowning.

I mentioned in the second part of this work the great influence


which Galvanism has in cases of asphyxia, and the preference which
ought to be given to it in comparison of other stimulants. Though
the observations offered in that part are sufficient to prove my
proposition, I shall add to them the following experiments:

EXPERIMENT I.
Some dogs and cats were immersed in a large pond till they gave no
external signs of respiration, or of muscular motion; and Galvanism
being immediately administered to them, according to the methods
already described, they were sometimes restored to life. I make use
of the term ‘sometimes,’ because, if animals are immersed in water
for a longer period than their organization can bear, and if the vital
powers are really destroyed, it is evident that it will be impossible to
restore them to life by any physical process whatever. I obtained the
same results from to animals thrown into a state of asphyxia in
different ways.

EXPERIMENT II.
Having applied Galvanism to the trunk of a dog, in the Hôpital de la
Charité at Paris, air seemed to escape from the tracheal artery on
every application of the arc. Being requested to repeat and confirm
this interesting experiment, I found myself under the necessity of
sacrificing a new victim to my Galvanic researches. As it was
necessary to examine the phænomenon while the body was in that
state of vitality most proper for the observation, I exposed the trunk
of another dog recently killed to the Galvanic action; and having
placed a taper near to the tracheal artery, it was extinguished twice
in succession by two applications of Galvanism. By repeating this
experiment, in Mr. Wilson’s anatomical theatre, Great Windmill-
street, and in the theatres of Guy’s and St. Thomas’s Hospital,
London, I found that the taper could be extinguished a greater
number of times.
These experiments give me sufficient reason to hope that Galvanism
may be administered with some advantage in cases of drowning. But
as I never had an opportunity of trying the effects of this stimulant
in such cases, I have requested several medical practitioners to pay
attention to this application of Galvanism, which may be of the
utmost importance to the cause of humanity. I have already
mentioned that the method which I propose is exceedingly simple;
that no anatomical operation whatever is required; that it is
attended with no danger; and that the possibility of saving the life is
in every case respected. Nothing is necessary but to immerse in salt
water one of the hands of the person subjected to the operation,
and then to apply the Galvanic current to one of the ears and to the
surface of the salt water.
Dr. Lettsom, a very zealous member of the Humane Society, having
been present at some of my experiments, I requested that he would
recommend the application of Galvanism in cases of drowning. He
assured me that he would use his endeavours to cause my method
to be tried, and I had several conferences with him on the subject,
that I might communicate to him such information as might tend to
facilitate the application of it. As the Galvanism in such cases ought
to be administered with great promptitude, we agreed that the
apparatus of the trough is preferable to that of the pile; and we
contrived the plan of a portable box to contain a trough, two arcs,
and a solution of common salt. Such an apparatus will be
exceedingly convenient, and may easily be employed in all cases of
drowning and of asphyxia.
SECTION IV.
Galvanism applied to the cure of melancholy madness.

Hospitals for lunatics present a spectacle which must excite


compassion in every breast not void of humanity, as they are in
general crowded with unfortunate beings, useless to themselves and
dangerous to others; while little hope is left of their being ever
restored to society. This is the case in particular with persons subject
to melancholy madness; on some of whom I tried last year the
effects of Galvanism. In consequence of a long series of painful and
disagreeable experiments made on myself, I was induced to
entertain great hopes from this remedy. I applied it to my ears and
to different parts of the head, in order that I might form a just
estimation of its power and influence on the brain. It is well known
that the strength and energy of the operations of the mind depend
on the state of the functions of the brain. It is well known also, that
a violent fall, or strong impression on the head, has often occasioned
great variations in the intellectual faculties. By such accidents some
have entirely lost the power of imagination; while, on the other
hand, some have acquired very great talents, or emerged from a
state of complete stupidity. These considerations gave me reason to
hope that the power of Galvanism might perhaps be able to produce
a salutary change in the brain in cases of melancholy madness. I
communicated my thoughts on this subject to the physicians who
superintend the hospital for lunatics at Bologna. They approved of
my ideas, and gave me every assistance in their power to enable me
to prosecute my researches. In their presence, and under their
direction, I administered Galvanism to several lunatics, applying it
different ways; and the result was the complete cure of two who had
laboured under melancholy madness. As the method I followed in
both cases was nearly the same, I shall here give a description of it,
as it may serve as a general rule for the administration of this
remedy under similar circumstances.
Louis Lanzarini, of a phlegmatic temperament, twenty-seven years of
age, and a farmer by profession, fell into a state of deep melancholy,
which first announced itself by an attack of fever; in consequence of
which he was conveyed to the public hospital of St. Ursula on the
17th of May 1801. When he arrived there, he began to complain of
the treatment he had received, and to show great uneasiness; by
which means his melancholy increased so much, that it at length
degenerated into real stupidity. While in this state, Professors Gentilli
and Palazzi were so kind as to allow me to administer Galvanism to
him; which I did in the presence of these physicians, and of several
medical students who attended the hospital.
I had provided for this purpose a pile composed of eighty pieces of
silver and zinc, and I at first administered the Galvanism gradually,
forming the arc by means of the hands. Lanzarini, in a state of the
utmost dejection, viewed the apparatus and the company present
with his eyes fixed and motionless. When interrogated by the
physicians and myself in regard to the origin of his malady, he gave
laconic and confused answers, which seemed to indicate a great
degree of stupidity and derangement. I first moistened his hands,
and formed an arc with the pile at different heights, to accustom him
to endure the action of the apparatus. No change, however, was
produced in the patient by this operation. I then repeated the
experiment, placing his hands, moistened with salt water, at the
bottom of the pile; and conveying an arc from the summit of the pile
to different parts of his face, moistened with the same solution. A
change was soon observed in the patient’s countenance, and his
whole demeanour seemed to indicate that the degree of his
melancholy was somewhat lessened. The experiment was repeated
several times with the same success; which seems to prove that
Galvanism absolutely exercises an action in such diseases. The
patient being interrogated next day, asserted that he had felt no
inconvenience from the application of the Galvanism; and this
account was confirmed by the keepers, who had been desired to
give a report of the least change that might take place. Similar
results were obtained by gradually administering the action of the
pile with greater force for several days successively, and we soon
began to observe that it produced a very striking effect. The patient,
on touching the apparatus, seemed to acquire new spirits; a smile
appeared on his countenance, and a complete change took place in
his eyes as well as in every feature of his face. Instead of showing
any aversion to the pile, he readily obeyed whenever he was called
to undergo the operation; and his whole conduct indicated that he
found relief from the influence of the unknown agent which it
excited. He began to converse with more readiness, sometimes
respecting the machine, and sometimes on the flash of light which
appeared in his eyes when the arc was applied; and on that account
we conceived the most flattering hopes of a complete cure. The
result of this operation induced me to administer the Galvanism even
to the substance of the brain; being convinced, as I have already
remarked, that the Galvanic fluid by this method of application
exercises its action with greater energy. I communicated my design
to the Professors of the hospital, and with their approbation began
to try the effects of a pile composed of fifteen plates of copper and
zinc. I formed an arc from one of the hands to one of the ears, and
then from one ear to another, having first moistened them with a
solution of muriate of soda. I increased the number of plates of
which the pile was composed, and found that the patient was always
more or less affected with a momentary impression exceedingly
painful, which however seemed in the end to produce a good effect.
When Galvanism was administered in this manner, I did not neglect
to continue the application of the other method at the same time;
and I found that the progress of the cure became more rapid. But as
I observed that the action of Galvanism on the ears was sometimes
too violent, we thought proper to apply it in a more moderate and
less dangerous manner. Several persons having been induced
through curiosity to try this action, the result, besides a violent
commotion of the whole substance of the brain against the skull,
was a state of watchfulness which continued several days running,
and which I experienced myself as well as others. We then
conceived the idea of shaving the head above the suture of the
parietal bone (Plate III. fig. 3.); and having moistened the shaven
part with salt water, a piece of gold or silver coin was placed over it.
The patient then touched with one of his hands the bottom of the
pile, and at the same time an arc was established from the summit
of the pile to the metallic armature placed on the head. By this
arrangement the action of the Galvanism was rendered more
moderate; the patient endured it for a long time, and seemed to be
greatly relieved by it. I have always united this method with external
application to different parts of the face, and have observed such
sudden changes in the looks as seemed to announce a considerable
abatement of the disease. Some of the physicians of Bologna,
Professors Brugnatelli and Zola of Pavia, and several other
foreigners, examined and confirmed the permanency of this effect.
The patient, therefore, not only got the better of his melancholy, but
began to relish his food, and at length recovered so much strength
that the physicians of the hospital thought nothing further was
necessary to complete the cure.
No other remedy besides Galvanism was administered to him, lest
the effects should be so confounded as to render it impossible to tell
to which the cure ought to be ascribed. Two days, however, before
he left the hospital a little blood was taken from him; as it was
conceived that this operation might contribute to render the cure
more certain.
On his leaving the hospital I carried him to my house, that he might
be fitted by proper nourishment for resuming his former
occupations. He remained with me eight days in the quality of a
domestic, during which time he was exceedingly tractable, and
performed his duty with great care and attention. I had several
conversations with him, in the course of which I learned that his
father, Fabian Lanzarini, had been attacked by the same disease, and
that he had been admitted into the same hospital, where he died on
the 12th of June 1790. By inspecting the registers of the hospital, I
found this account to be perfectly correct.
Agreeably to the principles already established, in regard to the
treatment of madness, I advised Lanzarini to spend the rest of his
life at a distance from his native country, lest, having continually
before his eyes those objects which had occasioned his disease, it
might recur with double violence. But though he had given me
several proofs of his docility, I found it impossible to persuade him to
make this sacrifice. A kind of nostalgia, perhaps, attached him to his
former master, to whom he returned, after paying a visit to the curé
of the parish. The latter, when he first saw him, imagined he had run
away from the hospital; but by his conversation he was soon
convinced of his being completely cured. After this period, I obtained
a regular report respecting his behaviour and the state of his health,
from the above curé, and from the person who had paid all the
expenses of his residence in the hospital; and I learned, with great
satisfaction, that he continued to enjoy good health, and to exercise
his usual employment.
By the same treatment I cured, of a similar disorder, Charles Bellini,
a labourer, who was restored to society in a shorter space of time,
because the affection was not so violent as in the preceding case.
The phænomena which took place when the patient was subjected
to the action of the pile, when the Galvanism was applied to the
brain, and during the whole progress of the cure, were nearly the
same. I must, however, freely acknowledge, that two cures are not
sufficient to establish the application of Galvanism as an universal
remedy in such cases. But on this account it ought not to be
rejected: at any rate it deserves further examination; for it is well
known that all remedies require certain conditions before they can
perform their effect. I have therefore several times found it
impossible to obtain the same result in other patients afflicted with
melancholy madness, to whom I administered Galvanism; and in
cases of raving madness I have even found it dangerous. In some
instances, melancholy madness derives its origin from a certain
general constitution of the animal machine, or from some great
alteration in the brain; and it is evident that in such cases the action
of Galvanism would be of no avail. But if the derangement of the
intellectual functions depend only on some humour intercepted
between the membranes and other parts of the brain, there is
reason to hope that Galvanism, if prudently administered, may be
attended with great benefit. The real cases in which it may be
administered with success, can be ascertained only by experience. I
must observe also, that the method of administering it is not yet
reduced to that state of simplicity, which is necessary before it can
be brought into regular use in large hospitals. The physicians, under
whose care they are placed, have in general a great deal of private
practice, and cannot conveniently attend to operations which require
a continued labour for several months. Besides, the novelty of the
remedy is sufficient to excite a clamour against it, and to awaken the
prejudice of the assistants, who will even wish to proscribe it before
it has been tried. For this reason, I think it necessary here to
request, that those who preside over establishments destined for the
reception of such patients would turn their attention to this subject,
and endeavour to reduce the method of applying Galvanism to the
utmost simplicity of which it is susceptible, in order that it may be fit
for being introduced into large hospitals. As the patient often shows
an aversion to this strange remedy, it will be necessary to encourage
him by every means possible. Sometimes on observing the flash of
light, when the Galvanism is communicated, he cries out and is
frightened; imagining that he sees a devouring fire ready to
consume him, and on this account refuses to submit again to the
operation. It will, therefore, be proper to conceal from him the
apparatus, or to make a person show him the pile some time before
as an object of amusement, and in this manner to prepare him for
receiving its action. It will be of benefit also sometimes to modify the
action of the pile, and to render it more moderate by a different
method of application. In the case of female patients I have found
the result the same, when the Galvanism, instead of being applied

You might also like