Showing posts with label software. Show all posts
Showing posts with label software. Show all posts

Monday, January 23, 2012

Bland - Altman plot in R

Not so long time ago I did a comparison study of two software packages, more precisely their ability to estimate random effects. The plain approach was to do correlations among the outcomes, and if they were high I assumed that both programs are OK. I presented this to my more experienced colleagues who suggested to use Bland-Altman plots to confirm the results. This is a reasonably simple technique to measure the agreement of the two outcomes. As they say in their paper Statistical methods for assessing agreement between two methods of clinical measurement (pdf linked, worthwile to read):

In clinical measurement comparison of a new measurement technique with an established one is often needed to see whether they agree sufficiently for the new to replace the old. Such investigations are often analysed inappropriately, notably by using correlation coefficients.The use of correlation is misleading. An alternative approach, based on graphical techniques and simple calculations, is described, together with the relation between this analysis and the assessment of repeatability.

 Simple, yet beautifull technique.

Naturally I was searching for implementartion in R. I quickly found and installed a package called ResearchMethods, but personally I thought it has very few soft tuning possibilities (e.g. scaling or color change). I went deeper and found a quite well documented page with a custom/modified R function. 

I used this one, as I could scale the y axis, so the final plot was nicer. On the other hand I also found that this particular function was written for demonstration purposes, but it had difficulties to run on other data.

For example the limits of the y axis were hard coded to -60, 60, which is quite problematic if you are interested in much higher or smaller differences (In my case on the 0.01 level...). Also the data set names were hard coded into the funtion.

So I modified the code to a more generic function like this:

BAplot <- function(x,y,yAxisLim=c(-1,1),xlab="Average", ylab="Difference") {
   d <- ((x + y)/2)
   diff <- x - y        
   plot(diff ~ d,pch=16,ylim=yAxisLim,xlab=xlab,ylab=ylab)
   abline(h=mean(diff)-c(-2,0,2)*sd(diff),lty=2)
}
 You call it as:
BAplot(testSet1,testSet2,yAxisLim=c(-0.1,0.1))

The "testSet"s are the datasets to compare, the yAxisLim modifies the scaling of the axis according to your needs. You might modify the labels of x and y axis if you wish with xlab and ylab.


Monday, November 28, 2011

R crash course

This is a follow up post for my R course held in Addis Ababa last week. You can find the description of the stay in the Inside Ethiopia (part 1) and Inside Ethiopia (part 2) blogposts, if interested. 

This post is a shorter and more practical one. I promised to multiple people to put the presentations online, so I thought I will make them available through my blog in combination with my Dropbox account. Here they are:

  1. Introduction to R
  2. Basic commands of R
  3. Statistics and programming in R

The other links I am referring to in the presentations are An Introduction to R, the R reference card and the other variations of cheat sheets.

You are free to re use and replicate the presenations, provided that the initial work is acknowledged.

Have fun with R! :)


Tuesday, October 25, 2011

Out for Africa

When I was starting to write this blog wanted to focus on more "work type" topics, mostly dealing with agriculture or animal breeding. This was the initial plan, which has slightly adapted in the meantime. One thing I was clear about from the beginning that I would like to deal with my two main interests, the advancments in technology related issues and my passion for agriculture with special interest in developing countries.

While writing this post I am thinking about the reasons behind this. Although I had little formal education in "development studies" so far, I met a bunch of people from these regions. I have in mind my former and current colleagues and friends from the BOKU office or from the EMABG. Although I have never been in those countries, they became one of my main interests, through the people I met.

So you can imagine how excited I was when I got the opportunity to participate on the ILRI - SLU - FAO workshop called "Capacity building for sustainable use of animal genetic resources"  in Addis Ababa, Ethiopia end of November this year. I was even happier that I could be one of the presenters. According to the plan I will have half a day to present the R data analysis and programming environment to the participants. I had similar (although shorter) presentations few times before, mostly for EMABG students, so I have bit of an experience with it. Although this will be a different setting and a different audience, so I am going to adapt the contents accordingly.

I was traveling quite a lot inside Europe, but this will be my first jouney outside the continent. First one goes to Africa. 

Monday, August 22, 2011

Next Generation Sequencing: Departure to New Frontiers


Last week I have competed the Synbreed Summer School called “Next Generation SequenceAnalysis: Practice and Departure to New Frontiers”. It was organized in Herrsching am Ammersee, Germany which is a place just near Munchen. The main organizers were animal breeding people from Technical University Munchen and researchers from the Helmholz Zentrum. 

I have to say: It was an exceptionally good summer school!




There were several thing in the course that were “out of the ordinary”, yet contributed for the course success (at least for my viewpoint).
1.       Focus on practical data handling: I liked this part very much. We went through everything, starting for the installation of the software up to imputation. It is not easy, but manageable.
2.       Usage of free software: I mean all software, including the operating system. Actually I had to install the Ubuntu Linux because of this. But now I am glad I did. The main interface is far from the command line feeling, which often keeps people from installing Linux. At least with this new Ubuntu graphical interface I had the feeling I am browsing a smartphone… Of course the things can become pretty complicated, depending on the actual aims of the user, but the basic navigation is without problems.
3.       Course given by PhD students: I was realizing this just by the end of the summer school. Not that PhD students are not good enough (in fact they were excellent), but I would expect somebody older “by default”. But I guess this was the strategy of the course to bring in people who are working with these things on daily basis,as they are the most qualified ones to introduce the techniques to us.
4.       Evening sessions: After the daily workload we often went for a beer-or-two, often ending in the billiard room. Good time! 

Except from the practical sessions there were also presenteres, who contributed to afternoon sessions. They were specialist in their fields highlighting various possibilities of sequence data. The list is as follows: Mario Caccamo and Jared Simpson on De novo assembly, Paul Kersey on Genome browsers and databases, Ben Hayes on Genomic selection, Agricultural genome projects and Perspectives of using sequence data, and last but not least Karl Schmid on  Next generation population genomics.

The list of software and other useful links:
  • Burrows Wheeler Aligner - for alligning short sequence reads
  • SAMtools - various utilities to manipulate allignments
  • SEQanswers - all-around forum for sequencing issues. They have a wiki too with the list of most popular software. If you are into sequencing, this is the place to dive deeper. 
Be sure to check out the "World map of sequencing" too. Well... I think it displays the number of sequencers by region, consequently the amount of effort put into sequencing everything what comes around. As of August 2011 it seems that the most powerfull players are the US and China as individual states. Europe comes third if we look at total sums.