Skip to content

Instantly share code, notes, and snippets.

Jeff S Jasper jasper1918

  • Q2 Solutions | EA Genomics
  • United States
Block or report user

Report or block jasper1918

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:36db5617bc238ace80268971c5b3e6eb
plot_fc<-function(df, key1_x, key1_y, key2_x, key2_y, plot_xlab="", plot_ylab=""){
l1x<-log2(df[,key1_x] +1)
l1y<-log2(df[,key1_y] +1)
l2x<-log2(df[,key2_x] +1)
l2y<-log2(df[,key2_y] +1)
diff1 <- l1x - l1y
diff2 <- l2x - l2y
names(diff1) <- "DIFF1"
names(diff2) <- "DIFF2"
View gist:790b11348b0507d65b2f37141913b30d
plot_ma<- function(dat, rep1, rep2, main_title=""){
l1<-log2(dat[,rep1] +1)
l2<-log2(dat[,rep2] +1)
diff <- l1 - l2
names(diff) <- "LOG2FC"
ave <- rowMeans(cbind(l1, l2), na.rm=TRUE)
df <- data.frame(rep1=l1, rep2=l2, "LOG2FC"=diff, "AVE_EXP"=ave, check.names = F)
max_y<-ceiling(max(abs(max(df$LOG2FC)),abs(min(df$LOG2FC)), 2))
seq_y<-round(seq(-max_y, max_y, by = .5),1)
#df$OUT1<-ifelse(abs(df$LOG2FC)>1, 0,1)
View ggplot_linearity.R
# ggplot with equation
lm_eqn <- function(df, key_y, key_x){
m<-lm(formula(paste(key_y,"~",key_x)), df)
eq <- substitute(italic(y) == b %.% italic(x) + a*","~~italic(R)^2~"="~r2,
list(a = formatC(coef(m)[1], digits = 4,format="f", flag="#"),
b = formatC(coef(m)[2], digits = 4,format = "f", flag="#"),
r2 = formatC(summary(m)$r.squared, digits = 4,format = "f", flag="#")))
as.character(as.expression(eq))
}
View mypca.R
mypca<-function(x, mytitle="", ...)
{
par(mfrow=c(1,1))
this_pc <- prcomp(x, scale=FALSE)
this_pc_coord <- this_pc$x
pc1pct=round(summary(this_pc)$importance[2,1]*100,2)
pc2pct=round(summary(this_pc)$importance[2,2]*100,2)
par(mar = c(8, 5, 3, 8), xpd=T)
plot(this_pc_coord[,1], this_pc_coord[,2], pch = 19, cex=2,
@jasper1918
jasper1918 / pairs_mod.R
Created Mar 14, 2017
my favorite pairs
View pairs_mod.R
# pairs(df, lower.panel=panel.smooth, upper.panel=panel.cor, diag.panel=panel.hist)
panel.cor <- function(x, y, digits=2, prefix="", cex.cor)
{
usr <- par("usr"); on.exit(par(usr))
par(usr = c(0, 1, 0, 1))
r <- abs(cor(x, y))
txt <- format(c(r, 0.123456789), digits=digits)[1]
txt <- paste(prefix, txt, sep="")
if(missing(cex.cor)) cex <- 0.8/strwidth(txt)
You can’t perform that action at this time.