Archive

Archive for November, 2011

It has to happen !

November 18, 2011 Leave a comment

You may have goals, that you haven’t reached yet , but you keep believing that one day you’ll achieve them, and… one day it finally happen . This has been the case for two of my secret goal !

As an unconditional emacs user, I knew that soon or later I would try to write my own emacs mode. I had the occasion to achieve this objective while testing a phasing program.

When comparing phased data, you generally want to align two phases and see on which SNP do you observe discrepancies. Nevertheless with thousands SNP, this looks like searching for a needle in a hay stack.  This can be done more efficiently with colored data. The idea is to just to associate a color to a list a character.

But as I am still a bit confused with lisp syntax, I just try to find some good example on the net.

And based on this write this piece of lisp code.

;;Define some attribute for each allele
 (setq myAllele
 '((" [1Aa]" . font-lock-function-name-face)
 (" [2Cc]" . font-lock-warning-face)
 (" [Gg]" . font-lock-constant-face)
 (" [Tt]" . font-lock-comment-face)
 (" [0\.]" . font-lock-builtin-face)
 ))
 ;;load this new attribute
 (define-derived-mode SNP-mode fundamental-mode
 (setq font-lock-defaults '(myAllele))
 (setq mode-name "SNP mode")
 (setq truncate-lines t)
 )

All this code is in a file called SNP.el stored in my ~/.emacs.d/

  1. The first block of code define association between allele and font-lock attribute
  2. The second block define the mode and ask for line truncation

And in order to allow use this mode automatically, I add in my .emacs

load "~/.emacs.d/SNP.el")

To go one step forward, as I know that most of my genotype or phase file are named like “phase*” or “typ*”, I add also a hook i.e. these 2 lines

(setq auto-mode-alist
 (cons '("typ+[1-9]" . SNP-mode) auto-mode-alist)
 (cons '("typ+[1-9]" . SNP-mode) auto-mode-alist))

Now everytime I open a genotype file (stariting either by “typ” or “phase”, the SNP-mode is loaded and I thus obtain this kind of screen.

Now there no way I could miss something awesome in the genome !

For the laziest of you the SNP-mode is available here

And for those wondering what was my other achievement, you are certainly not aware of the bedrace World championship !

Advertisements

You’ll never play poker the same way

November 8, 2011 Leave a comment

While surfing on the web I recently found this very entertaining and well explained video

I not only learned a nice cards trick (I hope I can bet and win some beers with it !), but I really enjoyed the idea that there is always a way to understand a process which may turned out not to be as “random” as one would expect.

A funny point is to notice that gambling seems to be a possible way for skilled statisticians to earn money, it’s the second time I read about such story (further discussed here).

 

Categories: Misc