Skip to content

Instantly share code, notes, and snippets.

View vals's full-sized avatar

Valentine Svensson vals

View GitHub Profile
@vals
vals / estimate_size_factors.py
Last active August 29, 2015 13:57
NumPy implementation of estimateSizeFactorsForMatrix from DESeq
def estimate_size_factor(counts):
#COUNTS = GENES (rows) x CELLS (columns)
genes = counts[:, 0]
#ONLY COUNTS WITHOUT HEADER NOR GENES
counts = numpy.array(counts[1:, 1:], dtype = int)
#DONT REMOVE INFITE VALUES AS IT CAUSES PROBLEMS
log_counts = numpy.log(counts)
@vals
vals / stacked by factor.ipynb
Last active August 29, 2015 14:02
Stacked by factor
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@vals
vals / gist:fa2aa17c1fc349598527
Created March 24, 2015 09:19
Reproducing Cicular Coordinates
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
@vals
vals / measles.ipynb
Created April 13, 2015 14:57
Time series plot for measles incidence
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
"""Solve 'Towers of Hanoi'"""
import pylab as p;
import mpl_toolkits.mplot3d.axes3d as p3;
def solve(g,n):
X = [sum(g[0])]
Y = [sum(g[1])]
Z = [sum(g[2])]
moved = 0
@vals
vals / plot_the_percentages.py
Created November 11, 2011 13:42
Plot most common barcodes
from __future__ import with_statement
import matplotlib.pyplot as plt
plt.rc('xtick', labelsize='x-small')
import yaml
def convert(yaml_file):
"""Convert the data in a yaml file generated by count_barcodes.py to a
.dat file with space seperated sorted fractions of barcode distribution.
"""
@vals
vals / make_random_test_fastq.py
Created November 16, 2011 14:32
Randomly pick out some of the line triples in a fastq file and write to a new fastq file.
"""Randomly picks out some title / sequence / quality triples
from a given fastq file and writes them in to a new fastq file.
This is to generate rudimentary test data which doesn't take too long to run.
Usage: make_random_test_fastq.py <fastq_file> <target file size in MB>
"""
import os
import sys
from random import random
@vals
vals / gist:2037334
Created March 14, 2012 15:37
Format of the size logs
log_entry = {
'date': '2011-03-31T00:00:00',
'machine': 'SN167',
'project': '0255_A81BF6ABXX',
'size': 277025390592L
}
@vals
vals / bioit12_notes.md
Created April 29, 2012 19:01
Notes from Bio-IT World Expo 2012

###Jill Mesirov - Broad Institute

@broadinstitute

Broad has generated >150 TBPs in a year, how was this number calculated?


###Bas Burger - BT Global Commerce