Category Archives: Programming

When not to program

It’s end of the semester time ’round here, and students I’m TAing are frantically trying to get their final projects working. One of the emails I fielded today was basically asking, “Is there a way to get MATLAB to automate this for me”.

The answer to the question, of course, is “yes”, but knowing that student’s comfort with programming, I phrased it more like, “Yes, you could do it by XYZ, but it’s probably just as easy to do it manually for the 6 data points you’re interested in”. What I didn’t write (but really meant) was essentially, “If you have to ask, the answer is no”.

It’s worth pointing out that the course isn’t designed for teaching general programming concepts (unlike other courses I’ve been involved with), and instead uses a very restricted set of MATLAB and programming concepts as a tool to understand biological modeling. It’s so restricted a set of concepts, in fact, that back in week 3 or 4, I wrote up a handout that was essentially a step-by-step recipe for doing the coding for all but one of the rest of the labs.

In grad school, there’s often two modes with somewhat opposing goals. First and foremost, you want to get stuff done. But you also want to leave things in a state where it will be possible to quickly and easily repeat things in the future. Sometimes, that latter goal is achieved by stopping before hand to think about the way to structure code, sometimes you even need to learn more skills which you will apply in the future (either programming or bench techniques or *gasp* math).

So in this student’s case, the answer (given that the final project is due in just a few days) is probably to do it the stupid, manual way that’s less elegant, but also much much faster than taking the time to really grok loops. In the long run of grad school, it won’t always be obvious where to spend more time making things faster, and where to just grind it out. And, of course, one final thought is that sometimes you can take longer to make it faster, and not succeed:

Teaching differential equations to biologists

Teaching, and especially teaching the same thing over again, is always an effort to iteratively refine how best to convey the information and understanding in your head to your students.

Analytical solutions

The first two equations we talked about in class were for exponential growth and logistic growth, both of which (happen to) have analytic solutions. It’s nice that they do, but I think it has perhaps gotten people into the frame of mind where they’re looking for those analytical solutions, or accidentally plugging them in when they should be using the differential equations.

If I were handed the reins for the next time this course will be offered, I’d try to avoid even writing the analytic solution to any of the differential equations.

Does this mean I think students should never be taught how to find analytical solutions? Absolutely not; I think there’s a lot of beautiful math that goes into deriving them. But for biology undergrads, many of whom haven’t taken a math class since AP Calculus in High School, the analytical solutions are a red herring. I think it’s worthwhile to help them understand what the graph itself will be shaped like, but being able to find the exact functional relationship isn’t usually necessary.

Walk through an example of numerically solving an ODE

For the way the course is set up, I think it’s necessary to step through an example of doing numerical integration—any numerical integration, even the Euler Method, which has terrible theoretical properties.

Thinking back on the first lecture, we actually did do this, but I think the problem was that it was presented as “Here’s a simulation of bacterial doubling”, rather than “here’s what ODE solvers do”. Did some students pick up on the fact that it’s actually one and the same thing? Maybe, but given that it didn’t occur to me, the TA, until writing this just now, I doubt if very many did.

Come up with a useful definition of steady state

… and stick to it. One of the things I noticed is that the lectures never really covered what we mean by steady state, and actually seems to use a different version of steady state depending on the context. I think it’s worthwhile spending a good amount of time determining the steady states for a system, as well as discussing stability (though none of my students seemed to have a problem with the idea of an unstable steady state).

I think distinguishing between a true steady state, and a few different examples of pseudo-steady state, where the system is still moving, but no longer dynamically interesting. In one case, autocatalysis in prion disease, the system undergoes a rapid shift from one degradable form to a non-degrading form, and so ultimately the system ended up producing an unbounded amount of the non-degradable form; while this isn’t a true steady state, I think that’s one kind of pseudo-steady state worth looking at. Perhaps more interestingly, in a separate example we looked at the pharmacokinetics of repeated doses of a medication, and due to the fact that the patient was taking discrete doses, the equations themselves don’t have a real steady state; nevertheless, the levels of the drug stabilizes, which I think offers lots of great hooks to calculus, and the idea that as we offer the doses more frequently, the plot becomes more of a smooth curve.

Flux analysis

I think one of the best ways to analyze systems, at least in a power of the technique vs simplicity sense, is to look at the total flux. At least in simple systems, there are certain quantities that are conserved or conserved in certain parts of the network, and it’s often useful to look at where that quantity ends up. For instance, I showed a few students who came to my office hours today that I could predict the quantity of a certain element in a system using that kind of analysis, and got pretty good accuracy.

Some of this grousing is really just Monday-morning quarterbacking, but it is really nice to have the opportunity to think about what I’d want to teach in the future, and the best ways to do it.