Skip to content

Instantly share code, notes, and snippets.

@macmanes
macmanes / streaming.sh
Created August 17, 2015 17:33
Streaming 2 pass Diginorm FTW!
interleave-reads.py file.1.fq.gz file.2.fq.gz \
| normalize-by-median.py --max-memory-usage 8e10 -C 30 -o - - \
| trim-low-abund.py -M 8e10 -o 2pass.fq --cutoff 2 --gzip -
@arundurvasula
arundurvasula / XKCD_sfs_plots.py
Last active November 8, 2015 20:09
Make an SFS from an MS output file
#!/bin/python
#xkcd SFS plots
# usage: ms 20 10000 -t 50 -r 10 1000 > neutral_ms.txt; python XKCD_sfs_plots.py neutral_ms.txt
from matplotlib import pyplot as plt
import numpy as np
from itertools import groupby
from sys import argv
ms_file = open(argv[1])
@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!
library(Rcpp)
body <- "
SEXP foo(const int len, Rcpp::NumericVector pr)
{
Rcpp::IntegerVector ret(len);
RNGScope();
for (int i=0; i<len; i++)
{
@davfre
davfre / bamfilter_oneliners.md
Last active January 18, 2025 22:47
SAM and BAM filtering oneliners
@ysaotome
ysaotome / install_pyenv.sh
Last active August 7, 2021 13:27
pyenv install for CentOS 6.5 x86_64
#!/bin/zsh
# pyenv install for CentOS 6.5 x86_64
yum install -y gcc gcc-c++ make git patch openssl-devel zlib-devel readline-devel sqlite-devel bzip2-devel
git clone git://github.com/yyuu/pyenv.git ~/.pyenv
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
@rchikhi
rchikhi / estimate-insert-sizes
Last active October 25, 2022 06:16
Quickly estimates insert sizes of read datasets, given some sequence(s) they can be mapped to. Requires BWA. Short usage: <reference> <*.fastq>
#!/usr/bin/env python
doc = """
Quickly estimates insert sizes of read datasets, given some sequence(s) they can be mapped to.
Author: Rayan Chikhi
short usage: <reference> <*.fastq>
example:
estimate-insert-sizes contigs.fa readsA_1.fq readsA_2.fq readsB_1.fq readsB_2.fq
@hadley
hadley / curriculum.md
Created September 27, 2013 20:24
My first stab at a basic R programming curriculum. I think teaching just these topics without overall motivating examples would be extremely boring, but if you're a self-taught R user, this might be useful to help spot your gaps.

Notes:

  • I've tried to break up in to separate pieces, but it's not always possible: e.g. knowledge of data structures and subsetting are tidy intertwined.

  • Level of Bloom's taxonomy listed in square brackets, e.g. http://bit.ly/15gqPEx. Few categories currently assess components higher in the taxonomy.

Programming R curriculum

Data structures

@arq5x
arq5x / unique-bash-history.sh
Created January 22, 2013 02:52
Unique BASH history
HISTCONTROL="erasedups"
export HISTCONTROL