I thought I’d already done a proper introduction of my move into using the R language to analyse the data for my thesis, but I can’t find anything now… I’d previously been using GraphPad Prism, which was easy to use and everything was customisable at a click, but this meant it was a bit slow and bloated. MSExcel hasn’t even entered into the equation after the effort needed to display standard error bars, and also that some of the inference test calculations aren’t even right. Instead, I decided to try to teach myself R.
So here’s the start of my journey into R analysis, a “jouRney” if you will. R is an open source language developed from the commercial language S, which in turn derives from C. Straight out of the box it can do some reasonably advanced data extraction, analysis and visualisation. It’s real strength, however, comes from its openness. Being open source means that thousands of stat geeks around the world have developed add-on “packages” that develop R’s abilities into all sorts of areas of research.
So far, I’m just beginning to learn how to read data in, manipulate it and visualise it, but here’s the result of my first attempt to produce a heat map/contour plot of the firing rate of a dopamine neuron in response to a stimulus, across trials:
#reads in raw data from text file produced by heatplot.s2s
contourplot <- read.table("c:\\documents and settings\\craig\\my documents\\my dropbox\\R stuff\\rawoutput.txt", header=TRUE, sep="\t")
#trims off empty columns
contourplot <- contourplot[,1:40]
#sets table to contain only the data columns
contourplot <- contourplot[,c(2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40)]
#transposes the data
contourplot <- t(contourplot)
#makes table into data matrix
contourplot_matrix <-data.matrix(contourplot)
#Plots heatmap of matrix "contourplot_matrix"
filled.contour(x=seq(1, 300, length=20), y=seq(-0.5, 1.5, length=20), z=contourplot_matrix[1:20,1:20], nlevels=20, axes=TRUE, color.palette=topo.colors)
Which produces this:

A comparison of contour plot in R (right) and the raw data from Spike2 - Conotur plot rotated 90 degrees anticlockwise
Which is essentially a grid of the mean firing rate in 100 ms by 15 trial bins. Hopefully, I should be able to use these data in a principal component analysis, and see if there are separate components which change over time at different rates.
Eventually, I’m aiming to do all of my statistics in R, so we’ll see how it goes.