Archive for December, 2011

Evolutions of LD across generation

December 19, 2011 Leave a comment

A classical way to present LD is ploting LD structure (with e.g. Haploview) anyway, while giving us a good overview of the LD in a certain population, this does not give any hints on how this structure evolve across generations.

So I decided to write for fun a little script, looking over 50 non overlapping generations the LD plot obtained by Haploview.

The population contain 1000 individuals per generation. The marker map have 100 markers spanning 7cM.

I then split my simulated genotypes file according to generations. And for each of them generate a LD plot.

And last but not the least I merged all the plot to obtain an animated gif with ImageMagick.

And here is the result !

A very funny thing is to see how fast some SNP are fixed (I made no assumption on MAF in founders population). I tested several scenario, with varying selection pressure . The one used here is rather simple :

  • Generations 1 to 5 use 100 males 500 females,
  • Generations 6 to 10 use 50 males/250 females,
  • Generations 11 to 15  10 males/200 females,
  • Generations 16 to 50  20 males/200 females.

While no LD is supposed at generation 1, we can see pretty fast that LD is created, and once pattern are observed they remain stable for a while.


Automation (1)

December 15, 2011 2 comments

Programmers should always try to be as lazy as they can. This post will explain several tricks used to retrieve automatically some password protected zipped file on a ftp server in an automated way.

Connection to the ftp server

Basically, the difficulty will be to establih a connection without entering the password.  The thing is just to write (or modifiy) a parameter file called .netrc in your home directory.

This file is a simple text file protected by permissions  set to 600 (chmod 600 .netrc).

It will contain for each (ftp) server you will be connected to, three lines :

  1. a name of the server (or ip address)
  2. a login
  3. a password

Once your .netrc is set, in order to connect to the server, you ‘ll only have to write the following command in a terminal.


And you ‘ll be automatically connected !

Retrieving the data

In an interactive ftp session , you would have to write basic command on the server to change directory and get data. In an automated script, you’ll have to write all this command in a text file and pass the later to ftp client.

So if we must move to the directory Mydir1 and get the file “file1”, we’ll have to create a file with the following instructions :

cat ><<EOF
 cd Mydir1

and then execute :

ftp <

Or in a more straight forward way :

ftp -i<<EOF
 cd Mydir1

Possible difficulties :

If we know that the name of the directory will change, let’s say Mydir1 can change to Mydir2, we may use in our script before submission a variable.

If the file name change is unpredictable (let says there is a suffixe giving the creation date in ddmmyyhhmmss) you’ll have no other choice than using mget instead of get. mget accept to retrieve file matching a pattern expressed with meta caracters.

Our script will become :

cat >ftp <<EOF
cd Mydir$num
mget file*.zip


Now that the file is downloaded, we’ll have to unzip it, which can been done with the following command :

for fic in  file*.zip
unzip -P "PassWord" $fic

Putting all the later instructions in a shell script file allow me to spare some time (unfortunately this time has also been automaticaly used to work on another task…poor me !)

Categories: Linux, Shell