Coloc v2.3

Coloc v2.3 is up on CRAN.

2013-09-25  Chris Wallace  <>

        * v2.3
        BUGFIX: Introduced a function to estimate trait variance
        from supplied coefficients and standard errors.  This is used
        within the approach implemented in coloc.abf(), and replaces the
        earlier version which implicity assumed that var(Y)=1 for
        quantitative traits, which could lead to incorrect inference when
        var(Y) was far from 1.

Pretty printing progress bars from .Call in R

I wanted to do something that takes a while in C (called from R) and wanted to print a progress bar.

In the R function, I did

pBar <- txtProgressBar( min = 0, max = n, style = 3 )
ret <- .Call("myfunction", arg1, arg2, as.integer(type), pBar, PACKAGE="annotSnpStats")

In the C function, I had

SEXP myfunction(SEXP arg1, SEXP arg2, SEXP Rtype, SEXP pBar) {

  int nprotect=0;
  SEXP utilsPackage, percentComplete;
  PROTECT(utilsPackage = eval(lang2(install("getNamespace"), ScalarString(mkChar("utils"))), R_GlobalEnv));
  PROTECT(percentComplete = allocVector(INTSXP, 1));
  int *rPercentComplete = INTEGER(percentComplete);

  for(i=0; i<nx; i++) { // index rows of x
  *rPercentComplete = i; //this value increments
  eval(lang4(install("setTxtProgressBar"), pBar, percentComplete, R_NilValue), utilsPackage);




And … it … just … worked! Happy day.

To see the full R function, go to dups in snp-match.R and the C is in countdiffs in comparisons.c.

Coloc v2.2

Coloc v2.2 is up on CRAN. The last two changes are shown below. The important thing is that the arguments to coloc.abf() have changed. Please do revise your code!

I do try and avoid completely changing arguments to released functions, but in this case, the function was introduced relatively recently, and the change makes sense because it allows us to analyse either datasets for which coefficients and standard errors are available, or for which only p values and minor allele frequencies are available, in a single function.

2013-19-06  Chris Wallace  <>

        * v2.2
        Merged coloc.abf and coloc.abf.imputed(), so that datasets for
        wheich beta, var(beta) are available can be matched to datasets
        with only p values and maf.2

        This means the arguments to coloc.abf() have been changed!  Please
        check ?coloc.abf for the new function.
2013-03-06  Chris Wallace  <>

        * v2.1
        Bug fix for coloc.abf() function, which used p12 instead of
        log(p12) to calculate L4.

        New function coloc.abf.imputed() to make better use of fuller
        information on imputed data.

Major update to coloc package

I am a co-author on another paper about colocalisation posted on arXiv. It’s a novel approach, using Bayesian inference based on Approximate Bayes Factors derived from p values, making colocalisation testing much more practical when data is not often as open access as claimed. My co-author, Vincent Plagnol, has written a nice post about it on Haldane’s Sieve.

The software to conduct these tests has been included in my coloc package, and I think such a change deserves a bump in version, so coloc v2.0 is now available on CRAN, together with a new vignette, explaining the different methods of analysis available, but see the papers 1 2 for the nitty gritty.

Writing R vignettes in emacs org mode using ox-ravel

I want to be able to write R vignettes in org-mode. Crazy, perhaps, but it has become my default way to write everything, notes on current projects, even beamer slides and papers. Now I need to write a vignette for the coloc R package, and switching to Sweave reminds me what a pain that is. So I had a play with knitr before, and liked it, but again it means learning a new markup syntax.

I have found ox-ravel, which means I can now write .org files, and export part or all to Sweave, knitr, brew, etc. I cannot stress just how fantastic this is, in allowing me to write everything in one syntax!

But setting it up required updating org-mode, because it requires the new ox export engine found in org-8. In the process, I didn’t want to break org2blog which I use to write these blog posts. Knowing this could get complicated, I documented each step here.

Continue reading