How to Fly

Flying is the action of being sustained above the ground without falling.

There is an art to flying, or rather a knack. The knack lies in learning how to throw yourself at the ground and miss.

The first part is easy. All it requires is simply the ability to throw yourself forward with all your weight, and the willingness not to mind that it's going to hurt.

So far I can do the first part very well.

Keep Source When Installing R Packages

When sourcing R functions from a file, the comments and indentation within the function body are kept and can be inspected in the console. Meanwhile, functions from installed packages, by default, are parsed to the standard format and all the comments are striped. What I often do when playing a package is to inspect the functions in the console and see how they are implemented, and I always hope to see the author's inline comments if possible. [Read More]

Callable S3/S4 Object in R

A function in R, like any other objects in R, can have additional attributes (or slots in S4), that is to say, a S3 or S4 object can inherit “function” semantics and become callable. The trick to enable the function to access its attributes or slots is to use sys.function function. Here is a simple example. pow <- function(x) { p <- attr(sys.function(), "p") if (is.null(p)) p <- 2 x^p } attr(pow, "p") <- 3 pow(2) ## [1] 8 We can modify the function’s attributes, leading to a different behavior of the function. [Read More]

TnT: GSoC 2017 Project Summary

Google Summer of Code The aim of this project is to provide an interactive and convenient approach to visualize track-based genomic data in R, that is, to provide a simple genome browser within R environment to view objects in bioconductor like GRanges, GRangesList, TxDb, EnsDb. In order to accomplish this goal, I developed a R package (TnT) mentored by Toby Hocking and Miguel Pignatelli, that wraps the TnT javascript libraries and provides functions to construct tracks from different data sources and show them as a simple genome browser in R. [Read More]