Skip to content

Instantly share code, notes, and snippets.

View aaronsaunders's full-sized avatar

Aaron Marc Saunders aaronsaunders

View GitHub Profile
p1 <- pw + geom_point() + facet_grid(.~g, scales='fixed') + coord_equal() +
stat_smooth(method='lm')
p2 <- px + geom_point() + facet_grid(.~g, scales='fixed') + coord_equal() +
stat_smooth(method='lm')
p3 <- pz + geom_point() + facet_grid(.~g, scales='fixed') + coord_equal() +
stat_smooth(method='lm')
grid.arrange(p1, p2, p3, ncol=1)
@aaronsaunders
aaronsaunders / UTF-8-sig-decode.py
Created October 1, 2013 08:38
>print data_list '\xef\xbb\xbfsome_data1' source: http://stackoverflow.com/questions/18664712/split-function-add-xef-xbb-xbf-n-to-my-list UTF-8 BOM in the beginning. To get rid of it, first decode your file contents to unicode.
fp = open("file.txt")
data = fp.read().decode("utf-8-sig").encode("utf-8")
@aaronsaunders
aaronsaunders / random-sample-list.py
Created October 1, 2013 08:41
Get random sample from list while maintaining ordering of items? I have a sorted list, let say: (its not really just numbers, its a list of objects that are sorted with a complicated time consuming algorithm) mylist = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 ,9 , 10 ] Is there some python function that will give me N of the items, but will keep the order…
# Following code will generate a random sample of size 4.
rand_smpl = [ mylist[i] for i in sorted(random.sample(xrange(len(mylist)), 4)) ]
#!/usr/bin/env python
import fileinput
import sys
from argparse import ArgumentParser
# https://docs.python.org/dev/library/argparse.html
parser = argparse.ArgumentParser(description = """docstring here""")
parser.add_argument('-i','--input',
@aaronsaunders
aaronsaunders / 0_reuse_code.js
Created October 23, 2013 10:44
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@aaronsaunders
aaronsaunders / .Rprofile
Last active December 26, 2015 13:49
Dotfiles
# from https://gist.github.com/stephenturner/5700920
# http://inundata.org/2011/09/29/customizing-your-rprofile/
## Returns names(df) in single column, numbered matrix format.
.env$n <- function(df) matrix(names(df))
# Shorten S3 methods so s(obj) instead of summary(obj)
s <- base::summary;
h <- utils::head;
n <- base::names;
@aaronsaunders
aaronsaunders / biofileformat.py
Created October 27, 2013 20:25
file parsing and length plotting
"""
Mappings from file extensions to biopython types.
Copied from Erik Matsens seqmagick https://github.com/fhcrc/seqmagick/
"""
import argparse
import contextlib
import copy
import functools
@aaronsaunders
aaronsaunders / qiime_demo.ipynb
Last active December 26, 2015 21:09
An example analysis of 16S rRNA amplicons using QIIME.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@aaronsaunders
aaronsaunders / nix-cheat.sh
Last active January 25, 2021 06:54
Quick reference for nix command line commands that I can never remember...
# Unix shell
# run if zero exit
cd tmp/a/b/c && tar xvf ~/archive.tar # untar if dir exists
# run if non-zero exit
cd tmp/a/b/c || mkdir -p tmp/a/b/c
cd tmp/a/b/c || mkdir -p tmp/a/b/c && tar xvf -C tmp/a/b/c ~/archive.tar
which
whereis
@aaronsaunders
aaronsaunders / .gitignore
Last active August 29, 2015 14:01 — forked from octocat/.gitignore
My .gitignore template
# emacs backups
*~
\#*#
# data files
*.log
*.tsv
*.dat
# image files