Splasho |

TAG | latex

Apr/13

2

LaTeX is amazing

I’ve long been a convert to the wonderful typesetting engine LaTeX, but it wasn’t until very recently that I fully understood its power. Given my very untidy handwriting, I keep my entire lab book in LaTeX. It includes many images of gels, such as the one below.

Biologists will recognise what this means – it is basically a slab of jelly which I’ve run some fragments of DNA through, from top to bottom. The smaller fragments run faster and represent the bands near the bottom. The middle ‘ladder’ is a mixture of fragments of known sizes. The lanes outside it contain unknowns which I want to measure in comparison to the ladder. So far, so standard.

What is special about this gel is the clean image above it. This is a simulation – what do I expect a gel to look like if it has certain band sizes? It just makes it very simple to see if we have what we expect, without looking up the exact details of the ladder. There are a number of tools for making these by hand, but this simulation was created in the typesetting engine itself, with just a few custom macros. This is the underlying Tex:

\begin{gelsim}
\gelscale{40} \geloffset{3}
\lane[Digestion A] \band{3500} \band{600}
\lane[Digestion B] \band{3500} \band{600}
\hyperladderlane
\lane[Digestion C] \band{1400}
\lane[Digestion D] \band{1400}
\end{gelsim}

\gel{Loaded onto gel (TGL14 DNA..}{UVP00822Nov302012.tif}

Pretty self-explanatory I hope. This isn’t a feature built into LaTeX: it works because of a custom class I hacked together (warning: totally uncommented and horrible). But it is totally amazing that it is possible at all. The class could use quite a bit of improvement, but it’s suiting my purposes for now.

The class itself is only 62 lines of code. Before spending a few hours hacking this together, I had no idea that LaTeX could even calculate logarithms on the fly!

If anyone is trying to replicate this you’ll also need to define the ladder in your preamble. And the last line of the code above should be ignored, just include the image as you would normally.

Happy lab booking!

· ·

Theme Design by devolux.nh2.me