Skip to content

Instantly share code, notes, and snippets.

View philippbayer's full-sized avatar

Philipp Bayer philippbayer

View GitHub Profile
@philippbayer
philippbayer / bla
Last active August 29, 2015 13:56
weirdness in rpy2
In R:
png("heatmap_before_sorting.png")
image(distance_matrix)
dev.off()
library("gclus")
ordered <- order.single(distance_matrix, clusters=NULL)
sorted_matrix <- distance_matrix[ordered, ordered]
In Python:
@philippbayer
philippbayer / blabla
Created June 11, 2015 21:01
getting 1000 genomes data with tabix and python
urls={"1":"ftp://ftp-trace.ncbi.nih.gov/1000genomes/ftp/release/20130502/ALL.chr1.phase3_shapeit2_mvncall_integrated_v5a.20130502.genotypes.vcf.gz",
"10":"ftp://ftp-trace.ncbi.nih.gov/1000genomes/ftp/release/20130502/ALL.chr10.phase3_shapeit2_mvncall_integrated_v5a.20130502.genotypes.vcf.gz",
"11":"ftp://ftp-trace.ncbi.nih.gov/1000genomes/ftp/release/20130502/ALL.chr11.phase3_shapeit2_mvncall_integrated_v5a.20130502.genotypes.vcf.gz",
"12":"ftp://ftp-trace.ncbi.nih.gov/1000genomes/ftp/release/20130502/ALL.chr12.phase3_shapeit2_mvncall_integrated_v5a.20130502.genotypes.vcf.gz",
"13":"ftp://ftp-trace.ncbi.nih.gov/1000genomes/ftp/release/20130502/ALL.chr13.phase3_shapeit2_mvncall_integrated_v5a.20130502.genotypes.vcf.gz",
"14":"ftp://ftp-trace.ncbi.nih.gov/1000genomes/ftp/release/20130502/ALL.chr14.phase3_shapeit2_mvncall_integrated_v5a.20130502.genotypes.vcf.gz",
"15":"ftp://ftp-trace.ncbi.nih.gov/1000genomes/ftp/release/20130502/ALL.chr15.phase3_shapeit2_mvncall_integrated_v5a.20130502.genotypes.vcf.gz",
"16":
@philippbayer
philippbayer / juliapython.jlpy
Created April 2, 2012 04:27
Julia vs. Python 2.7 Parsing
$ python2.7 parse.py
0.797344923019
$ julia parse.jl
16789.66212272644
o.O
Tested against a 91mb big tab-delimited input-file.
With a 800mb big file:
@philippbayer
philippbayer / pyvsruby.rb
Created April 10, 2012 04:31
Python vs Ruby
min = 1000000000
5.times do
t = Time.now
File.open("./backParsedTapidorContigs.csv").each do |r|
r.split("\t")
end
finish = (Time.now - t)
if finish < min
min = finish
end
@philippbayer
philippbayer / mass.cpp
Created April 10, 2012 10:04
All languages.
-------------------------------------------------------
C++:
#include <iostream>
#include <string>
#include <fstream>
#include <boost/tokenizer.hpp>
#include <vector>
#include <iterator>
#include <sys/time.h>
@philippbayer
philippbayer / dictin.py
Created April 17, 2012 02:19
Dictionary with in
return_dict = {}
for line in file_handle:
line_list = line.split()
if line_list[0] in return_dict.keys():
return_dict[line_list[0]].append(line_list)
else:
return_dict[line_list[0]] = [line_list]
@philippbayer
philippbayer / defaultdict.py
Created April 17, 2012 23:53
Python dictionary with defaultdict
from collections import defaultdict
d = defaultdict(list)
for line in file_handle:
line_list = line.split
d[line_list[0]].append(line_list)
@philippbayer
philippbayer / plot_gene_covs.R
Last active November 11, 2015 09:01
This R script creates a nice faceted plot of read coverage of reads based on bedtools genomecov -d output, to which one column with gene names was added
# Fileformat is
# Gene Chr Pos Cov
# gene_A A01 40 0
# gene_A A01 41 2
# ...
# gene_D A01 508 41
# gene_D A01 509 42
# ...
geneCov <- read.table("./test_genes.txt", sep="\t", header=F)
@philippbayer
philippbayer / index.html
Last active December 8, 2015 04:08
Simple D3 gene expression example
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.node {
stroke: #fff;
stroke-width: 1.5px;
}
.link {
@philippbayer
philippbayer / index.html
Created December 8, 2015 04:16
Another test
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.node {
stroke: #fff;
stroke-width: 1.5px;
}
.link {