Skip to content

Instantly share code, notes, and snippets.

View stephenturner's full-sized avatar

Stephen Turner stephenturner

View GitHub Profile
@stephenturner
stephenturner / bootstrap632.r
Created April 15, 2022 16:34
.632 bootstrap proof
n <- 1e7
x <- sample(n, size=n, replace=TRUE)
length(unique(x))/n
# [1] 0.6321897
1-exp(-1)
# [1] 0.6321206
@stephenturner
stephenturner / install-gcc48-linuxbrew-centos6.md
Last active March 6, 2022 02:49
Installing gcc 4.8 and Linuxbrew on CentOS 6

Installing gcc 4.8 and Linuxbrew on CentOS 6

The GCC distributed with CentOS 6 is 4.4.7, which is pretty outdated. I'd like to use gcc 4.8+. Also, when trying to install Linuxbrew you run into a dependency loop where Homebrew's gcc depends on zlib, which depends on gcc. Here's how I solved the problem.

Note: Requires sudo privileges.

Resources:

@stephenturner
stephenturner / build-hdf5.sh
Created August 31, 2015 18:29
building hdf5 without root
# Run these lines
cd /path/to/wherever/it/should/go
wget http://www.hdfgroup.org/ftp/HDF5/current/src/hdf5-1.8.15-patch1.tar.gz
tar -zxvf hdf5-1.8.15-patch1.tar.gz
cd hdf5-1.8.15-patch1
./configure --disable-parallel --without-szlib --without-pthread --prefix=$(pwd)
make && make install
# Add this to your .bashrc
export HDF5="/path/to/wherever/it/should/go/hdf5-1.8.15-patch1"
@stephenturner
stephenturner / build-install-bcftools-home.sh
Last active November 24, 2021 13:14
Install htslib, bcftools, samtools to home directory
# Compile and install htslib, bcftools, samtools 1.9 to home directory
# Set up dirs where stuff will be installed
mkdir -p ${HOME}/bin/htslib
mkdir -p ${HOME}/bin/bcftools
mkdir -p ${HOME}/bin/samtools
# Make a dir to build
mkdir -p ${HOME}/tmp
@stephenturner
stephenturner / plink-split-up-bedfile-by-chromosome.pl
Created November 11, 2010 21:54
plink-split-up-bedfile-by-chromosome.pl
@stephenturner
stephenturner / .Rprofile.r
Last active July 19, 2021 22:05
My .Rprofile
## See http://gettinggeneticsdone.blogspot.com/2013/06/customize-rprofile.html
## Load packages
library(BiocInstaller)
## Don't show those silly significanct stars
options(show.signif.stars=FALSE)
## Do you want to automatically convert strings to factor variables in a data.frame?
## WARNING!!! This makes your code less portable/reproducible.
@stephenturner
stephenturner / get-uscode-wc.sh
Last active June 12, 2021 21:43
Get a rough word count of the entire US Code of Law
# Replace the parallel stuff with xargs if you don't have GNU parallel, or just pipe to 'sh'.
# Use 'wget' on linux, 'curl -O' on mac.
for i in $(seq -f "%02.f" 1 51); do echo "curl -O http://uscode.house.gov/download/pls/Title_$i.ZIP"; done | parallel
find *ZIP | parallel --dry-run unzip {}
cat *txt | wc
## Results:
# cat *txt | wc
# 6546729 45920853 338309328
@stephenturner
stephenturner / expressed_or_not.R
Last active June 6, 2021 03:17
are genes "expressed?"
library(dplyr)
library(readr)
# Get data from http://dx.doi.org/10.6084/m9.figshare.1601975
browseURL("http://dx.doi.org/10.6084/m9.figshare.1601975")
countdata <- read_csv("http://files.figshare.com/2439061/GSE37704_featurecounts.csv")
head(countdata)
metadata <- read_csv("http://files.figshare.com/2439060/GSE37704_metadata.csv")
head(metadata)
@stephenturner
stephenturner / volcanoplot.r
Last active May 13, 2021 20:11
code from blog post to make a volcano plot
# Download the data from github (click the "raw" button, save as a text file called "results.txt").
# https://gist.github.com/stephenturner/806e31fce55a8b7175af
res <- read.table("results.txt", header=TRUE)
head(res)
# Make a basic volcano plot
with(res, plot(log2FoldChange, -log10(pvalue), pch=20, main="Volcano plot", xlim=c(-2.5,2)))
# Add colored points: red if padj<0.05, orange of log2FC>1, green if both)
with(subset(res, padj<.05 ), points(log2FoldChange, -log10(pvalue), pch=20, col="red"))

This list is outdated. This post has a list of bioinformatics/genomics/genetics workshops and training materials that I haven't updated since 2015.


In-person courses

Note that many of the courses shown below also have course materials from past years publicly available online.

Cold Spring Harbor Courses: