More about heatmapVis

The idea behind the sortable heatmap plot is that we often have a set of subjects and numeric observations that we want to visualize as a heatmap. For example, in genomics we might have differential gene expression levels at different sites and for different study subjects.

In addition to the numeric observations, we could have an additional set of data for each subject, such as their age, gender, treatment indicators, medication, etc. We would somehow want to incorporate this information into the heatmap, and so the sortable heatmap is born.

Take a look at the example code below:

nsubj = 40
nobs = 25
data1 <- matrix(rnorm(nsubj*nobs), nsubj, nobs)
rownames(data1) <- sapply(1:nsubj, function(x){paste("S", x, sep="")})
colnames(data1) <- sapply(1:nobs, function(x){paste("V", x, sep="")})

# Create a set of discrete and continuous covariates to sort by
sort.by1 <- data.frame("Treatment"=rbinom(nsubj, 1, 0.4), "Age"=rpois(nsubj, 30))


In this code, we are simulating 40 study subjects and 25 observation sites (a 40×25 matrix of numeric values). We provide names for the rows (S1…S40 for the subjects) and columns (V1…V25 for the sites). Next, we simulate a set of covariates as a data frame. The first column is a treatment indicator and the second is the subject’s age.

heatmapVis() expects a numeric matrix of dimension n x m and a data frame of covariates of dimension n x p. Here we have passed a 40×25 matrix of numeric observations and a 40×2 data frame of covariates. There is also a color argument (defaulted above) which takes a vector of the form c("lowColor", "medColor", "highColor") . You need to specify three colors signifying low, medium, and high values, and the intermediate colors are filled in accordingly by the function.

As you can see in the final product, we start with an unsorted heatmap, but can then sort the rows (subjects) by the covariates we specified. This could be useful for looking at how trends change when the subjects are grouped and ordered.

Limitations: This visualization is still a bit limited as we are working to increase how much data our server can accept in one request. Also, the transition becomes sluggish when there are many rows or columns. We are working on rectifying these issues as we speak. For now, try it out and let us know what you think!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s