# February 2008 Archives

## Sifakas, Ringtaileds, and Sportives, Aye-Aye!

Dr. Anne Yoder and her group at the Duke Lemur Center have produced lemur family tree tree. Greg Laden has the goods.

Note: Prof. Steve Steve was not involved in the study.

## Rendering Equations with ImageMagick’s Convert

Last October I described my algorithm for rendering LaTeX equations for use on this blog: “Rendering Equations in Movable Type”. For kicks, here are instructions on how to manually run the algorithm. The only thing missing is the middle alignment part of the algorithm.

First create a file, called eqn.tex using the following skeleton. Insert your LaTeX equation code where it says to.

\nonstopmode
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{amsmath,amsfonts,amssymb,wasysym,latexsym,marvosym,txfonts}
\usepackage[pdftex]{color}
\pagestyle{empty}
\begin{document}
\fontsize{12}{24}
\selectfont
\color{white}
\pagecolor{black}
$% % EQUATION GOES HERE %$
\end{document}


Next process the file with pdflatex eqn.tex, which will render your equation as eqn.pdf. Now we will use the convert command line tool from the ImageMagick library to turn eqn.pdf into eqn.png.

convert $$-density DENSITY eqn.pdf -trim +repage$$ \
$$+clone -fuzz 100% -fill FG -opaque black$$ \
+swap -compose copy-opacity -composite \
$$+clone -fuzz 100% -fill white -opaque BG +matte$$ \
+swap -compose over -composite eqn.png


Here DENSITY, FG, and BG are user tunable variables. DENSITY tells convert how many pixels per inch to use when rendering the pdf to a png. This determines how big of a png you have for a given rendered equation. Note that a density of 300 is print quality, 96 is windows monitor standard, and 72 is the mac standard. FG is the color of the equation text in the final image, and BG is the color of the background. Setting BG to none will make the background transparent.

Now for an explanation of the options:

$$-density DENSITY eqn.pdf -trim +repage$$ \ loads the pdf into memore, removes excess background, and saves it into the image stack position 0.

$$+clone -fuzz 100% -fill FG -opaque black$$ \ copies the image at position 0, fills it with the FG color, and saves it at position 1. We clone and fill to ensure that image 1 has the same dimensions as the trimmed image in position 0.

+swap -compose copy-opacity -composite \ uses the black-and-white values in position 0 to determine how transparent pixels are in 1, clears the stack, and saves the result to pos 0. We actually swap positions 0 and 1 to put them in the right order for the -composite operator.

$$+clone -fuzz 100% -fill white -opaque BG +matte$$ \ copies image 0 again and fills it with the BG color, discarding all transparency information.

+swap -compose over -composite eqn.png overlays image 0 onto image 1 and saves result to eqn.png.

And now you have an equation rendered as a png that can be included on any webpage.

## Estimating Local Ancestry

Last month, one of the fellow postdocs in our lab went back home to Denmark and began professoring again. So it’s nice to find out that one of his collaborators in Denmark is a blogger and has a really cool post about Estimating local ancestry. He even connects the post to some research that was done in our lab, which makes it double plus one good.

## Hiding Email Addresses From Robots with Javascript

| 1 Comment | 1 TrackBack

Spammers use automated programs to search the internet for email addresses to harvest. There are several techniques out there to hide email addresses from spam “robots”: Address Munging. Although, all these techniques can be beaten—some rather easily—you probably still want to use them because the average harvester is not designed to handle them. Sites with exposed email addresses outnumber those that protect theirs, and as long as there are easy nuts, the spammers are not going to invest the resources and time to crack the hard nuts. (Think Darwin’s Finches.)

The simplest technique is to add characters to the email address that most humans will recognize and remove or replace to form the valid address:

jason [at] theargonauts [dot] com
NOSPAMjason@theargonauts.com


This is a very effective technique; however, it requires user intervention, and the most popular techniques can still be interpreted with little effort by a robot. If user intervention is not a concern, then one nearly flawless technique is to simply display the email in an image. In my opinion this should only be used as a last resort because it has several drawbacks: no click to email ability, difficulty in copying the email address, increased download size, etc.

Transparent munging techniques can be used to allow users to click and use email address directly. The simplest technique encodes the email address using html entities:

jason@theargonauts.com


Obviously, this is not that hard to crack because everyone knows the entity-to-character translation rules ahead of time. However, we can use javascript to make things difficult to understand but easy to use. The logic here is to encrypt email addresses in webpages and use javascript to force browsers to decrypt them. The advantage here is that to all humans visiting your site, the email address behaves like a normal mailto: link. However, robots won’t understand it because they don’t implement javascript. Using a simple rot13 cypher would produces the following address:

wnfba@gurnetbanhgf.pbz


From this, javascript can be used to tell the browser that the above email address is really jason@theargonauts.com. Although generic harvesters will probably never implement the complexities of javascript, they can be programed to decode the email addresses without javascript once they learn the algorithms. However, as long as each site implements its own encode and decode algorithms, it is uneconomical for robots to specialize and hard to be comprehensive.

I use the following javascript framework to decode email addresses on my blogs:

1. Find all links with a mailto: specification and for each:
2. Match an encoded address or return
4. Split the decoded string into the real address and an optional url text
6. Set the inner html text if it was specified.

Using the tricks of the jQuery library and the assumption that email addresses are encoded as hexadecimal numbers (characters 0-9 and a-f), we have the following frame work. You will just need to supply your own decryption routine.

$(function(){$('a[href^=mailto:]').each(function(i) {
var xr = this.href.match(/^mailto:([0-9a-f]+)$/); if(!xr) return; var x = xr[1]; // encoded address var s = ''; // decoded address /* Here be decoding of 'x' into 's'. */ xr = s.split(/\|/); // optionally split real address from url text this.href = "mailto:" + xr[0]; if(xr.length > 1)$(this).html(xr[1]);
});
});


Here is an example of an encoded email address used on this page that is decoded by the script above:

  <a href="mailto:7d0f6a0f6b2b4f2a583d4f3a5739582c592b4a6411625d0e7b19731675013c781d3d6f0a780d60400e6f1b6e1c7d5d1f731c7b">Email Me</a>


Very cryptic and yet the page still validates—unlike other javascript email hiding implementations—while the user hardly ever notices that anything is up. Of course, if you decide to use this technique you will need a way to encode your email addresses in the first place. I wrote movabletype plugin to produce my encoded email addresses. Another option would be to setup a form on your website that would process addresses and return the proper encoding.

## Green Openlab

Bora and I met today to pack and mail copies of the Open Laboratory 2007 to most of our contributors. We sent the international ones off today, and Bora will mail the rest on Monday.

What was cool about this batch was that Lulu filled the bulk order using a different printer than the previous batches. The result was green covers! Yes, when ordered in bulk, the Openlab 2007 comes with a proper green cover. When ordered in small batches, it comes with a blue-gray cover. Unfortunately, we were not able to send green books to everyone, we had to use up our stock of blue-gray books.first. Some of the authors who ordered multiple copies will actually get both colors, just because.

I’m slowly revising the 2007 version to create a corrected, second edition, which I hope will be available during the summer. I’m hoping to fix the cover color issues at that time. We may even try a different publisher/printer since we still retain the rights to the book.

I am also working with Bora and Jennifer to extend the layout and styles we developed for this edition to next year’s.

## External Linking with XHTML and jQuery

| 1 Comment

Many of you may be familiar with the behavior on this blog and the Panda’s Thumb that links to external websites open a new window or tab. In old fashioned html, this would be accomplished by adding a “target” attribute to your link:

<a href="http://scit.us/" target="_blank">Scitus</a>


However, with the advent of XHTML, content was separated from style and behavior, and the target attribute was officially retired; although, it is still recognized by standard browsers. Instead with XHTML, the proper solution is to use the “rel” tag to show how the linked page is connected to the current page:

<a href="http://scit.us/" rel="external">Scitus</a>


Perhaps you are using a browser that understands this but are probably not; therefore, we use a line of javascript to tell the browser what to do with those links:

$(function(){$('a[href][rel*=external]').each(function(i){this.target = "_blank";});});


The above code is very cryptic because it relies on shortcuts provided by the jQuery library. With prototype you can do use something equally cryptic like this:

function externalLinks() {
('a[href][rel~=external]').each( function(value, index) {value.target = "_blank";});
}


Sure, it’s more complicated than the original, but it wouldn’t be progress if unless they made things harder to do.

## WΔZ: Evolutionary Equations on the Big Screen

According to Rotten Tomatoes, the movie WΔZ starts showing today in the UK. The movie is a psychological thriller/horror movie and has been compared to Se7en. What makes this movie interesting is the fact that the screenplay was inspired by Price’s Equation:

Price’s Equation is a broader version of Fisher’s Fundamental Theorem of Natural Selection. It describes how the change in trait with phenotypes is related to the phenotypes’ fitnesses, . Note that the genetics of the trait (mutation, ploidy, etc.) is contained in the second term. See Wikipedia for more details.

Now according to the Rotten Tomatoes exclusive on WΔZ:

The script comes from City of Vice scribe Clive Bradley, who claims to have come up with the movie’s premise after flicking through a book on Darwinism. “It featured a mathematical equation—W Delta Z—formulated by American population geneticist George R. Price,” he explains. “It supposedly shows that there’s no real altruism in nature; no such thing as selflessness. Price was so upset by his findings that he ended up giving away all his possessions to the poor and, eventually homeless himself, committed suicide with a pair of nail scissors in a filthy London squat.”

The study of the evolution of altruism goes beyond the description above, and I hope moviegoers won’t be seduced by this fictional account of evolutionary theory. (I’m waiting to see what demagoguery that AiG, DI, and the Expelled frauds come up with about this movie.) Now, it is true that according to Price’s Equation, altruistic behavior that benefits a species at the cost of individual fitness is selected against. (Note that a deleterious phenotype can still exist in a population through mutation-selection balance or genetic drift.) However, if the altruism only benefits certain members of the species (e.g. relatives), then altruism can be selected for.

This is represented by Hamilton’s rule: . This describes under what conditions an altruistic allele will invade a population. is the cost of the allele to the “actor”, is the relatedness of the receiver to the actor, and is the benefit that the receiver receives by the actor being altruistic. The consequence of Hamilton’s rule is that selfish genes can still be altruistic. There is a lot of interesting literature about the evolution of altruism, including how punishment can reinforce altruism. I recommend Sean Rice’s Evolutionary Theory, Chapter 10, as a good starting point.

So if anyone in the UK goes to see this movie this weekend, please send us an overview/review.

## jQuery

I’ve migrated the javascripts on this site from the Prototype library to jQuery. Let me know if anything breaks.

## Compression Enabled

Last night I modified the server config to add compression to html, text, css, and javascript files. Let me know if you see any issues. Last time we tried this on PT, it broke IE’s refresh control.

## Jack Tice, Tragic Pioneer at Iowa State

Most people who follow this blog probably know Iowa State as the soon to be former employer of “intelligent-design” activist Guillermo Gonzalez. However, it actually has an interesting progressive history. George Washington Carver was both the first African-American student and the first African American faculty member there. Today, ESPN ran a story about Jack Tice, the namesake of the football stadium and the first African-American athlete at ISU: “ISU only I-A school to honor African-American in stadium name.”

When Euseph Messiah arrived at Iowa State, he barely noticed a weather-beaten statue outside of his team’s home stadium, much less cared whom the facility was named after.

Jack Trice’s figure can be found outside the stadium that bears his name, despite a fleeting college career that lasted only two games for the Cyclones.

That might not seem like much. But for those who have learned about Trice’s tragic story of sacrifice, it remains one of the most compelling in the history of college football.

In an age when most stadiums are named after a megabuck donor or a corporate sponsor, the Cyclones’ home facility honors Trice, who died from injuries on Oct. 8, 1923, two days after he was trampled in a football game against Minnesota.

It is a very interesting story, and well worth a read.

## Happy Darwin Day!

Today is Darwin Day. Get out and learn some biology!

(HT: PZ)

## The Market

Tiffany started her first full-time lawyer job this week. Yay, now we can pay off our credit cards and get some new stuff—50-inch plasma screen!—for the house.

I’m in the job market as well; I applied for eight faculty positions last fall. I got my first official rejection email today, which doesn’t bother me. So far, I’ve had one interview, and it’s looking like that is the only one that I’m going to have this year. I came away from the interview thinking that I’d like to work there more than any of the other places that I had applied to. I haven’t heard either way about that position, but I really hope that I get an offer because I really think it is a perfect position with a lot of opportunities for both me and Tiffany.

| 1 Comment | 1 TrackBack

The Scientist has a new article on the history of the scientific literature and controversy of the HOTHEAD mutation in Arabidopsis: “Mendel Upended? How the behavior of an Arabidopsis gene could overturn the classical laws of genetics.” Long time readers of this blog will remember that when the original paper came out I blogged my thoughts on the study and eventually turned my blog thoughts into a scientific coauthorship. (See Blog About Hothead and Get an Easy Paper for more background.)

Comai and I are mentioned in The Scientist’s article, although not by name:

In November, 2005, researchers at the University of Washington and the University of Georgia proposed that, rather than a novel genetic mechanism causing the reversion, the HTH gene product might be a metabolic enzyme, which when mutated produces toxic and mutagenic compounds that act on the DNA. In particular, they suggested that the HTH protein may be in a class of proteins that, given a deleterious mutation, revert precisely to the wild-type from mutagenic effects.

Other authors with more fantastical explanations get named and cited, but our reasonable example is tossed aside. (Of course, the most reasonable example, pollen contamination, gets a lot of discussion.) I guess one consolation prise is that if you search for “Susan Lolle” my blog comes up first.

What strikes me in all the discussions about HOTHEAD is that most of the geneticists quoted appear to have not studied population genetics beyond classical, Mendelian work. The way they frame the discussion makes me think that they’ve never studied well known phenomena like meiotic drive. (I’m currently participating in a seminar class, which is reading Burt and Trivers’s Genes in Conflict and meiotic drive gets first billing. It is very refreshing to be participating in popgen discussions again.)

Most organisms that people care about are diploid; they contain two copies of each gene. During reproduction, each copy of their genes has a 50% chance of being passed to their offspring. However, some genes show meiotic drive, which occurs when one copy gets passed to offspring a majority of the time. Consider two, unlinked genes—Aa and Bb—where A drives at 90% and B is normal. Therefore, an AaBb individual will produce four different gametes, which have the following frequencies: AB = 45%, Ab = 45%, aB = 5%, and ab = 5%. Now an AABb will have two different gametes: AB = 50% and Ab = 50%. An aaBb individual is similar.

Unaffected by other forces, a driving allele will go to fixation because it has the advantage over other alleles. However, meiotic drive often works by physically killing gametes that contain the other allele. The simple model of how this works is that the A allele is actually a pair of genes: one produces a time-delayed “poison” before gamete formation, and the other provides an “antidote” after gamete formation. Because the “poison” is in all gametes, but the antidote is only in gametes that contain the A allele, the a-gametes are weakened and thus the A-gametes get more than 50% of the fertilizations. Because nearly half of their gametes are removed, individuals with driving alleles can suffer reduced fertility, which can make it difficult for driving genes to go to fixation. Instead a polymorphic equilibrium is reached and the driving alleles persist in the population as a “chronic infection.”

If you think that meiotic drive is too exotic to be common, most organisms that have been studied extensively have shown its signs, the classic examples being the t-haplotypes in mice and sd inversions in Drosophila.

## Super Bowl XL2: Carl is Unpissed.

I was really rooting for someone to finally go 19-0, but as the last of three boys, seeing Eli win a super bowl was a nice consolation prize for me. Of course Carl is excited that the Giants won.

## Carl is Ready for Sunday.

It’s the Pats versus the Giants in the Super Bowl this weekend. Carl is psyched for another New York versus Boston championship game:

Personally, I dislike both cities, but since I had Brady on my victorious fantasy football team this year—worst to first, baby—I’m pulling for the Pats to finally make everyone stop talking about the 1972 Miami Dolphins.

What’s even better than Carl’s weekly video diary is the fact that Aqua Teen Hunger Force is now airing new episodes.—Casting John Kruk as one of three beautiful sirens was hilarious.—To add the cherry to my joy sunday, [adult swim] just released ATHF:Volume Five on DVD.

Yay!