Skip to content

Instantly share code, notes, and snippets.

View GuangchuangYu's full-sized avatar
🎯
Focusing

Guangchuang Yu GuangchuangYu

🎯
Focusing
View GitHub Profile
@GuangchuangYu
GuangchuangYu / emacs.md
Last active August 29, 2015 14:14
emacs for R
@GuangchuangYu
GuangchuangYu / subview.md
Last active August 26, 2015 13:13
embed subview in ggplot2
require(grid)
require(ggplot2)
require(magrittr)

theme_transparent <- function(...) {
    theme(panel.background = element_rect(
              fill = "transparent",
              colour = NA),
 plot.background = element_rect(
require(TxDb.Hsapiens.UCSC.hg19.knownGene)
txdb <- TxDb.Hsapiens.UCSC.hg19.knownGene
library(ChIPseeker)
library(GenomicRanges)
# Hack chipseeker function to add annotaiton
getGenomicAnnoStat <- function(peakAnno) {
if ( class(peakAnno) == "GRanges" )
peakAnno <- as.data.frame(peakAnno)
anno <- peakAnno$annotation
## anno <- sub(" \\(.+", "", anno)
## devtools::install_github("stephenturner/msigdf")
library(msigdf)
library(dplyr)
library(clusterProfiler)
c2 <- msigdf.human %>%
filter(collection == "c2") %>% select(geneset, entrez) %>% as.data.frame
data(geneList)
de <- names(geneList)[1:100]

No update since 2014.

## Access date: 2017-01-04
$ svn log -q |grep 'z.li'
r87229 | z.li | 2014-03-08 12:13:28 +0800 (Sat, 08 Mar 2014)
r85532 | z.li | 2014-01-15 13:00:43 +0800 (Wed, 15 Jan 2014)
r85454 | z.li | 2014-01-12 13:57:16 +0800 (Sun, 12 Jan 2014)
r72578 | z.li | 2013-01-16 15:11:20 +0800 (Wed, 16 Jan 2013)
r72577 | z.li | 2013-01-16 13:43:05 +0800 (Wed, 16 Jan 2013)
f <- function(a, b) function(y) a * y * log(y, base=10) -1/b * exp(-(b*y - b/exp(1))^4)
y <- seq(0, 1, length.out=100)
cols = colorspace::rainbow_hcl(5)
d1 <- data.frame(x = f(3, 30)(y), y=y, color=cols[1])
d2 <- data.frame(x = f(2.8, 33)(y), y=y, color=cols[2])
d3 <- data.frame(x = f(2.5, 36)(y), y=y, color=cols[3])
d4 <- data.frame(x = f(2.2, 40)(y), y=y, color=cols[4])
d5 <- data.frame(x = f(2, 50)(y), y=y, color=cols[5])
qbar <- function(x, verbose=TRUE) {
enc = encoding(quality(x))
qual <- sapply(seq_along(x), function(i) enc[to_char_vector(x[i])])
mq <- rowMeans(qual)
if (verbose) {
names(mq) <- NULL
print(mq)
}
d = structure(list(x = c(516.362976074219, 514.883316040039, 510.306549072266,
502.721382141113, 492.303680419922, 479.293769836426, 463.977825164795,
446.675720214844, 427.74100112915, 407.568737030029, 386.590072631836,
365.25927734375, 344.028457641602, 323.352523803711, 303.678215026855,
285.42236328125, 268.959743499756, 254.630310058594, 242.738302230835,
233.550735473633, 227.284624099731, 224.07541847229, 223.949848175049,
226.633100509644, 232.021848678589, 240.107601165771, 248.467231750488,
256.632625579834, 264.798046112061, 272.827682495117, 279.170124053955,
284.358814239502, 288.348812103271, 291.169918060303, 292.902908325195,
293.650428771973, 293.608024597168, 292.990119934082, 291.361457824707,