Skip to content

Instantly share code, notes, and snippets.

@gauthamnair
gauthamnair / gist:cacd07b3b0f1a4ff72d0
Created July 11, 2015 20:42
transducers tic-tac
//--
// Clojure's Transducers
// (the simpler parts)
//--
// References:
@gauthamnair
gauthamnair / streamingIO
Created July 8, 2015 12:12
fromFPinscala + transducers.
package code
object Process0 {
sealed trait Process[I, O] {
import Process._
def |>[O2](p2: Process[O,O2]): Process[I,O2] = compose(this, p2)
def ++(p2: Process[I,O]): Process[I,O] = concat(this, p2)
def flatMap[O2](f: O => Process[I,O2]): Process[I,O2] = nest(this)(f)
}
Instructions: you would have to download and format the Marks et al. data from
their supplement first. Then, save this file as an .Rnw, Stangle and
source the resulting .R file.
Import data from Marks et al. Cell 2012.
<<>>=
dat <- read.table('./marks2i.serum.example.txt')
# > head(dat)
# GeneSymbol log2Fold pval
% Instructions: Save as .Rnw, run Stangle in an R session and source the resulting .R file.
% Some required libraries: data.table, GO.db, stringr
A helper function to exclude GO terms that are too small or too big, as measured by the number or genes annotated for it.
<<>>=
require(data.table)
f.GOsizefilter <- function( gotable, gosizecutoff=250, keepsmaller = TRUE ){
# gotable: One column is Category, another is GeneSymbol.
# One row for every Category that contains the gene
gotable <- as.data.table(gotable)