Archive for February, 2013

There’s a fire in the building…

28 Feb 2013

I was at work this morning at 8am. At 8:45am I got a text asking what was going on in my building, with this picture:

Fire trucks at MSC

It was news to me.

At 8:55am we got an alert saying “Avoid 1300 Univ Ave. Fire and Police on scene for working fire.” Hey, I’m at 1300 University Avenue!

We could see out the window that there was a campus police officer preventing people from entering the building. But the fire alarm had never gone off.

At 9:05am I called the campus police to ask what was going on. They said all the alarms were supposed to go off. They asked me to leave the building. I did immediately, but afterwards I wished I’d brought my lunch and laptop with me.

Apparently no one was hurt, but there seems to be quite a mess. This is on the same floor as my office, not too far away:

Fire-related mess, 4th floor SMI

The fire seems to be around the corner from that shot, in the back-central part of the building. I peaked around the corner and saw a bunch of people standing around, but I was too shy to take a picture of them.

There are related articles in the Wisconsin State Journal and the Channel 3000 site.

UW-Madison joins Coursera

21 Feb 2013

UW-Madison is joining Coursera to offer four massive open online courses (MOOCs).

I like Sara Goldrick-Rab’s comments.

MOOCs are a good thing, but I view them as “outreach”. There are lots of problems with universities, but MOOCs don’t seem to be a solution to any of them.

I like Sara’s point about MOOCs more being used more for continuing education for the already educated vs new access for the uneducated.

Interactive MA plot

11 Feb 2013

The New York Times has an interesting interactive graphic on boys’ and girls’ average scores on a science exam, by country.

Science scores

It’s nice to see a scatterplot. (Often one would see just a bar plot, with female and male bars side-by-side.) Even better, this is an “MA plot.” That is, rather than just plot males vs females, they show the difference vs the average.

The wikipedia entry for MA plot says such a plot of difference vs average is in medical statistics known as a Bland-Altman plot and in other fields is known as a Tukey mean-difference plot.

D3.js difficulties

8 Feb 2013

I’m pleased with my progress learning javascript and D3. (I’m actually writing coffeescript rather than javascript.)

But I spent a lot of time thrashing about yesterday, due mostly to two silly errors.

Put the script in the body

First, I’d tried to make a truly simple example, making just an SVG with a little rectangle.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Put script in body</title>
    <script type="text/javascript" 
        src="http://d3js.org/d3.v3.min.js"></script>

    <script type="text/javascript">
    var h=50;
    var svg = d3.select("body").append("svg")
                .attr("height", h).attr("width", h);
    svg.append("rect").attr("x", 0).attr("y", 0)
                .attr("height", h).attr("width",h);
    </script>
</head>

<body>
</body>
</html>

But this gives nothing. You need to move the script from the head to the body, as it is here. Then it works.

I don’t really understand this. Perhaps I should go back to my reading.

[Update: I think I’ve figured this out. If you put the script in the head, the code gets run before the body exists, and so there’s no body in which to append the SVG. Conclusion: Put the link to your script at the very bottom of the html file.]

Don’t forget enter()

In D3, you bind data to a bunch of objects, and attributes of the objects can be controlled by features of the data. I write code sort of like this:

svg.append("g").selectAll("empty")
   .data(thedata)
   .enter()
   .append("rect")
   .attr("x", (d) -> start[d])
   .attr("y", pad.top)
   .attr("width", (d) -> end[d] - start[d])
   .attr("height", (d) -> hInner)
   .attr("fill", (d) -> color[d])
   .attr("stroke", "none")

My most common mistake so far: I forget the .enter() part. You don’t get a error message, but the objects don’t get created.

Interactive graphics with d3.js

8 Feb 2013

I’m making some progress learning D3 (for interactive graphics), by which I mean I’ve gotten a couple of examples to work.

Many box plots

First, an example for displaying many distributions. Here I’m considering a set of nearly 500 gene expression microarrays, each with 40,000 or so measurements. It’s hard to look at 500 box plots side-by-side, and with 40k measurements, traditional box plots don’t give enough information about the tails.

Many box plots

In the top figure, the 500 arrays are aligned next to each other, sorted by their median, and then I show the 1, 5, 10, 25 50, …, 99th percentiles. The advantage of the interactive plot is that you can hover over a given array on the top and see a more detailed histogram below. And if you click on an array, its histogram will be retained below, for easy comparison to other arrays.

LOD curves and QTL effects

As a second example, I plot the LOD curves from QTL analysis across the genome; click on a chromosome above and you get a more detailed view of that chromosome in the bottom-left; click on a marker position in the bottom-left, and you get a view of the QTL effect on the bottom-right.

LOD curves and QTL effects

Likely none of that is understandable; let me try to explain. QTL stands for “quantitative trait locus,” a region of the genome (i.e., locus) that influences some quantitative trait (like insulin level in serum). To identify QTL, we look at the association between the quantitative trait and genotype at each of many genetic markers across the genome. We’re basically doing analysis of variance, but we express the results as a log10 likelihood ratio, called the LOD score.

The advantage of this interactive graph is that you have some ability to look at the underlying genotype/phenotype association, rather than just rely on LOD curves. It would be nice to include the option of a dot-plot on the lower right, rather than just the within-group averages.