Tuesday, August 12, 2014

Merge two kmer count hashes into one

 #!/usr/bin/perl  
 use warnings;  
 # Input parameters  
 open FASTA1, $ARGV[0] or die $!;  
 open FASTA2, $ARGV[1] or die $!;  
 my %seqs = ();  
 while($line = <FASTA1>){  
 chomp $line;  
 my @jelly=split(/\s+/,$line);  
 $seqs{$jelly[0]}=$jelly[1];  
 }  
 close FASTA1;  
 while($line = <FASTA2>){  
 chomp $line;  
 my @jelly=split(/\s+/,$line);  
 if(exists $seqs{$jelly[0]}){$seqs{$jelly[0]}=$seqs{$jelly[0]}+$jelly[1];}  
 else{$seqs{$jelly[0]}=$jelly[1];}  
 }  
 close FASTA2;  
 foreach $iso (sort keys %seqs) {  
 print "$iso\t$seqs{$iso}\n";  
 }  

Will take two lists of kmer counts and merge them into one. A kmer count list consists of two columns. The first column being the kmer itself and the second being its count.

This might be useful in merging the output of a program like jellyfish after running it on each chromosome separately. While jellyfish has a merge function, it requires the hashes to be of equal size.

May be this can be re-written as a perl one liner...

Ka ka ka ka ka ka ka ka

Previous crow stuff has been covered by Jerry Coyne himself. This in turn stimulates lot of debate on what constitutes a species. Fortunately, most people agree that understanding the genetics is more important and relevant than fighting over the definition of species. 

Like the title of this post, the call of a crow can be written as "ka ka ka ka ka" or "kaw kaw kaw kaw" or "Caw caw caw caw". They are all trying to capture the same thing. As long as the underlying genetics is well understood, it should be ok to not worry about the definition for now. Hopefully, over time our understanding of genetics will be so good that we may even come up with a single definition that most of us can agree on.

Monday, August 11, 2014

Get overlapping sequences from multifasta file

 #!/usr/bin/perl  
 #use strict;  
 use warnings;  
 # Input parameters  
 open FASTA, $ARGV[0] or die $!;  
 my $seqst_temp="";  
 my %seqs = ();  
 my $iso="";  
 my $maxlen=0;  
 my $maxval="";  
 while($line = <FASTA>){  
 if($line=~ /^>/){  
 if($header){  
 $seqs{$header}=$seqst_temp;  
 }  
 chomp $line;  
 $header="";  
 $header=$line;  
 $seqst_temp="";  
 }  
 else{  
 $line =~ s/[\n\t\f\r_0-9\s]//g;  
 $seqst_temp .= $line;  
 }  
 }#end of while loop  
 if($header){  
 $seqs{$header}=$seqst_temp;  
 }  
 close FASTA;  
 $maxlen=0;  
 foreach $iso (sort keys %seqs) {  
 my $line1=$iso;  
 my $line2=$seqs{$iso};  
 my $flag=0,$overlap=500,$length=1000;  
 $seqlen=length $line2;  
 while(($seqlen-$flag)>$length){  
 if(($seqlen-($flag+$overlap))<$length){  
 $length=$seqlen-$flag;  
 }  
 $nextseq=substr $line2,$flag,$length;  
 print $line1.":".$flag."-".($flag+$length)."\n";  
 print $nextseq."\n";  
 $flag=$flag+$overlap;  
 }#end of seqlen while loop  
 }  

Thursday, July 17, 2014

As the crow forks

We had our work on crows (The genomic landscape underlying phenotypic integrity in the face of gene flow in crows) published in the journal Science. Very interesting interpretations of the work ranging from it being proof for evolution to reasoning for human assortative mating in a political context have been presented. It has also been covered by the Swedish Radio, Der Spiegel (a popular German weekly) and few other offline sources.

A well written description of the science that puts the work in a broader context is also available.[It should also be noted that a description of another paper about the human polymorphic inversion 17q21 from the same author was a useful resource while looking at the ancestral state of our fixed differences.]

The whole genome was scanned for differences in DNA sequence content between carrion and hooded crows using 60 crows. While most of the genome is the same, small regions of the genome do show differences in DNA sequence and gene expression. These differences in DNA sequence are localized to specific regions of the genome. Infact all 81 of 82 fixed differences that we find are within a 2 megabase region. 

Snapshots of a region of the genome with fixed differences seen between hooded and carrion crow sequencing reads provides a very visual idea of how these fixed differences "look". Each of the boxes in the figure is a sequencing read (from the bam file) mapped to the reference genome. Positions which differ from the reference genome have the actual base that differs from the reference in each read.

Below figure shows the sequencing reads from one crow from Poland. Note that all the positions are similar to the reference genome. All 30 hooded crow individuals (from Sweden and Poland) look exactly like this at this base.


The next figure shows the sequencing reads from one crow from Germany at the same position as the hooded crow above. However, the blue box has "C" written in all its reads. At this position the Carrion crow has a base that is different from the Hooded crow reference genome. All the 30 carrion crows (from Spain and Germany) have this "C" base at this position.


Similar to the above position, we identify 81 other sites that show such a "fixed difference". The rest of the genome seems to be extremely similar between the carrion and hooded crows.

Friday, June 27, 2014

The Elephant Catchers

It has been 6 years since i read and blogged about Subroto Bagchi's book Go kiss the world. As with the previous book, finished reading the book "The Elephant Catchers" in one sitting. The writing style is very captivating and keeps you reading. 

The Elephant Catchers is all about growing a company that is hunting rabbits (small game) into one that now catches elephants. While many people start a startup, very few can make it into a self-sustaining and growing company. The book deals with the mistakes that happen and how to go about "fixing" those mistakes. 

Many anecdotes from different points along the way makes for an interesting read. The use of personification at different points to explain very different stories is very appealing. For example, at one point the company wins a big client who could be persuaded to hire a dog that is loyal instead of cat that is pleasing. 

Dividing the book into 6 parts with sub-chapters keeps it well organized. All of them have one thing in common, it is about scaling things. Be it scaling ideas or infrastructure the wisdom of having been there and having done that shines through brilliantly.

Monday, June 16, 2014

Largest known protein - Titin

With a length of more than 30Kb Titin is the largest known protein in the Human genome. Due to its repeated use of the same domains, it is thought have undergone very unpredictable exon losses. 

Apart from the biological reality of exon loss, the incredible length of the gene makes it prone to annotation errors. Prevalence of such large scale annotation errors makes it impossible to study the intricacies of the biology of such a gene. This is an attempt to identify such potential errors in annotation. The hope is that it will contribute to improving the annotation. 

Mutations in the Titin gene have been implicated in many diseases. Being the longest gene also makes it interesting from an evolutionary point of view. 

Chicken:

The human version of the gene (located on chr-2) has 363 annotated exons as per Human release 75 of Ensemble. The chicken version of the gene (located on chr-7) has only 47 annotated exons as per Chicken release 75 of Ensemble. Flanking genes are PLEKHA3 and CCDC141. However, a new gene, "ENSGALG00000026366" has been annotated in Chicken between PLEKHA3 and TITIN. While it has a name like "gga-mir-7474" and a link to the mirbase, it has gene type as protein coding. If that was not confusing enough, this gene has an aminoacid length of ~30Kb (has 269 exons). Given its location and length, it appears that the Titin gene has been incorrectly split into two genes (Titin itself and gga-mir-7474). As expected, the two genes are connected by a chicken cDNA EST (see figure below).



This "gga-mir-7474" gene gets top blast hit from Titin. 

So based on EST data and blast data these two genes can be merged as part of the Titin gene. We are still short by 47 more exons.

Flycatcher:

The release 75 of Ensemble has a ~61Kb long TTN gene with 106 exons annotated in Flycatcher. Two very short genes (with 1 and 2 exons) downstream from this TTN gene, ENSFALT00000015943 and ENSFALT00000003626 also give top blast hit to the TTN gene.

Even with availability of EST evidence, some very good objective predictions, the annotation seems rather sketchy.  


Wednesday, June 11, 2014

European crow hybrid zone poem

A poem by Jochen Wolf, that describes the European crow hybrid zone.

Crows are generally believed to be black,
but some think that they are grey.

fact is, both parties are right,
and anyway all crows are black at night.

but during day they meet along a narrow hybrid zone
where they eat and play.
and sometimes mate, and assortatively clone.
black with black and grey with grey.
so the question is: why do black and grey stay away.

to answer this riddle we climbed many pines,
and raised a good deal of young, for food that they shout.
we sequenced genomes and programmed
until the keyboard shines

and kind of
figured it out.