Biology, Computation

Basic Mathematical Biology Programming Part I

Programming elements that are used to perform basic mathematical calculations include:

  1. Arrays
  2. Matrices
  3. Equations or Simple functions
  4. Math functions

This post will deal with the first two.


Sets are common in mathematical biology : response values, independent values, time units, gene or protein names. These sets can be expressed as arrays. The two most common array types are integer and character arrays. Integer arrays are used to keep a set of numbers together. Instead of defining each time individually

time_1=0; time_2=1; time_3=5; . . .

the set of times can be defined as an array:

time \begin{Bmatrix}  0,1,5,10,15,25,26,30\end{Bmatrix}

Now, to refer to a specific time, we can call time(i) where i = the position of the time we are interested in. Ie, the first time point is time(1).

Character arrays can be used to keep non-numerical characters together:

genes = \begin{Bmatrix} 'YAL054C'&'YAL060W'&'YAL038W'&'YAL039C'&'YAL012W'&'YAL044C' \end{Bmatrix}

If an operation needs to be performed on multiple time units, or genes, then the entire set can be passed to the function performing the operation.


Matrices are useful when dealing with two dimensional data. For example, if each gene has a corresponding expression level:

\begin{Bmatrix} genes \\ expression \end{Bmatrix} = \begin{Bmatrix}  'YAL054C'&'YAL060W'&'YAL038W'&'YAL039C'&'YAL012W'&'YAL044C'\\ 1&3&20&0&30&40 \end{Bmatrix}

This matrix has two rows (genes, expression) and six columns (one for each gene/expression pair). It is often helpful to consider whether we want the rows or the columns to contain a subset of data. For example, if we have multiple observations of expression for the gene set, we could define the matrix in two ways.

matrix \begin{Bmatrix} 'YAL054C' &'YAL060W'&\cdots \\ 1 & \vdots & \\ 20 & \vdots &  \end{Bmatrix}

This gives a matrix where the first row is the gene names, the other 3 rows are the different expression observations. Here each column contains a subset of data, so if we want to plot the expression for YAL054C, we can look down the first column. Alternatively,

matrix = \begin{Bmatrix}   'YAL054C' & 1 & 20 & 5 \\ 'YAL060W' & .&. &. \\ \vdots &&& \end{Bmatrix}

Now the first column is the gene name, and each row contains the gene name and the 3 observations. Now each row is containing the subset of data.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s