Patrice Koehl Department of Computer Science Genome Center Room 4319, Genome Center, GBSF 451 East Health Sciences Drive University of California Davis, CA 95616 Phone: (530) 754 5121 koehl@cs.ucdavis.edu

# Lab2: Graphing and Programming

With this lab, you will practice some programming as well as to more graphing

### Handouts

Graphing and Programming:

or

### Exercise 1: Checking if a matrix is magic

A magic square is a square that produces the same sum, when its elements are added row-wise, column-wise or diagonally (both main diagonal and anti-diagonal). A matrix is magic if it represents a magic square. For example,

 16 2 3 13 5 11 10 8 9 7 6 12 4 14 15 1

is a magic matrix with sum = 34.

Write a small program that checks if a matrix of any size is magic.

### Exercise 2: Challenge: sum of Fibonacci numbers

Remember the Fibonacci sequence from Lab 1. As a reminder, it is defined as follows:

Write a MATLAB script that computes the sum of the Fibonacci numbers Fn, for n between 1 and a given number N, with Fn being a multiple of 2 or 5.

For example, when N = 5, only F3 and F5 are multiples of 2 or 5, and the sum is: S = F3 + F5 = 7.

Check your program for N = 10, 15, 20, and 30 (in which cases S = 104, 858, 10207, and 1171004).

### Exercise 3: Analyzing biological data

A simple experiment was designed to analyze the effects of noise on gene expression within a cell: a cell has been engineered to contain two genes (which we will label as C and Y) that are supposed to be expressed identically. In the presence of noise however, the expression levels will differ. There are two possible source of noise:

• Extrinsic noise: noise related to all external factors that may affect gene expression
• Intrinsic noise: noise related to the gene expression machinery itself

Two different experiments were conducted, each with a different type of cell. In experiment 1, data (i.e. expression levels for C and Y) were collected for 30 cells, while in experiment 2, data were available for 37 cells. The raw data are in the two files:

Data_exp1.dat Data for experiment 1
Data_exp2.dat Data for experiment 2
(In each file, the first and second columns correspond to the expression levels of C and Y, respectively).

Write a Matlab script for analyzing these data:

1. Generate a plot (scattered plot) of Y as a function of C for each experiment
2. Compute the levels of intrinsic, $$\eta_{int}^2$$, extrinsic, $$\eta_{ext}^2$$, and total $$\eta_{tot}^2$$ noise in each experiment

You will use the formula:

$$\eta_{int}^2 = \frac{\left \langle (c-y)^2 \right \rangle}{2\langle c \rangle \langle y \rangle} \quad \quad \eta_{ext}^2 = \frac{\langle cy \rangle - \langle c \rangle \langle y \rangle}{\langle c \rangle \langle y \rangle} \quad \quad \eta_{tot}^2 = \frac{\langle c^2 + y^2 \rangle - 2\langle c \rangle \langle y \rangle}{2 \langle c \rangle \langle y \rangle}$$