Posts RSS Comments RSS 63 Posts and 41 Comments till now

Archive for August, 2007

Programmer Virtue in Molecular Biology

Larry Wall taught us the three great virtues: laziness, hubris, and ego. I have long cultivated this in my life, and continue to do so now that I am a biologist.

My latest act of virtue (or perhaps virtù) involves selecting restriction enzymes for some cloning. Starting with a plasmid and a sequence I want to replicate in it, I need enzymes A, B, C, D, E, and X with the following properties:

  • A and B have compatible ends, but when those two ends are ligated, none of the enzymes can recut them.
  • None of the others have compatible ends.
  • A must appear one time in the plasmid without the insert.
  • B and C must not appear in the plasmid.
  • D, E, and X must appear one time in the plasmid.

Don’t worry about where these rules come from for now. I’ll explain another time. Instead, let us focus on my tool for laziness: Prolog. In Prolog, you write down a set of logical propositions and rules, and then query them. This sounds fairly trivial, but it’s in fact really, really useful.

I typed in NEB’s compatible cohesive ends table for their restriction enzymes, which consisted of many lines that looked like this:

compatible(spei, [avrii,nhei,styi,xbai], [bfai]).

This is an example of a fact in prolog. It consists of a label for the fact (compatible), and a series of arguments. The first argument is the enzyme, the second is the list of compatible enzymes (lists are enclosed in [], and the entries are separated by commas), and the third is the list of enzymes that recleave such a ligation. I can create as many facts as I like with the same label and different arguments. In this case, it’s one for every line of that NEB table. Then I can define rules which let Prolog derive more facts from the simple facts I have given it:

is_compatible(X,X) :- true.
is_compatible(X,Y) :- compatible(X,F,_), member(Y,F).


The first line says that any sites cleaved by the same enzyme are compatible. The second says two enzymes are compatible is the second is a member of the list of compatible enzymes of the first.

is_incompatible(X,Y) :- \+ is_compatible(X,Y).

And to be incompatible, they must not be compatible (\+ is ‘not’ in Prolog). Here’s another predicate which is fairly straightforwards:

is_recleaved_by(A,A,A) :- true.
is_recleaved_by(X,Y,Z) :- compatible(X,G,F),member(Y,G),member(Z,F).

Then I put in the list of the restriction enzymes I have on hand: ncutter(aatii). and so forth. I also declare two lists for sites in the plasmid: restriction sites which appear once in the plasmid, and sites that do not appear in the plasmid (among those enzymes I have on hand):

m361_1([aatii, ecori, hindiii, hpai, kpni, mlui, ndei, nhei, noti, pvuii, spei, sphi, xhoi, xmni]).
m361_0([asci, ecorv, ncoi, paci, sbfi, scai, sfoi, snabi]).
And some convenience predicates so I don’t have to dig into the lists all the time:

singleM361(A) :- m361_1(B), member(A,B).
zeroM361(A) :- m361_0(B), member(A,B).

As an exercise, try to figure out what these do:

unrecleavable_pair(A,B) :-
is_compatible(A,B),
\+ is_recleaved_by(A,B,A),
\+ is_recleaved_by(A,B,B).

incompatible_with(_,[]) :- true.
incompatible_with(X,[Y|Ys]) :-
is_incompatible(X,Y),
incompatible_with(X,Ys).

incompatible_set([_]) :- true.
incompatible_set([X,Y|Xs]) :-
incompatible_with(X,[Y|Xs]),
incompatible_set([Y|Xs]).

Then I encode most of my rules into one query:

enzyme_set(A,B,C,X) :-
ncutter(A), ncutter(B),
unrecleavable_pair(A,B),
ncutter(C), ncutter(X),
incompatible_set([A,C,X]),
incompatible_set([B,C,X]).

Now I ask for sets of A, B, C, and X which work:

?- enzyme_set(A,B,C,X), singleM361(A), singleM361(X), zeroM361(B), zeroM361(C).

Prolog gives me every possible set. I look at my plasmid map and pick one that seems reasonable (A=MluI, B=AscI, C=EcoRV, X=AatII). Then I cheat a bit, look for a pair of enzymes in the polylinker that only appear once in the plasmid, and which are incompatible with everything else (which I check in Prolog as well).

It’s not as automated as it could be, nor is it elegant, but compare this to searching through enzymes descriptions by hand! Nor should you be intimidated by the language. I began this with a bare minimum of Prolog, which I picked up in about two hours by reading the first three chapters of Clocksin and Mellish’s Programming in Prolog.

How to learn to program

Peter Norvig has addressed this question. Eric Raymond has his nice essay on the subject. But these don’t provide much guidance for the beginner who wants to know “which books do I sit down and churn through?”

The short answer: The Haskell Road to Maths, Logic, and Programming by Doets and van Eijck (what appears to be an earlier draft is available in PDF here), and then Abelson and Sussman’s Structure and Interpretation of Computer Programs (also available online).

The long answer:

Until you understand what Abelson and Sussman are about in their book, you’re missing the whole point of computer science. Peter Norvig wrote about it,

“…if you’re like me, you’re not looking for one more trick, rather you’re looking for a way of synthesizing what you already know and building a rich framework onto which you can add new learning over a career. That’s what SICP has done for me. I read a draft version of the book around 1982 and it changed the way I think about my profession.”

Unfortunately, SICP requires a fair degree of intellectual, indeed mathematical, maturity. That’s where Doets and van Eijck comes in. Hopefully it will guide you far enough up the slope where SICP makes sense.

After this, there remains only one development in programming languages which you won’t be able to take completely in stride: monads and all the apparatus around them. But that’s a story for another day.

BIO2010 (Part 3)

In my previous post on the Bio2010 report I gave some principles to guide curriculum design. Remember, the goal is a mature and sophisticated mind, not a knowledge of any particular subfield. I’m not qualified to select the content for such a curriculum, so please suggest changes. We’ll begin with a survey of the advanced undergraduate courses.

Neurobiology: I give neurobiology its own place because certain aspects of it are very mature and therefore a prime field for training minds. For similar reasons, immunology makes no appearance in this list, as the field is too contorted, at least as represented in the textbooks, to usefully train anyone.

The first milestone of the course is a physical understanding of the Hodgkin-Huxley model, and how it came to be. This will probably take half a semester.

After Hodgkin-Huxley, I am out of my depth. The two obvious directions are the essential features of the synapse, and the basics of neural architecture, probably using vision and hearing as the models. This brief discussion (warning: PDF) has some interesting references, but I have not had time to follow them up.

Molecular biology has two aspects. The first is structural understanding of the three major biopolymers (DNA, RNA, and protein); the second is designing protocols to manipulate them. Students should not only understand the structural differences between GC rich vs. AT rich helices (at the level of something like Calladine’s Understanding DNA), but also why each step in a miniprep is there, and how to calculate what it should be in the absence of a protocol. This means they need quantitative descriptions of sedimentation and separation by centrifugation, chromatography, and amplification by various kinds of PCR. Then move on to models of transcription and translation, and mechanics of molecular motors. This course will probably take about a year.

Evolution and ecology begins with population genetics (Gillespie’s Population Genetics seems about right), epidemiology (some selection from Diekmann and Heesterbeek’s Mathematical Epidemiology of Infectious Diseases), something about species interactions and evolution of behavior (a couple bits and pieces of Gintis’s Game Theory Evolving), bioenergetics and flows of energy carrying molecules both in organisms, which gives a chance to discuss metabolism, and in ecosystems. These selected topics constitute a semester.

The next semester is genetic mapping and screening (design of screens and selections, RFLP and other techniques) and phylogeny (constructing the universal phylogenetic tree, with visits to representative areas such as evolution of horses, gene transfer in bacteria, and parallel evolution of fluorescent proteins in corals).

Biomechanics
is the successor to anatomy, merged with mechanical engineering and developmental biology. It begins with a couple weeks of statics such as Galileo’s argument on the scaling of bones, pressures on bacterial membranes and cell walls, DNA pressure and packing in viral capsids.

Then it moves to dynamics: swimming of microscopic and macroscopic creatures, motility of cells by actin, circulation in the body, and basic models of cell migration and patterning in development.

What about supporting courses?

Single and multivariable calculus are necessary in all the courses, as are ordinary differential equations, with an emphasis on phase space analysis and qualitative features, but definitely including the Fourier transform. Partial differential equations are used only in biomechanics and evolution and ecology, and in neither place in really intricate ways, so they can be handled in those classes. Probability and stochastic processes appear in all of the courses except biomechanics, and possibly there as well depending on the exact selection of topics. It is also necessary to statistics.

Chemistry of ions in solutions is necessary for neurobiology, chemical thermodynamics for evolution and ecology and molecular biology. Organic chemistry is necessary to make sense of the pieces in molecular biology. A general chemistry course with a really physical bent is probably enough as a starting point.

Physics of point particles and rigid bodies, thermodynamics, and basic electromagnetism are all that need to be covered outside of the courses. I expect most science students to take introductory physics, chemistry, and biology as part of choosing their field of study, so these courses cannot be altered too much.

All of the classes can provide opportunities for students to dig into real data, so a separate data analysis and statistics course makes sense. I think a selection from Tukey’s Exploratory Data Analysis and Data Analysis and Regression and Kiefer’s Introduction to Statistical Inference would form a good basis for such a course. All science students should have such a course, so there is no reason to specialize it for biology.

The data analysis course and the evolution and ecology course both involve an understanding of programming and computational cost of algorithms. A computer science course on basic numerical analysis and search, sorting, and alignment algorithms would be a useful companion to both. Students should write all their own code for the assignments in this class, and use almost no libraries and certainly no algorithmic black boxes. About the only way to actually do this is in a semester is to teach the course in Scheme or a similar language.

What goes in the introductory course? My inclination is the first two lectures of material from each major section of the four courses, rearranged into a more unified year-long presentation.

What laboratory classes should students take? I would propose a separate introductory laboratory class of experiments that can be done in one or two sessions, separate from the introductory biology course, but covering what of that material is checkable in the lab in reasonable time.

Molecular biology is an obvious for a candidate for lab, learning how to prepare DNA, digest and religate it, run western blots, and do genetic engineering in E. coli.

Almost everyone uses a microscope, so a one semester laboratory on optical microscopy covering material something like Shinya Inoué’s Video Microscopy would be a good time investment. Then an intermediate lab where students carry out three or four longer experiments in small groups throughout the semester.

The Bio2010 report recommends a research seminar, which I think is a good idea. The Rockefeller University requires such a course of its graduate students. The class reads two of the classic papers in biology each week and meets with two faculty members over lunch to go over them.

In the end we have a schedule that looks like this:

First year:
Introductory biology (all year)
Introductory chemistry (all year)
Introductory physics (all year)
Single and multivariable calculus (all year)

Second year:
Introductory biology laboratory (all year)
Differential equations (fall) / Probability and stochastic processes (spring)
Neurobiology (fall) / Biomechanics (spring)
Numerical analysis (fall) / Data analysis and statistics (spring)

Third year:
Evolution and Ecology (all year)
Molecular biology (all year)
Microscopy lab (fall) / Intermediate lab (spring)
Research seminar (all year)

Fourth year:
Molecular biology laboratory (fall)

This leaves plenty of space for electives and general requirements. Now everyone have at and rip this to shreds.

BIO2010 (Part 2)

In an earlier post I gave my quibbles with the language of the BIO2010 report. I promised to lay out an alternative curriculum proposal, but first I’m going to set forth my underlying philosophy. First a few principles:

Repeat a canon several times.
Choose a core set of techniques and ideas which will properly shape the students’ minds. The shape of their mind when they come out is far more important than any particular collection of facts.

My sister once noted in surprise, the night before a calculus exam, "I can’t study for this class! I can only practice." There is no body of things that a science student should know, only a body of things he should be able to do. Skills and mindsets take much longer to teach than facts, so it is important to by stingy with what gets space in the curriculum. For example, given familiarity with the simple SIR epidemiology model and with partial differential equations from mechanics, there is no conceptual difficulty with adding spatial effects to the SIR model. Unless it is a step to some other compelling mental skill, ditch it.

If math is your language, don’t work in translation.
You would not expect students of Italian literature to have everything taught in English translation except for one course where they played with Italian translation. Just so, if mathematics isn’t the language in which you teach your classes, adding a random course will not fix the situation. Having students take carefully designed courses in math, computer science, and physics is not the right approach. They should only take those courses which impart tools they will use in every biology class from there on out. If no biology class in your department uses complex analysis, then don’t require the class of your students. If almost every class needs stochastic processes, then abstract that out and require a course in it. If no biology class in your department uses math, then if you find this state of affairs unacceptable, it falls upon you to correct it, not to delegate the task to a mathematician who spends his days worrying about category theory.
Prerequisite courses are for the universal, not the potentially useful.
Physicists have separate calculus courses not because it’s a good idea for students to know calculus, but because the tools are used in every physics course the students take, so it is more efficient to deal with the tools once, uniformly, and assume them from there on out. Topics like Laguerre polynomials which show up in only some of the following physics classes are simply taught alongside the physics, not abstracted out.

Does every course require the students to know what a calcium ion is, what it does in solution, and how it combines with things? Then general chemistry seems like a compelling prerequisite.

A course is the minimal mental pattern of a practitioner.
Students taking a course shouldn’t have to memorize facts. They are there to pick up a core of tools and structures which shapes their mind for research in a field. I propose a rule of thumb: if a practitioner uses something weekly, it should be in the introductory course; monthly, in the advanced undergraduate course; annually, in the graduate course.

Finally, the report wants physics and chemistry departments to modify their introductory courses for the needs of the biology department, or to offer special introductory courses. No. Many students are undecided as to their major in their first year, and take the introductory courses in all the sciences. I think each of these courses should be taught as if to a class full of majors in the department teaching the course. For instance, why should physics departments throw out relativity? And if an ostensible biology student seeing relativity decides that they like that more, shouldn’t they become a physics major?

I’ll post the curriculum proposal next.

(Update: Talking to my adviser, his comment was that the single most important thing that could be done would be to cut the administrative burden (not including teaching) of principal investigators from half to two thirds of their time to something much, much smaller. I think perhaps five to ten percent should be the upper limit.)

BIO2010 (Part 1)

The NIH and HHMI organized a much trumpeted report entitled BIO2010: Transforming Undergraduate Education for Future Research Biologists. It came out in 2003 to much acclaim. I reach the crux of it (chapter 2, "A New Biology Curriculum") last night. I don’t like it. I have some basic philosophical objections to their approach, and a lot of quibbles with the details as they stand. In this post I’ll go through the quibbles, and in later ones I’ll attack the underlying philosophy, and propose a curriculum in my turn.

The chapter is organized into a list of core concepts to be taught from biology, physics, chemistry, engineering, and math and computer science, then a set of suggested curricula. I’ve broken my gripes down by section:

Biology: Some of the concepts listed are important ("Biological systems obey the laws of chemistry and physics." and "Lipids assemble with proteins to form membranes, which surround cells to separate them from their environment. Membranes also form distinct compartments within eukaryotic cells.") and I dearly hope they are being taught already. Others are sloppy, tautological, or espouse absurdities such as "holistic" science.

Chemistry: I know almost know chemistry and am not willing to comment on this section except for the fact that "computational methods and modeling" is a bullet point right alongside Lewis structures.

Physics: The physics recommendations largely consist of a standard intro physics course for hard science majors with a few topics moved here or there. This isn’t a bad thing. I think that the best approach would be to take an 1960’s edition of Halliday and Resnick and go through that in a year (for those who don’t know it, the early editions of Halliday and Resnick were clear, comprehensive, and had a doable number of extremely well selected problems).

The report also wants the students to do learn by interacting with simulations. I can tell you from being on the receiving end of such an attempt and from anecdotal evidence in the community that such approaches are dismal failures. Let the course be analytical and experimental. Leave the computer out of it.

Engineering: Aside from the incredibly broad heading, this has about the only interesting, concrete recommendation in the report. The introduction was written by the biologists who are convinced that systems engineering is all that they might really want. Then someone wrote a curriculum outline for the first third of a really solid neurobiology course. Whoever wrote that, bravo!

Mathematics and Computer Science: Some of the topics confuse me (computability theory? why?). The gist of this section is to give the biology students special math classes where the computer can do all the work for them. Hamming said, "The computer is an extension of the body, not the mind." (I found this quote in the preface to McNeil’s Interactive Data Analysis) I agree that biologists should be able to program, and should really understand what BLAST does. This would be better taught as a one or two semester course on numerical analysis and relevant search methods, plus data structures such as ropes to handle long sequences. And it should be taught in Scheme (or this for the ambitious), not in "higher-level languages such as Matlab, Perl, or C" as the report recommends. Everyone who knows programming languages just stopped taking the computing recommendations of the report seriously with that list.

Apparently students should be taught data analysis. I completely agree. Astonishingly, John Tukey wrote some great books for this back in the ’70’s because he was teaching people data analysis. And it’s not just biologists who need this. Every scientist would benefit. Call up your local statistics department and get them to institute an "interdisciplinary" course based on John Tukey’s two classics Exploratory Data Analysis and Data Analysis and Regression, or whatever modernized version they want to teach.

The recommended math comes down to the following classes in the math department: single and multivariable calculus, linear algebra, differential equations (more like Arnol’d’s book than what the engineers are taught), and probability and stochastic processes (this would be a great place to use Nelson’s Radically Elementary Probability Theory). There, three years of math, a semester of computer science, and a semester of data analysis. That’s not so bad, is it?

The report also mentions that medical school admissions requirements govern a lot of what biology departments cover. My approach: ignore them. Physics departments do. If the biologists ignore the MCATs completely, then they will change to follow the biology.

The recommended solutions for dealing with not having the expertise to teach a course are frightening: "…taught…by a collaborating team of faculty from multiple departments" or "A mathematician or computer scientist might also be invited to give a guest lecture or two." Two lectures isn’t long enough to have any real effect on students’ mental processes, and team teaching makes the course scattered and disorderly. I speak from experience. Biology courses are often taught this way, and it’s absolutely useless.

There is an obsession throughout with having a course on modeling and simulation. I believe the rationale is that all the ugly mathematics stuff can be put into this, taught by one of those egg-headed math people, and the biology professors can go on doing exactly as they have been.

At one point it says, "Opportunities to learn mathematical skills in a rich content context will enhance conceptual understanding and procedural fluency." No it won’t. Math professors should (and usually do not) ask students, "Why is this theorem interesting?" If a student has not reached a level of mental abstraction sufficient to answer such a question in the context of pure mathematics, the mathematics education has failed. Later it even recommends remedial math courses before calculus! What are you doing in college if you need that?

The state of theory in biology

I finally got around to watching Rob Phillips’s talk "Physical Biology of the Cell" at KITP.

He’s got some great meat, but my favorite part is at the end where he makes some philosophical comments:

  • About an NSF meeting to consider how to handle funding of condensed matter folks going into biology: "There was a representative of the NIH there and his view…was that basically the David Nelsons of the world should go hang out in labs of biology groups and write code."
  • "I find it very frustrating that theory has come to mean computation and simulation."
  • "There is more to modeling the cell than mining data." He also has some harsh things to say about accumulating terabytes of data.

The first quote accurately represents how many biologists think of the role of physicists in biology. This reflects a persistent animism which tries to draw a line saying that biological systems are fundamentally more complicated (and thus somehow not amenable to physical analysis) than the rest of the physical world. I think it actually reflects a deep seated fear on the part of this same subset of biologists that everyone will realize they’re wasting their time.

And then we have computational biology and its close cousin systems biology. Molecular biology has largely degenerated into listing everything in sight in hopes that understanding will somehow emerge. Systems biology attempts to do this automatically! No longer will people have to pore over long lists of arbitrary three and four letter acronyms people have assigned to certain sequences of nucleic acids. Now a computer can do it for us, and since it can look at so many more, understanding is bound to emerge.

Let’s face it: the only scientific program that has ever produced anything is reductionism. Idealize the system you’re looking at, pare away everything you don’t need to explain the features at hand, and then start building back up. Reduce everything to some set of comprehensible physical phenomenon.

Standard hardware

I propose QEMU as the new standard hardware platform for operating system design. Why?

A new operating system must not only be technically superior and offer enormous advantages to its users, it must also run on enough hardware to establish a user base. The first is almost trivial given the state of systems today. No one wants to tackle the second. We all remember Linux’s long march up that slope.

However, Linux has made the march. We don’t have to do it again. Run a Linux kernel, then emulate a standard hardware platform with QEMU. Write your new operating system for that. Assume you’re going to coexist with Linux. If your system is someday so successful that Linux appears to be a useless appendage, you’ll have the necessary user base to write drivers. Until then, embrace our friends in the Linux community.