Day 10 Pre-Class: Viral Kinetics#

✅ Put your name here

#

Goals for today’s pre-class assignment:#

  • Practice using solve_ivp to build a viral kinetics model

  • Once you have a functioning model, explore the impact that various parameters have on the model’s behavior

Assignment instructions#

This assignment is due by 7:59 p.m. the day before class, and should be uploaded into the appropriate “Pre-class assignments” submission folder. Submission instructions can be found at the end of the notebook.


Before we get started, we’re going to import all of the necessary libraries. Note that we’re using SciPy’s solve_ivp package, we’ve worked with recently. solve_ivp accurately and quickly solves wide classes of ODEs. Make sure you execute the cell!

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
%matplotlib inline

# Note that the SciPy library is needed for solve_ivp
from scipy.integrate import solve_ivp

Now, execute the cell below and watch the video about Ordinary Differential Equations (ODEs) and Compartmental Modeling. Compartmental models are really useful when we can divide up a system into distinct populations or quantities and then define equations for how those populations/quantities evolve and interact. After you watch the video, you’ll have a chance to build your own compartmental model to understand how viruses spread.

from IPython.display import YouTubeVideo 
YouTubeVideo("0N3qB5vaJhA",width=640,height=360)

Now that we know a bit more about compartmental models, let’s dig into the following model for Viral Infections!#


Viral Infections#


Viral infections are one the main causes of disease in humans and recently have been the reason behind the global COVID-19 pandemic. Along with bacteria and parasite infections, viral infections are caused by the introduction of a microscopic “organism” into our bodies. Sometimes these viruses live in our bodies throughout our lifetime with little damage; sometimes, they quickly kill us.

We would like to build a model for how viruses infected the cells of our body. We will consider an infection in which our immune system is able to clear the virus. Since winter is coming, consider this to be the influenza virus.

How do viruses work? We need to understand a bit about this in order to build our model. The most important feature is that viruses cannot reproduce on their own - that is what they need you for. Your body, to a virus, is simply a factory for making and spreading more of them. If virions were writing the history books, humans would simply be their maternity ward. The way this works is that virions enter your cells, where there is a factory at work to keep the cell functioning, and they give all of the factory workers new instructions. A factory that was making cars, once the virions enter, is now making laptops; or, in this case, rather than keeping the cell alive and healthy, the machinery of the cells makes more virions. For every virion that enters a cell, that cell might make hundreds of new virions, leading to a population explosion. Your body will need to quickly mount an immune response to keep this under control.

What compartments might we need? (Look at the picture above.)

  • Target cells; these are the healthy cells the virion might enter

  • Infected cell; these cells produce new virions, and might die over time

  • Virion population; the number of virions at any given time during the infection

What parameters will we need?

  • rate at which cells become infected: this reduces the value of T and increases the value of I

  • the production rate of new virions, which increases the value of V

  • rate at which infected cells die

  • rate at which virions degrade and leave the system


Viral Kinetics (VK) Model#


A simple model is then: $\(\frac{dT}{dt} = -\beta TV,\)$

\[\frac{dI}{dt} = \beta TV - \delta I,\]
\[\frac{dV}{dt} = pI - rV.\]

Models like this are called “viral kinetics” models, or VK for short. Note that due to terms like \(TV\), these are non-linear ODEs and almost never have simply solution: we need a computational approach. But, because this is so incredibly common, nice Python libraries make this super easy.


REVIEW: Setting up solve_ivp()#

Let’s pause our focus on VK modeling to examine how we can set up all problems of this type.

You’ve already spent some time working with solve_ivp(), but we’re including the following information to provide a more detailed framework for how you can think about using solve_ivp() to solve a system of ODEs. Watch the video in the cell below for a review!