Monday, July 26, 2010

Traitwise coding survey

We're almost ready to release the beta version of our survey engine: Traitwise.com. As a test of the embedded private surveys, I've created this short 10 question survey for my nerd friends to resolve a couple of hypotheses I have about coding styles and coding experience. So, to all my coding friends -- please take a few seconds to honestly answer this survey and to report any bugs or problems you find in the engine.

Sunday, July 18, 2010

Chemotaxis CheZ position experiments


From freeversity.org

Bacteria swim by their noses. That is, they smell food and swim towards it; they smell waste and swim away. The molecular basis of this amazing feat is the most well studied molecular signal transduction system and as such serves as a model for other lessor-studied bio-molecular signaling.

There's one little detail of the chemotaxis system that caught my attention a few years ago. The signal is transmitted from sensor to motors via a diffusing molecule called "CheY". When CheY has a phosphoryl group attached to it, it activates the motors in a certain way; when it loses that group it reverses the motors.

There's a very interesting subtlety to this system. The part of the system which "charges" the transmitter (to borrow electrical engineering terminology) is a kinase called CheA. The "discharging circuit" is the enzyme CheZ. It turns out that these two enzymes are, counter-intuitively, co-located. That is, it seems odd that the enzymes responsible for pulling-up a signal are co-located with the enzymes that pull it down. It would appear that the system is spinning it's wheels -- undoing what it just did. Why shouldn't it have the pull-down phosphatase evenly distributed or co-located with the motors?

When I first read this detail a few years ago in Eisenbach's book "Chemotaxis" it mentioned this counter-intuitive fact and I thought to myself, "I bet I know why -- it reduces saturation and evens out the signal." I wrote a little simulation years ago and convinced myself that this was indeed the case (at least for my toy simulation). Then I got distracted for years didn't get around to improving the simulations.

My hypothesis is that by co-locating CheZ and CheA the signal will saturate less near the transmitter and become more spatially uniform. My intuition is that when the external signal is rising and transmitter wishes to control the motors it needs a supply of free un-phosphorylated CheY in order to communicate this. Because CheY is produced at one end and diffuses to the other regions, there's a 1/r^2 distribution of it as it produces it. If it turns on the transmitter at some moment then a few moments later there will be an excess of CheY~P near the transmitter but a lot less further away. But, if CheZ is located nearby the transmitter then it is right where it is needed most -- where there's an excess of CheY~P.

Honestly, it's easier to see the effect than to describe it.

In the following figures, the top row has the CheZ co-located with CheA on the left side. The bottom row has the same amount of CheZ evenly distributed. These are space-time plots. Space is on the X axis with the transmitter on the left. Time progresses from the bottom of the graph towards the top. The right plot is the power spectrum of the right most spatial position which simulates the most distant motor's response. In the top row we see two things. First, the distribution is much smoother from left to right than it is in the bottom row. This is good for the bacteria as the motors are scattered throughout the cell and the controller depends on them to synchronously changing state as it switches from laminar movement to chaotic tumbling. Second, the non-linear clipping harmonic (the little spike on the right) is taller in the bottom row and the primary response (the big peak) is a little smaller. This indicates that there's a (mild) fidelity improvement in the co-location of CheA and CheZ. Given the simplicity of this argument I submit that such co-location is probably a common motif in other kinase/phosphatase (and similar pull-up/pull-down type) systems.



Caveats -- this is a scale-free simulation. I made no attempt to model actual parameters but rather went on the assumption that the bacteria probably operates near peak efficiency so I just twiddled the parameters until I saw what appeared to be peak efficiency. Of course, this is hardly rigorous so the next step will be to try to get accurate rate and diffusion constants. If anyone knows where they are conveniently located in one paper, that would be nice. :-)

2D stadium wave

I finally got around to making my previous stadium wave simulation run in 2D. It makes pretty patterns as I expected it would. The fascinating thing about it is that there's these interior waves that back propagates as the outer wave spreads out. There's some sort of instability that causes little imperfections (probably due to the imposed spatial lattice) that gets these little eddies started and once their started they tend to collide and make interesting things happen. The simulation is torodial so once the wave hits the edges it interacts with itself and then all kinds of beautiful things happen. (Note, the image looks wider than it really is -- what looks like an oval is actually a circle.)

Sunday, July 11, 2010

The similarity between New Testament textual analysis and bacterial plasmid phylogeny



In Prof. Bart Ehrman's excellent lecture series from the Teaching Company called "From Jesus to Constantine" he spends some time explaining the history of the documents of the New Testament. He describes various motifs of textual mutation caused by scribes' errors and theological corrections.

I was struck by the similarity between these motifs and the same motifs in biological DNA mutation.

The most obvious are the point mutations. There are many tens of thousands of spelling differences among the Greek and Latin manuscripts. The vast majority of these are irrelevant as they do not change the interpretation of the text. In biological terms, we might call these "point mutations of synonymous coding regions" which is a really fancy way of saying "spelling mistakes" that do not change the interpretation -- the functionality -- of the DNA. Prof. Ehrman points out that, including these textual point mutations, there are more differences in the Greek manuscripts of the New Testament than there are words!

The second motif is selection. As theological beliefs wandered throughout the centuries, the scribes forced "corrections" on the text to make it more in line with contemporary thought. One example he mentions is the story in Luke of Jesus and his family visiting Jerusalem. In the story the family accidentally leaves Jesus behind. 3 days later (!) they realize they forgot him and go back to find him in the Temple. In the Greek manuscripts Mary says: "You're father and I have been looking all over for you." But at the time the manuscript was being copied many centuries later, the theological orthodoxy had incorporated the story of the virgin birth so how could this passage be right: "your father and I have been looking..." so it was changed to "we've been looking...". This adaption was more "theological fit" than its cousins and was thus selected for in manuscripts over the ages.

The third -- and most incredible -- is the similarity between bacterial plasmids and marginal insertion mutations. The copied manuscripts were used by teachers and would sometimes end up with marginal notes -- writings in a different hand scribbled in the margins of the book. One example of this is the line in first Corinthians chapter 14:34 that "women should remain silent in the churches". Sometimes a scribe would read these marginal notes and think: "that's a good bit, I will maintain it into the next copy." What begins in separate hand becomes a marginal note now written with the same hand as the main-line text. Another generation or more later another scribe comes along and sees this marginal note and thinks: "What's this doing in the margins?" and inserts it into the main line text.

Similarly, in bacteria and other organisms, there's sometimes extra loops of DNA that are independent of the main-line chromosome called "plasmids". These stand-alone pieces of DNA are copied independently of the main-line but are occasionally inserted into the main-line. Once inserted, like the inserted marginal text, they cannot be distinguished from the original thus they become a permanent part of the main-line code. Because we have the sequences of thousands of bacteria, we can see evidence of this throughout history.

Sunday, June 20, 2010

Math Series 10 -- Euler's equation

And today we reach the first major milestone in my series: Euler's equation.






















Saturday, June 19, 2010

Math Series 9













Antenna analogy


An old fashioned radio without an amplifier.
Image from http://homepage.mac.com/msb/163x/faqs/radio-spark-crystal.html


How can a radio pull power out of the thin air sufficient to hear a radio broadcast many miles away? And what does this have to do with how bacteria swim? They both require an understanding of antennas.

I've been developing an analogy to with my friend John to help demystify antennas; the analogy is also intended to help my chemist friends see how the concepts of antenna design apply equally to all communication systems -- even biochemical ones.

Imagine a boat out at sea on a moonless night. Suppose there are waves rolling by on the ocean. How could we build a device on the boat to detect the invisible waves? A simple solution is to trap a marble into a slot and attach a switch a either end.



As the boat buoys up and down with the waves the ball will roll back and forth hitting the switches on either end. Consider why this works -- when the wave passes it lifts one side of the boat before the other. This lifting creates gravitational potential energy between one side of the boat and the other. Whenever there's a potential difference, anything free to change state under that potential will do so. In this case the marble will convert that potential energy into kinetic energy (and friction) which is detectable as the marble hits the switch.

There's a few non-obvious aspects of this that are easy to see when using this boat analogy and harder to see when talking about other kinds of antenna. Understanding these subtleties permits one to have much greater intuition for antenna design in other domains be that electrical or biochemical.

Aspect #1) It only works if the boat is rigid. If it was not rigid, say like a inflatable raft, the boat would simply deform to the shape of the wave and the marble could just sit in one place as the wave passes by.


Non-rigid ship.


#2) The length of the boat relative to the wavelength is important. Imagine how our marble-based water-wave receiver system would behave under two extremes: the boat being very short compared to the wave (top picture below) and the boat being very long compared to the wave (bottom).



When the boat is very short compared to the wave length, it hardly feels any potential energy difference between the bow and stern and thus the marble will not respond well to the wave. Similarly in the other extreme. If the boat is so long that many waves can pass under the it at the same time then again there will be little potential difference between bow and stern and the marble will not roll. We can therefore see that there is an optimal length range for our boat-antenna that is approximately equal to the receiving wave-length.

#3) The friction of the marble is important. A marble traveling through a denser medium will be slower to accelerate than will a marble going through a low viscosity medium. Imagine the marble moving through honey so that as the wave passes by it hardly has a chance to move at all before the wave has passed. Obviously this would be a bad detector because the ball wouldn't hit the switches.

Conversely if the ball were able to move too quickly, it would get all the way to the end of the rail very quickly and it would just sit on the switch. Although that might not matter for a simple-minded wave detector that only wished to detect the absence or presence of the wave (a binary sensor), it would matter if you were using the marble's velocity to drive some other system; for example, if we were making a recording of the marble's position to make a picture of the invisible waves. When the marble is able to travel so quickly to the end of the detector that it just sits uselessly at one end or the other it is called "saturation" or "clipping" and introduces a very particular kind of distortion called "clipping harmonics" and can be easily seen in the power spectrum with and without the clipping as seen below.


#4) You don't need a "ground" to detect a wave. The reason that a pilot can use a radio in the air is that that detecting a wave has only to do with detecting the difference in potential between the "top" of the wave and the "bottom". Indeed you need to be careful not to ground yourself in many cases because by "grounding" yourself you're creating an antenna that is the size of the earth!! For example, consider a boat mooring.



If you were to connect your boat to the ground then you'd be detecting the potential difference between ground and any wave even waves the size of the whole earth -- the tides. This can be very dangerous as the potential might be so great that it could destroy a ship. That's why in the picture below you see that boats that are moored to docs have to have rollers on them to isolate them from ground.



If there rollers weren't there the moored boats would be dangling from the ropes when the tide went out or deluged when the tide came in!


All of this stuff about length and friction boils down to a time constant. You need the marble "sensor" to have roughly the same time constant as the wave you're trying to detect. If the detector responds too slow (because it is too long or too burdened by friction for example) then you won't detect the waves very well. If your detector responds too fast (because it is too short or too frictionless for example) then the sensor will saturate.

This analogy demonstrates that an antenna is a "rigid" device that has a tuned response to a changing potential energy. This is true no matter the technology. And this lesson teaches us that antennas of any variety be they electrical, chemical, or anything else must be tuned to respond at a time scale in the ballpark of the speed that the signal of interest changes.

For example, an electrical antenna is a metal rod inside of which there are mobile electrons that are analogous to the marbles. As an electromagnetic field passes by the antenna the front and back of the antenna have different electrical potential so that electrons rush from end to end to try to cancel that potential just like the marbles did. And just as was the case with the boat-and-marble antenna, the length and tuning of detector circuit matters to optimize the response of the system to the wave.





All sensors of any technology are driven by changing potential energy. Consider a beautiful example of a biochemical "antenna" -- the bacterial chemotaxis sensor.



The receptor/sensor is a trans-membrane enzyme complex that undergoes a conformational change when it binds to a ligand of interest. The concentration of the ligand is variable in space and time and thus the bacteria needs to have a tuned antenna that responds at the same time scale. Imagine two extremes. Suppose the kinetics of the receptor enzyme were extremely slow to release the ligand. In that case, the bacteria would believe that the ligand was a high concentration even after it swam somewhere it wasn't. Conversely, imagine that the kinetics of the system were such that the motor was quickly saturated with signal. In that case, you'd get clipping distortion as described earlier. Both situations would reduce the performance of the chemotaxis system thus we'd expect that the bug would have evolved a circuit that is tuned to the time constants in the same rough proportion to the speed at which ligands change in the environment it is searching.

The above argument applies to any and all biochemical reactions. Ultimately every informatic aspect of a cell comes down to communicating information from place to place using diffusing metabolites. Therefore there's a lot to be said for thinking of the kinetics of these systems as "antenna" that are transmitting and receiving chemical messages at particular speeds with tuned circuits to optimize those communications.

[Revision 20 Jun -- thanks to my friend Sean Dunn for pointing out that I had incorrectly used a mass analogy where I should have used a viscosity analogy.]