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

Monday, April 21, 2014

Book review : Programming the Semantic Web


I picked up this book wanting to learn more on NoSQL that I had to implement in developing some packages. This book serves well as a beginners guide : why we need semantics, and compares current ideas and structure of SQL databases to the more flexible and abstract forms that it is trying to promote.

For me it was written in a very logical progression and concepts were introduced in a very good pace. The book goes on to talk about RDF and OWL together with how they can be implemented (O'Reilly has another book Learning SPARQL which may be a logical progressing after this book). No doubt it is not going to make you a pro on the subject, but it was sufficient for me to understand the basics of semantic data structures.

Few things you might want to take note:
  1. this book uses Python, so a basic understanding would be very helpful to understand how things are implemented
  2. the website semprog.com is not available anymore, but you can get the code package at http://examples.oreilly.com/9780596153823/Programming-the-Semantic-Web.zip
Overall, a good introductory book.

PS: If you don't like to read, youtube now has a lot of channels talking about NoSQL and semantics including O'Reilly themselves, so you might want to check that out.

Friday, March 28, 2014

Version control systems

The type of version control system (Git vs SVN vs CVS vs Mercurial) used would likely not have much impact while working within a single lab environment (with one or two coders). I started thinking more about this when moving some of my more "public" code from an SVN-based Unfuddle over to GitHub. Git is more suited when working in a larger group, and then there are the concept or forking/pulling is great. The only thing stopping me from moving wholesale is the pricing option for private repos (Unfuddle is free). I also like that Bioconductor can bridge its SVN repo with Github (so I can share my code easily as well) and I also enjoy the whole user experience of the site.

As for now, I'm on both. I'm thinking of moving my private repos to BitBucket, which supports Git and Mercurial. The ability to work with a local repo (Git) while on the road is very useful.

Some further self-reading : http://stackoverflow.com/questions/871/why-is-git-better-than-subversion