Skip to content

Instantly share code, notes, and snippets.

View al2na's full-sized avatar
💭
fishing 🎣

Altuna Akalin al2na

💭
fishing 🎣
View GitHub Profile

Here is how you can make a table in GFM format using knitr + ascii

render_gfm()
gfm_table <- function(x, ...) {
    require(ascii)
    y <- capture.output(print(ascii(x, ...), type = "org"))
 # substitute + with | for table markup
@al2na
al2na / read.bed.files.rrbs.R
Created March 3, 2013 07:55
read multiple rrbs bed files
file.list = list("wgEncodeHaibMethylRrbsA549Dm002p7dHaibSitesRep1.bed.gz",
"wgEncodeHaibMethylRrbsAg04449UwstamgrowprotSitesRep1.bed9.gz")
obj = read(file.list, sample.id = list("test", "control"), treatment = c(1,0),
assembly = "hg19", header = FALSE, context = "CpG", resolution = "base",
pipeline = list(fraction = FALSE, chr.col = 1, start.col = 3, end.col = 3,
coverage.col = 5, strand.col = 6, freqC.col = 11))
obj
## methylRawList object with 2 methylRaw objects
##
## methylRaw object with 1464031 rows
@al2na
al2na / read.rrbs.bed.R
Last active December 14, 2015 10:49
read ENCODE rrbs bed file
library(methylKit)
obj = read("wgEncodeHaibMethylRrbsA549Dm002p7dHaibSitesRep1.bed.gz",
sample.id = "test", assembly = "hg19", header = FALSE,
context = "CpG", resolution = "base",
pipeline = list(fraction = FALSE, chr.col = 1, start.col = 3,
end.col = 3,coverage.col = 5, strand.col = 6,
freqC.col = 11))
library(sqldf)
library(doBy)
library(plyr)
library(data.table)
n<-100000
grp1<-sample(1:750, n, replace=T)
grp2<-sample(1:750, n, replace=T)
d<-data.frame(x=rnorm(n), y=rnorm(n), grp1=grp1, grp2=grp2, n,
replace=T)
@al2na
al2na / read.BSMAP.ratio.methylKit.R
Created October 5, 2012 17:50
reading BSMAP ratio files
library(methylKit)
obj=read("bsmap_output.txt",sample.id="test",assembly="mm9",header=TRUE, context="CpG", resolution="base",
pipeline=list(fraction=TRUE,chr.col=1,start.col=2,end.col=2,
coverage.col=6,strand.col=3,freqC.col=5 )
)
obj