Monday, May 26, 2014

Coursera course review : Interactive Python Programming

An Introduction to Interactive Programming in Python

Although it says "introduction in the title", do not be misled to think that it is an introduction to Python programming, rather, it is introducing *interactive* Python programming. Reading through the course forum, many beginners found it hard to grasp concepts fast enough to be able to do the weekly coding mini-projects (my background : I use Python everyday at work for years. I would say that if you are not completely clueless about programming, and have at least some encounter with coding concepts, this course is manageable). Having said that, the forum is a great resource and there are lots of people willing to help you out with coding problems and point you in the right direction.

You write and execute your code on CodeSkulptor (made by Scott, one of the course instructors). Great tool to eliminate the need for installs and there are custom modules created to take away the nitty gritty parts of graphical programming - and that helps lessens the frustration of potentially dealing with more technical issues.

What attracted me most to this course is the application of the concepts learned. Each week, students will code a game. You start text-based, and at the end you code a graphical game with sound and animation!

This course is a good example of applied coding skills, and the course instructors were very good in presenting concepts and helping with framing the projects, and kick-starting the enthusiasm to complete them every week.

Verdict: Highly recommended, and lots of fun.

Wednesday, May 21, 2014

Useful Javascript functions!

Personal list of useful functions:

Converting a Javascript array to a function arguments list 
Very important for writing short code when passing values to another function (exploding the list).

Tuesday, May 6, 2014

Adding column entries to DataFrame objects

The DataFrame class comes from the IRanges package and is used by several other packages (eg. Rsamtools) to read in bam files.

Simply cbind-ing a column to the DataFrame object will change it to the more conventional data.frame class.

So, instead of 
cbind(object1,newcolumn)

do:
cbind(object1,DataFrame(newcolumn))

to ensure that the result is still in the DataFrame class.

Monday, May 5, 2014

Subsetting/ extracting reads from bam files

1. Regions (make an index first, then select your regions)
samtools index bam_file 
samtools view -b file.bam chr1 > file_chr1.bam 
samtools view -b file.bam chr1:1-10000 > file_chr1_1_10000.bam 

2. Regions given in bed file
samtools view -bL regions.bed file.bam > file_regions.bam 

3. First n reads
samtools view -h file.bam | head -n 10000 | samtools view -bS - > file_n10000.bam