Skip to content

Instantly share code, notes, and snippets.

@pmagwene
pmagwene / gist:1290415
Created October 16, 2011 01:55
create a numpy recarray from a matrix
nr1 = np.core.records.fromarrays(d1.transpose(), names=labels,formats=['f8']*191)
@pmagwene
pmagwene / gist:1298331
Created October 19, 2011 13:50
Get SNPs for gene from our Illumina data
from yeastgenome import samsnp
from yeastgenome import yeastgff as yff
from yeastgenome import yeastsnp
from yeastgenome import gff, gffsnp as gs
flist = gff.parse_GFFfeatures('./yeast-genome-Feb2011/saccharomyces_cerevisiae.gff')
gdict = gff.fasta_asdict('../yeast-genome-feb2011/saccharomyces_cerevisiae.gff')
bwa70 = samsnp.parse_samsnp('./PMY070/bwa.Feb2011/final.pileup')
@pmagwene
pmagwene / gist:1367153
Created November 15, 2011 14:05
Prevent TextMate from restoring files from last session
If you want to change this behavior, open Terminal.app and type
defaults write com.macromates.textmate OakDisableSessionRestore 1
This will make Textmate not remember the last session.
Change the 1 by 0 if you want the default behavior.
@pmagwene
pmagwene / gist:1991040
Created March 7, 2012 05:08
crude dotplot in matplotlib
# assumes pyplot and numpy are in namespace
import string
x = [1,4,5,9,9,11,13,14,18,20]
cats = [i for i in string.letters[:10]]
maxx = max(x)*1.10
ax = axes([0,0,1,1])
xlim(0,maxx)
ylim(0,11)
ticks = ax.yaxis.set_ticks(range(1,11))
@pmagwene
pmagwene / gist:2023405
Created March 12, 2012 17:09
build vim 7.3 on OS X w/non-system python and lua support

If using brew version of python

Make sure you brew as:

brew install --framework python

Configure

@pmagwene
pmagwene / gist:2212148
Created March 27, 2012 03:09
Lato based preamble for LaTeXit
\documentclass[10pt]{article}
\usepackage[usenames]{color} %used for font color
\usepackage{amssymb} %maths
\usepackage{amsmath} %maths\documentclass[10pt,letterpaper]{article}
%\usepackage[usenames]{color} %used for font color
\usepackage[HTML,dvipsnames,svgnames,x11names,hyperref]{xcolor}
\usepackage{amssymb} %maths
\usepackage{amsmath} %maths
\usepackage[utf8]{inputenc} %useful to type directly diacritic characters
@pmagwene
pmagwene / gist:2220955
Created March 27, 2012 22:21
samtools mpileup example
samtools mpileup -uf ../../yeast-genome-Feb2011/yeast-genome-Feb2011.fasta aln.sorted.bam | bcftools view -bvcg - > var.raw.bcf
bcftools view var.raw.bcf | vcfutils.pl varFilter -D400 > var.flt.vcf
@pmagwene
pmagwene / Accent.py
Created December 6, 2012 05:42 — forked from endolith/Accent.py
Documenting the matplotlib colormaps
# https://github.com/matplotlib/matplotlib/issues/881
# Several of the ColorBrewer maps are "qualitative", meaning
# they are just a group of colors that can be used together
# for categories of data. So I remapped Accent to segments
# instead of continuous:
# Actually, these should be used with ListedColormap, and
# the number of colors should depend on the number of
# categories in the data, with colors removed from the
# list in a certain order?
{
"metadata": {
"name": "",
"signature": "sha256:4632c48d2d93ec86103808ed599b94a33dfdda25ab937192359f68ab92ee1ec0"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
library(tidyr)
library(dplyr)
library(magrittr)
library(ggplot2)
# load data in "wide" format (genes in columns)
spellman <- read.csv("spellman-reformated.csv")
# restructure in "long" format
spellman.long <- gather(spellman, gene, expression, -expt, -time)