{{ message }}

Instantly share code, notes, and snippets.

🎯
Focusing

# Guangchuang Yu GuangchuangYu

🎯
Focusing
Last active Aug 26, 2015
embed subview in ggplot2
View subview.md
```require(grid)
require(ggplot2)
require(magrittr)

theme_transparent <- function(...) {
theme(panel.background = element_rect(
fill = "transparent",
colour = NA),
plot.background = element_rect(```
Last active Aug 29, 2015
emacs for R
View emacs.md
Last active Aug 29, 2015 — forked from zjhiphop/ppurl-alternative.md
View ppurl-alternative.md

### Image Site

Created Feb 8, 2012
generate violin plot using ggplot2
View violin_plot.R
 p <- ggplot(mtcars, aes(factor(cyl),mpg, fill=factor(cyl), colour=factor(cyl))) p1 <- p+geom_violin(alpha=0.3, width=0.5) + geom_boxplot(width=0.2, outlier.colour=NA) p2 <- p+geom_violin(alpha=0.3, width=0.5) + geom_dotplot(binaxis='y', stackdir='center', dotsize=0.5)
Created Feb 9, 2012
calculating fibonacci number
View fibonacci.R
 fibonacci <- function(n) { u <- (1+sqrt(5))/2 (u^n - (1-u)^n) / sqrt(5) }
Created Apr 23, 2012
quantile quantile plot
View qqplot.R
 ## http://ygc.name/2011/08/02/q-q-plots/ qqplot <- function(y, distribution=qnorm) { x <- distribution(ppoints(y)) plot(x, sort(y), xlab="Theoretical Quantiles", ylab="Sample Quantiles", main="Normal Q-Q Plot" ) lines(y,y)
Created Apr 28, 2012
get points within a circle
View point_in_circle.R
 set.seed(123) x <- rnorm(100) y <- rnorm(100) points.df <- data.frame(x=x,y=y) center <- c(0.2, 0.3) diameter <- 2 d <- apply(points.df, 1, function(x) x-center)
Created May 2, 2012
bootstrap method for enrichment analysis
View bootstrapEnrichment.R
 # http://ygc.name/2012/04/29/bootstrap-for-enrichment-analysis/ goboot <- cmpfun(function(goid, sampleSize, nboot=1000) { ratio <- rep(0, nboot) allgene <- unique(mappedkeys(org.Hs.egGO)) allgeneInCategory <- unique(get(goid, org.Hs.egGO2ALLEGS))
Created May 17, 2012
venn plot
View vennplot.R
 x <- read.csv("/Volumes/YGC/Researches/ARCHIVE/Others/AL-1-by-GR.Yan/2D-data-and-analysis-result/2D.csv") eg <- as.character(x[,1]) require(clusterProfiler) xx <- enrichGO(eg, ont="BP") gg <- xx@geneInCategory names(gg) <- clusterProfiler:::TERM2NAME.BP(names(gg)) g <- gg[1:4] require(gplots) vm <- venn(g)
Created May 29, 2012
T test
View ttest.R
 ## http://ygc.name/2012/05/29/t-test/ p1 <- rnorm(1000) p2 <- rnorm(1000, sd=3) hist(p2, col="green", xlab="", main="") hist(p1, col="red", add=T) legend(legend=c("sd=1", "sd=3"), fill=c("green", "red"), x="topright")