Machine Learning in Biotechnology and Life Sciences - Saleh Alkhalifa - E-Book

Machine Learning in Biotechnology and Life Sciences E-Book

Saleh Alkhalifa

0,0
39,59 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

The booming fields of biotechnology and life sciences have seen drastic changes over the last few years. With competition growing in every corner, companies around the globe are looking to data-driven methods such as machine learning to optimize processes and reduce costs. This book helps lab scientists, engineers, and managers to develop a data scientist's mindset by taking a hands-on approach to learning about the applications of machine learning to increase productivity and efficiency in no time.

You’ll start with a crash course in Python, SQL, and data science to develop and tune sophisticated models from scratch to automate processes and make predictions in the biotechnology and life sciences domain. As you advance, the book covers a number of advanced techniques in machine learning, deep learning, and natural language processing using real-world data.

By the end of this machine learning book, you'll be able to build and deploy your own machine learning models to automate processes and make predictions using AWS and GCP.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB
MOBI

Seitenzahl: 412

Veröffentlichungsjahr: 2022

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Machine Learning in Biotechnology and Life Sciences

Build machine learning models using Python and deploy them on the cloud

Saleh Alkhalifa

BIRMINGHAM—MUMBAI

Machine Learning in Biotechnology and Life Sciences

Copyright © 2022 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

Publishing Product Manager: Ali Abidi

Senior Editor: David Sugarman

Content Development Editor: Nathanya Dias

Technical Editor: Rahul Limbachiya

Copy Editor: Safis Editing

Project Coordinator: Aparna Ravikumar Nair

Proofreader: Safis Editing

Indexer: Pratik Shirodkar

Production Designer: Joshua Misquitta

Marketing Coordinator: Abeer Riyaz Dawe

First published: January 2022

Production reference: 1221221

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham

B3 2PB, UK.

ISBN 978-1-80181-191-0

www.packt.com

Contributors

About the author

Saleh Alkhalifa is a data scientist and manager in the biotechnology industry with 4 years of industry experience working and living in the Boston area. With a strong academic background in the applications of machine learning for discovery, prediction, forecasting, and analysis, he has spent the last 3 years developing models that touch all facets of business and scientific functions.

I would like to dedicate this book to my parents, Esam Alkhalifa and Anna Letz, without whose motivation and support I would not be the scientist I am today.

About the reviewers

Indraneel Chakraborty is a data science enthusiast with an open mindset and a passion for solving data problems with code and building cloud-based data apps. He has both academic and industrial skill sets that include experience in the curation and analysis of clinical trials registry data for insights into policy research and also experience working with biomedical data providing ML/AI-ready solutions. He enjoys coding in Python and R, with lots of Googling, of course!

Dr Neha Kalla has a PhD in biotechnology from Banasthali University, India. During her PhD, she spent time working as a project assistant in an Indo-Danish project and also worked at the Centre for Conservation and Utilization of BGA, Indian Agricultural Research Institute, India. After completing her PhD, she developed associations with some of the most renowned professors and scientists across India and at Cambridge University. Following a long stint in research and academia, she decided to proceed with her career as a data scientist. She is presently working as a senior data scientist in the sphere of AI, offering machine learning-based retail solutions in Germany.

Table of Contents

Preface

Section 1: Getting Started with Data

Chapter 1: Introducing Machine Learning for Biotechnology

Understanding the biotechnology field

Combining biotechnology and machine learning

Exploring machine learning software

Python (programming language)

MySQL (database)

AWS and GCP (Cloud Computing)

Summary

Chapter 2: Introducing Python and the Command Line

Technical requirements

Introducing the command line

Creating and running Python scripts

Installing packages with pip

When things don't work…

Discovering the Python language

Selecting an IDE

Data types

Tutorial – getting started in Python

Creating variables

Importing installed libraries

General calculations

Lists and dictionaries

Arrays

Creating functions

Iteration and loops

List comprehension

DataFrames

API requests and JSON

Parsing PDFs

Pickling files

Object-oriented programming

Tutorial – working with Rdkit and BioPython

Working with Small Molecules and Rdkit

Summary

Chapter 3: Getting Started with SQL and Relational Databases

Technical requirements

Exploring relational databases

Database normalization

Types of relational databases

Tutorial – getting started with MySQL

Installing MySQL Workbench

Creating a MySQL instance on AWS

Working with MySQL

Creating databases

Querying data

Conditional querying

Grouping data

Ordering data

Joining tables

Summary

Chapter 4: Visualizing Data with Python

Technical requirements

Exploring the six steps of data visualization

Commonly used visualization libraries

Tutorial – visualizing data in Python

Getting data

Summarizing data with bar plots

Working with distributions and histograms

Visualizing features with scatter plots

Identifying correlations with heat maps

Displaying sequential and time-series plots

Emphasizing flows with Sankey diagrams

Visualizing small molecules

Visualizing large molecules

Summary

Section 2: Developing and Training Models

Chapter 5: Understanding Machine Learning

Technical requirements

Understanding ML

Overfitting and underfitting

Developing an ML model

Data acquisition

Exploratory data analysis and preprocessing:

Developing and validating models

Saving a model for deployment

Summary

Chapter 6: Unsupervised Machine Learning

Introduction to UL

Understanding clustering algorithms

Exploring the different clustering algorithms

Tutorial – breast cancer prediction via clustering

Understanding DR

Avoiding the COD

Tutorial – exploring DR models

Summary

Chapter 7: Supervised Machine Learning

Understanding supervised learning

Measuring success in supervised machine learning

Measuring success with classifiers

Measuring success with regressors

Understanding classification in supervised machine learning

Exploring different classification models

Tutorial: Classification of proteins using GCP

Understanding regression in supervised machine learning

Exploring different regression models

Tutorial: Regression for property prediction

Summary

Chapter 8: Understanding Deep Learning

Understanding the field of deep learning

Neural networks

The perceptron

Exploring the different types of deep learning models

Selecting an activation function

Measuring progress with loss

Deep learning with Keras

Understanding the differences between Keras and TensorFlow

Getting started with Keras and ANNs

Tutorial – protein sequence classification via LSTMs using Keras and MLflow

Importing the necessary libraries and datasets

Checking the dataset

Splitting the dataset

Preprocessing the data

Developing models with Keras and MLflow

Reviewing the model's performance

Tutorial – anomaly detection in manufacturing using AWS Lookout for Vision

Summary

Chapter 9: Natural Language Processing

Introduction to NLP

Getting started with NLP using NLTK and SciPy

Working with structured data

Searching for scientific articles

Exploring our datasets

Tutorial – clustering and topic modeling

Working with unstructured data

OCR using AWS Textract

Entity recognition using AWS Comprehend

Tutorial – developing a scientific data search engine using transformers

Summary

Chapter 10: Exploring Time Series Analysis

Understanding time series data

Treating time series data as a structured dataset

Exploring the components of a time series dataset

Tutorial – forecasting demand using Prophet and LSTM

Using Prophet for time series modeling

Using LSTM for time series modeling

Summary

Section 3: Deploying Models to Users

Chapter 11: Deploying Models with Flask Applications

Understanding API frameworks

Working with Flask and Visual Studio Code

Using Flask as an API and web application

Tutorial – Deploying a pretrained model using Flask

Summary

Chapter 12: Deploying Applications to the Cloud

Exploring current cloud computing platforms

Understanding containers and images

Understanding the benefits of containers

Tutorial – deploying a container to AWS (Lightsail)

Tutorial – deploying an application to GCP (App Engine)

Tutorial – deploying an application's code to GitHub

Summary

Other Books You May Enjoy

Section 1: Getting Started with Data

This section describes the basics of Python, SQL, and translating raw data into meaningful visualizations and representations as the first step of a strong data science project. Novice students generally find themselves overwhelmed by the vast amount of data science content found on the internet or in print. This book remedies this issue by focusing on the most important and valuable must-know elements for getting started in the field.

This section comprises the following chapters:

Chapter 1, Introducing Machine Learning for BiotechnologyChapter 2, Introducing Python and the Command LineChapter 3, Getting Started with SQL and Relational DatabasesChapter 4, Visualizing Data with Python

Chapter 1: Introducing Machine Learning for Biotechnology

How do I get started? This is a question that I have received far too frequently over my last few years as a data scientist and consultant operating in the technology/biotechnology sectors, and the answer to this question never really seemed to change from person to person. My recommendation was generally along the lines of learning Python and data science through online courses and following a few tutorials to get a sense of how things worked. What I found was that the vast majority of scientists and engineers that I have encountered, who are interested in learning data science, tend to get overwhelmed by the large volume of resources and documentation available on the internet. From Getting Started in Python courses to Comprehensive Machine Learning guides, the vast majority of those who ask the question How do I get started? often find themselves confused and demotivated just a few days into their journey. This is especially true for scientists or researchers in the lab who do not usually interact with code, algorithms, or predictive models. Using the Terminal command line for the first time can be unusual, uncomfortable, and – to a certain extent – terrifying to a new user.

This book exists to address this problem. This is a one-stop shop to give scientists, engineers, and everyone in-between a fast and efficient guide to getting started in the beautiful field of data science. If you are not a coder and do not intend to be, you have the option to read this book from cover to cover without ever using Python or any of the hands-on resources. You will still manage to walk away with a strong foundation and understanding of machine learning and its useful capabilities, and what it can bring to the table within your team. If you are a coder, you have the option to follow along on your personal computer and complete all the tutorials we will cover. All of the code within this book is inclusive, connected, and designed to be fully replicable on your device. In addition, all of the code in this book and its associated tutorials is available online for your convenience. The tutorials we will complete can be thought of as blueprints to a certain extent, in the sense that they can be recycled and applied to your data. So, depending on what your expectations of the phrase getting started are, you will be able to use this book effectively and efficiently, regardless of your intent to code. So, how do we plan on getting started?

Throughout this book, we will introduce concepts and tutorials that cater to problems and use cases that are commonly experienced in the technology and biotechnology sectors. Unlike many of the courses and tutorials available online, this book is well-connected, condensed, and chronological, thus offering you a fast and efficient way to get up to speed on data science. In under 400 pages, we will introduce the main concepts and ideas relating to Python, SQL, machine learning, deep learning, natural language processing, and time-series analysis. We will cover some popular approaches, best practices, and important information every data scientist should know. In addition to all of this, we will not only put on our data scientist hats to train and develop several powerful predictive models, but we will also put on our data engineer hats and deploy our models to the cloud using Amazon Web Services (AWS) and Google Cloud Platform (GCP). Whether you are planning to bring data science to your current team, train and deploy the models yourself, or start interviewing for data scientist positions, this book will equip you with the right tools and resources to start your new journey, starting with this first chapter. In the following sections, we will cover a few interesting topics to get us started:

Understanding the biotechnology fieldCombining biotechnology and machine learningExploring machine learning software

With that in mind, let's look at some of the fun areas within the field of biotechnology that are ripe for exploration when it comes to machine learning.

Understanding the biotechnology field

Biotechnology, as the name suggests, can be thought of as the area of technological research relating to biology when it comes to living organisms or biological systems. First coined in 1919 by Karoly Ereky, the father of biotechnology, the field traditionally encompassed the applications of living organisms for commercial purposes.

Some of the earliest applications of biotechnology throughout human history include the process of fermenting beer, which dates as far back as 6,000 BC, or preparing bread using yeast in 4,000 BC, or even the development of the earliest viral vaccines in the 1700s.

In each of these examples, scientific or engineering processes utilized biological entities to produce goods. This concept was true then and had remained just as true throughout human history. Throughout the 20th century, major innovative advancements were made that changed the course of mankind for the better. In 1928, Alexander Fleming identified a mold that halted the replication of bacteria, thus leading to penicillin – the first antibiotic. Years later, in 1955, Jonas Salk developed the first polio vaccine using mammalian cells. Finally, in 1975 one of the earliest methods for the development of monoclonal antibodies was developed by George Kohler and Cesar Milstein, thus reshaping the field of medicine forever:

Figure 1.1 – A timeline of a few notable events in the history of biotechnology

Toward the end of the 20th century and the beginning of the 21st century, the field of biotechnology expanded to cover a diverse bevy of sub-fields, including genomics, immunology, pharmaceutical treatments, medical devices, diagnostic instruments, and much more, thus steering its focus away from its agricultural applications and more on human health.

Success in Biotech Health

Over the last 20 years, many life-changing treatments and products have been approved by the FDA. Some of the industry's biggest blockbusters include Enbrel® and Humira®, monoclonal antibodies for treating rheumatoid arthritis; Keytruda®, a humanized antibody for treating melanoma and lung cancer; and, finally, Rituxan®, a monoclonal antibody for treating autoimmune diseases and certain types of cancer. These blockbusters are but a sample of the many significant advances that have happened in the field over the past few decades. These developments contributed to creating an industry that's larger than many countries on Earth while changing the lives of millions of patients for the better.

The following is a representation of a monoclonal antibody:

Figure 1.2 – A 3D depiction of a monoclonal antibody

The biotechnology industry today is flourishing with many new and significant advances for treating illnesses, combatting diseases, and ensuring human health. However, with the space advancing as quickly as it is, the discovery of new and novel items is becoming more difficult. A great scientist once told me that advances in the biopharmaceutical industry were once made possible by pipettes, and then they were made possible by automated instruments. However, in the future, they will be made possible by ArtificialIntelligence (AI). This brings us to our next topic: machine learning.

Combining biotechnology and machine learning

In recent years, scientific advancements in the field, boosted by applications of machine learning and various predictive technologies, have led to many major accomplishments, such as the discovery of new and novel treatments, faster and more accurate diagnostic tests, greener manufacturing methods, and much more. There are countless areas where machine learning can be applied within the biotechnology sector; however, they can be narrowed down to three general categories:

Science and Innovation: All things related to the research and development of products.Business and Operations: All things related to processes that bring products to market.Patients and Human Health: All things related to patient health and consumers.

These three categories are essentially a product pipeline that begins with scientific innovation, where products are brainstormed, followed by business and operations, where the product is manufactured, packaged, and marketed, and finally the patients and consumers that utilize the products. Throughout this book, we will touch on numerous applications of machine learning as they relate to these three fields within the various tutorials that will be presented. Let's take a look at a few examples of applications of machine learning as they relate to these areas:

Figure 1.3 – The development of a product highlighting areas where AI can be applied

Throughout the life cycle of a given product or therapy, there are numerous areas where machine learning can be applied – the only limitation is the existence of data to support the development of a new model. Within the scope of science and innovation, there have been significant advances when it comes to predicting molecular properties, generating molecular structures to suit specific therapeutic targets, and even sequencing genes for advanced diagnostics. In each of these examples, AI has been – and continues to be – useful in aiding and accelerating the research and development of new and novel products. Within the scope of business and operations, there are many examples of AI being used to improve processes such as intelligently manufacturing materials to reduce waste, natural language processing to extract insights from scientific literature, or even demand forecasting to improve supply chain processes. In each of these examples, AI has been crucial in reducing costs and increasing efficiency. Finally, when it comes to patients and health, AI has proven to be pivotal when it comes to recruiting people for and shaping clinical trials, developing recommendation engines designed to avoid drug interactions, or even faster diagnoses, given a patient's symptoms. In each of these applications, data was obtained, used to generate a model, and then validated.

The applications of AI we have observed thus far are only a few examples of the areas where powerful predictive models can be applied. In almost every process throughout the cycle where data is available, a model can be prepared in some way, shape, or form. As we begin to explore the development of many of these models in various areas throughout this process, we will need a few software-based tools to help us.

Exploring machine learning software

Before we start developing models, we will need to few tools to help us. The good news is that regardless of whether you are using a Mac, PC, or Linux, almost everything we will use is compatible with all platforms. There are three main items we will need to install: a language to develop our models in, a database to store our data in, and a cloud computing space to deploy our models in. Luckily for us, there is a fantastic technology stack ready to support our needs. We will be using the Python programming language to develop our models, MySQL to store our data, and AWS to run our cloud computing processes. Let's take a closer look at these three items.

Python (programming language)

Python is one of the most commonly used programming languages and sought-after skills in the data science industry today. It was first developed in 1991 and is regarded today as the most common language for data science. For this book, we will be using Python 3.7. There are several ways you can install Python on your computer. You can install the language in its standalone form from Python.org. This will provide you with a Python interpreter in its most basic form where you can run commands and execute scripts.

An alternative installation process that would install Python, pip (a package to help you install and manage Python libraries), and a collection of other useful libraries can be done by using Anaconda, which can be retrieved from anaconda.com. To have a working version of Python and its associated libraries on your computer as quickly as possible, using Anaconda is highly recommended. In addition to Python, we will need to install libraries to assist in a few areas. Think of libraries as nicely packaged portions of code that we can import and use as we see fit. Anaconda will, by default, install a few important libraries for us, but there will be others that we will need. We can install those on-the-go using pip. We will look at this in more detail in the next chapter. For the time being, go ahead and install Anaconda on your computer by navigating to the aforementioned website, downloading the installation that best matches your machine, and following the installation instructions provided.

MySQL (database)

When handling vast quantities of information, we will need a place to store and save all of our data throughout the analysis and preprocessing phases of our projects. For this, we will use MySQL, one of the most common relational databases used to store and retrieve data. We will take a closer look at the use of MySQL by using SQL. In addition to the MySQL relational database, we will also explore the use of DynamoDB, a non-relational and NoSQL database that has gained quite a bit of popularity in recent years. Don't worry about getting these setups right now – we will talk about getting them set up later on.

AWS and GCP (Cloud Computing)

Finally, after developing our machine learning models in Python and training them using the data in our databases, we will deploy our models to the cloud using both Amazon Web Services (AWS), and Google Cloud Platform (GCP). In addition to deploying our models, we will also explore a number of useful tools and resources such as Sagemaker, EC2, and AutoPilot (AWS), and Notebooks, App Engine, and AutoML (GCP).

Summary

In this chapter, we gained a quick understanding of the field of biotechnology. First, we looked at some historical facts as they relate to the field, as well as some of the ways this field has been reshaped into what it looks like today. Then, we explored the areas within the field of biotechnology that are most impacted by machine learning and AI. Finally, we explored some of the most common and basic machine learning software you will need to get started in the field.

Throughout this book, Python and SQL will be the main languages we will use to develop all of our models. We will not only go through the specific instructions of how to install each of these requirements, but we will also gain hands-on knowledge throughout the many examples and tutorials within this book. AWS and GCP will be our two main cloud-based platforms for deploying all of our models, given their commonality and popularity among data scientists.

In the next chapter, we'll introduce the Python command line. With that in mind, let's go ahead and get started!