Showing posts with label Cufflinks. Show all posts
Showing posts with label Cufflinks. Show all posts

Wednesday, August 24, 2011

Extract insert size of paired-end reads from Cufflinks output

The new version of Cufflinks tries to estimate the mean and std value of paired-end read insert size automatically. Sometimes we need to extract such information to check our sequencing data. Here I wrote a simple script to search Cufflinks outputs.

The script is written in Python. The implementation is easy: search for key words (like "Estimated Mean", etc) in log files. The usage is as follows:


This script extracts insert size information from Cufflinks logs.
Usage: getinsertsize [cufflinks log file]
Note: you may specify different log files using filename wildcards.



Sample output:

File    MapMass ReadLength      Mean    Std
cufflinksinvoke.sh.e2148442     34108402.45     85      150.35  19.18
cufflinksinvoke.sh.e2148443     31007287.59     85      155.19  17.45
cufflinksinvoke.sh.e2148444     37286038.02     85      123.87  25.60

Source code:



Thursday, August 18, 2011

Converting Cufflinks .GTF predictions to .BED files

Cufflinks writes its predictions as .GTF files. However, this file type is sometimes too large to process. For example, it may be too large to upload to UCSC gene browser (even you compress it). IGV browser also takes more memory resources to process .GTF file than processing BED file. So I wrote a small script (in Python 3) to convert GTF formatted files to BED files. This helps to reduce the file size dramatically. For example, this script converts a 120M GTF file to only 9M BED file, reducing the size by more than 90%!

Of course there are general tools to convert .GTF to .BED. For example, here is one Perl script to do this. However, my script is written specifically for Cufflinks .GTF files: it recognizes "gene_id", "transcript_id" and "FPKM" key word in attribute lists. "transcript_id" is converted as the name field in .BED file, and "FPKM" value is rounded as "score" field in .BED file.

Here is one example of .GTF file predicted by Cufflinks:


chr1    Cufflinks       transcript      934797  935655  324     -       .       gene_id "CUFF.29"; transcript_id "CUFF.29.3"; FPKM "23.5107601622"; frac "0.216036"; conf_lo "20.031437"; conf_hi "26.990083"; cov "84.378021"; full_read_support "yes";
chr1    Cufflinks       exon    934797  934812  324     -       .       gene_id "CUFF.29"; transcript_id "CUFF.29.3"; exon_number "1"; FPKM "23.5107601622"; frac "0.216036"; conf_lo "20.031437"; conf_hi "26.990083"; cov "84.378021";
chr1    Cufflinks       exon    934906  935655  324     -       .       gene_id "CUFF.29"; transcript_id "CUFF.29.3"; exon_number "2"; FPKM "23.5107601622"; frac "0.216036"; conf_lo "20.031437"; conf_hi "26.990083"; cov "84.378021";

The converted .BED file includes only one line as follows:

chr1    934796  935655  CUFF.29.3       24      -       934796  935655  0,0,255 2       16,750  0,109

The record in .BED file doesnot contain information like "frac", "conf_low", "conf_hi", "cov". But it uses only one line instead of 4 lines. Notice that the transcript_id is kept and the FPKM value (23.5) is rounded to 24 in score field of .BED file.

Feel free to comment or ask questions.