Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # helper functions
- plot_sig <- function(sigtab, x="Species", color="Species", rank1="Family", rank2="Species", alpha=0.05, title=""){
- sig = sigtab[which(sigtab$padj < alpha), ]
- y = tapply(sig$log2FoldChange, sig[, rank1], function(z) max(z))
- y = sort(y, TRUE)
- sig[, rank1] = factor(as.character(sig[, rank1]), levels=names(y))
- y = tapply(sig$log2FoldChange, sig[, rank2], function(z) max(z))
- y = sort(y, TRUE)
- sig[, rank2] = factor(as.character(sig[, rank2]), levels=names(y))
- return(ggplot(sig, aes_string(x=x, y="log2FoldChange", color=color)) +
- geom_point(aes(size=baseMean)) + guides(col = guide_legend(ncol = 1)) +
- theme(axis.text.x = element_text(angle = 90, vjust=0.5)) + ggtitle(title))
- }
- plot_volcano <- function(sigtab, color="Family", label="Species", title=""){
- our_copy <- sigtab
- our_copy[,"neg.log10.padj"] <- -log10(our_copy$padj)
- return(ggplot(our_copy, aes_string(x="log2FoldChange", y="neg.log10.padj", color=color, label=label)) +
- geom_point(size=3) + geom_label() +
- theme(axis.text.x = element_text(angle = -90, hjust = 0, vjust=0.5), legend.position="bottom") +
- ggtitle(title) + geom_hline(aes(yintercept=-log10(.05))) + geom_vline(aes(xintercept=1)) + geom_vline(aes(xintercept=-1)))
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement