This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "Get verbatim R chunks in R Markdown" | |
author: "Jenny Bryan" | |
date: "18 September, 2014" | |
output: | |
html_document: | |
keep_md: TRUE | |
--- | |
My periodic revisitation of "how can I include a verbatim R chunk in `.rmd`"? This time I am writing it down! Various proposed solutions: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "GrammaR of graphics using `ggplot2` in R" | |
author: "John Stanton-Geddes" | |
date: "December 8, 2014" | |
output: html_document | |
--- | |
The `ggplot2` package, deveoped by Hadley Wickham, is the most downloaded R package of [all time](http://www.rdocumentation.org/) and one of the standards for publication-ready figures. Fron the [ggplot website](http://ggplot2.org/) | |
> ggplot2 is a plotting system for R, based on the grammar of graphics, which tries to take the good parts of base and lattice graphics and none of the bad parts. It takes care of many of the fiddly details that make plotting a hassle (like drawing legends) as well as providing a powerful model of graphics that makes it easy to produce complex multi-layered graphics.) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#################################### | |
# TITLE: ONEWAY.R | |
# PURPOSE: ILLUSTRATE ONE WAY ANALYSIS OF VARIANCE | |
# DATA: AGES AT WHICH INFANTS FIRST WALKED ALONE, FROM FISHER AND VAN BELLE (2nd edition), | |
# PAGE 359. FOUR GROUPS: ACTIVE GROUP, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df <- data.frame(gene = rep(c(paste("gene", 1:10, sep="")), 5), | |
treatment = rep(paste("trt", 1:5, sep=""), each=10), | |
temp = rep(1:5, each=10), | |
exp = rnorm(50)) | |
head(df) | |
# lm for a single gene | |
lmout <- lm(exp ~ temp, data = df[df$gene == "gene1", ]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Script to compare Reads per Kilobase per Million mapped reads (RPKM) to Transcripts per Million (TPM) for gene expression count data | |
# Wagner et al. 2012 "Measurement of mRNA abundance using RNA-seq data: RPKM measure | |
# is inconsistent among samples" Theory Biosci. 131:281-285 | |
library(plyr) | |
## Worked example from http://blog.nextgenetics.net/?e=51 | |
X <- data.frame(gene=c("A","B","C","D","E"), count=c(80, 10, 6, 3, 1), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
import screed, sys, itertools | |
s1_file = sys.argv[1] | |
s2_file = sys.argv[2] | |
for r1, r2 in itertools.izip(screed.open(s1_file), screed.open(s2_file)): | |
name1 = r1.name | |
if not name1.endswith('/1'): | |
name1 += '/1' |