Goodbye 2012!


Retrospective blog post time! 2012 was a fine year. I coauthored a paper, made some progress on a few more, started this here blog, went to the Congo, wrote a lot of code, and hopefully secured funding for my Ph.D. project. A bunch of folks visited this site from all over the world which always makes me happy. C’mon, though, Greenland! You’re a lot of grey in this map projection.

Here’s the highlight reel of the most popular pages, the top 13 in honor of 2013. Thanks for visiting and Happy New Year!

  1. Geometric Line Designs in R
  2. Similar Image Mosaic
  3. Lesula, New Monkey Species
  4. Preparing an Academic CV in LaTeX
  5. Repetition Code Demonstration
  6. Darwin Primate Mosaic
  7. Drawing Hats on a Monkey with Mechanical Turkers
  8. Primate Pet Legality Map
  9. ISIS Map of Mammals in Zoos
  10. World Map of IUCN Primates
  11. Markov Text Generation
  12. Chromosome Ideograms
  13. 3D Map of Global Treecover

Map: Where Primate Pets are Legal

Inspired by the sad story of Darwin, known as the “Ikea monkey,” I made this map of state laws regulating the keeping of non-human primates as pets. The data comes from this article in the International Business Times by Roxanne Palmer. The R code to generate the map is below.


library(maps)

# Load pet law data
pet_data = read.table("pet_data.txt", header=FALSE)
names(pet_data) = c("state", "status")

# Translate statuses into colors
col = rep("grey", length(pet_data$status))

color.meanings = data.frame(
	state=c("Illegal", "Legal but effectively banned", 
			"Some species legal", "Legal with permit", "Legal"),
	color=c("#006837","#1A9850","#FDAE61","#F46D43","#D73027"))

for (i in 1:nrow(color.meanings)) {
	this.state = as.character(color.meanings[i,]$state)
	this.color = as.character(color.meanings[i,]$color)
	
	col[pet_data$status == this.state] = this.color
}

# Plot map
out = map("state", interior = FALSE)
int = map("state", boundary = FALSE, col=col, add = TRUE, fill=TRUE)

# Add legend and title
legend("bottomleft", legend = color.meanings$state, 
	col = as.vector(color.meanings$color),
	ncol = 1, cex = .65, lwd = 8, seg.len = 1)
title("Legality of Keeping Primates as Pets")


VCF tab to FASTA Alignment Script

I’m not sure if anyone will find this useful, but I’m making available a tiny script I wrote to convert VCF tab files (output from VCFtoolsvcf-to-tab utility) to FASTA alignments. Essentially it just concatenates your SNPs. I found this useful as a quick sanity check when working with massive SNP datasets: I converted my VCF files to VCF tabular files, then used this script to make a quick FASTA alignment so I could generate a fast neighbor joining tree. The script is available on Google Code here:

VCF-tab-to-FASTA

Let me know if you ever use it!