Skip to content

Instantly share code, notes, and snippets.

View stephenturner's full-sized avatar

Stephen Turner stephenturner

View GitHub Profile
install.packages("dynamicTreeCut")
install.packages("RPMM")
install.packages("sqldf")
install.packages("parallel")
install.packages("data.table")
install.packages("shiny")
install.packages("ggplot2")
install.packages("plyr")
install.packages("dplyr")
install.packages("tidyr")

Keybase proof

I hereby claim:

  • I am stephenturner on github.
  • I am turner (https://keybase.io/turner) on keybase.
  • I have a public key whose fingerprint is C3FF 1534 9B0A AA92 67B0 7461 32DB A6EC 08E5 BE05

To claim this, I am signing this object:

@stephenturner
stephenturner / thedress_heatmap.r
Created February 27, 2015 20:27
the dress heatmap
library(NMF)
set.seed(42)
m1 <- matrix(rnorm(20000*5, mean=0), nrow=5)
m2 <- matrix(rnorm(20000*5, mean=1.2), nrow=5)
m <- cbind(t(m1), t(m2))
myiqr <- apply(m, 1, var, na.rm=T)
mostvar <- order(myiqr, decreasing=T)[1:20]
hmat <- m[mostvar, ]
aheatmap(hmat, col=colorRampPalette(c("#806E46", "#968264", "#8794BE", "#838CC3", "#656581"))(100), labRow=NA, labCol=NA, scale="row")
[include]
# For user/credentials/token/etc
path = ~/.gitconfig.local
[core]
editor = vim
excludesfile = ~/.gitignore
[color]
branch = auto
diff = auto
status = auto
@stephenturner
stephenturner / swc-install.sh
Last active August 29, 2015 14:14
Install stuff for swc class
# Get some basic software that you'll need. Edit the first line below. Then update all software and system.
sudo apt-get -y install gcc make vim git
sudo apt-get -y update
sudo apt-get -y upgrade
sudo reboot
## Not necessary, but installing guest additions will allow you to go fullscreen and share files with the host.
# First you'll need the linux headers for your distribution
sudo apt-get -y install linux-headers-generic linux-headers-$(uname -r)
# In Vbox "insert" the guest additions CD, and then cd to /media/user/disc
@stephenturner
stephenturner / readtable_v_fread.R
Created January 14, 2015 19:49
read.table vs fread
# Generate dataset with 5,000,000 rows, and some random numbers from normal,
# uniform, and cauchy distributions. Write out to file (warning, ~330MB)
n <- 5000000
d <- data.frame(a=1:n, b=rnorm(n), c=runif(n), d=rcauchy(n))
write.table(d, file="test.txt")
# Import the regular way with read.table
system.time(in1 <- read.table("test.txt"))
## Crikey!
@stephenturner
stephenturner / microbenchmark-blog-post.R
Last active July 28, 2017 19:56
Code for GGD blog post on microbenchmark
# see blog post here:
# http://gettinggeneticsdone.blogspot.com/2015/01/microbenchmark-package-r-compare-runtime-r-expressions.html
library(dplyr)
library(nycflights13)
flights
# base
aggregate(flights$arr_delay, by=list(flights$carrier), mean, na.rm=TRUE)
# RNA-seq: differential gene expression analysis
*[back to course contents](..)*
This is an introduction to RNAseq analysis involving reading in count data from an RNAseq experiment, exploring the data using base R functions and then analysis with the DESeq2 package.
## Install and load packages
First, we'll need to install some add-on packages. Most generic R packages are hosted on the Comprehensive R Archive Network (CRAN, <http://cran.us.r-project.org/>). To install one of these packages, you would use `install.packages("packagename")`. You only need to install a package once, then load it each time using `library(packagename)`. Let's install the **gplots** and **calibrate** packages.
@stephenturner
stephenturner / import-beadstudio.R
Last active August 29, 2015 14:11
Code to import and pre-process beadchip data exported from GenomeStudio
#######################################################################
#
# import-beadstudio.R
# Stephen Turner, December 2014
#
# Ask the core to export text file data with the info below.
# Assumes control probe file has for each sample:
# ProbeID, AVG_Signal, BEAD_STDERR, Avg_NBEADS, Detection Pval.
# Assumes sample probe file has for each sample:
# ProbeID, Symbol, AVG_Signal, BEAD_STDERR, Avg_NBEADS, Detection Pval
---
title: "Untitled"
author: "Stephen Turner"
date: "September 4, 2014"
output:
html_document:
keep_md: true
---
This is markdown text.