Skip to content

Instantly share code, notes, and snippets.

View ngehlenborg's full-sized avatar
🧪
🍋➡️🥤

Nils Gehlenborg ngehlenborg

🧪
🍋➡️🥤
View GitHub Profile
@ngehlenborg
ngehlenborg / gist:9107086
Created February 20, 2014 04:26
Set Indexing Experiments
// experiments
// Author: Nils Gehlenborg (@ngehlenborg)
var nextBitPermutation = function( current ) {
// from: http://www-graphics.stanford.edu/~seander/bithacks.html#NextBitPermutation
var v = current;
var t = (v | (v - 1)) + 1;
var w = t | ((((t & -t) / (v & -v)) >> 1) - 1);
return ( w>>>0 );
};
@ngehlenborg
ngehlenborg / hex-to-rgba.js
Last active August 29, 2015 13:57
Hex color string to RGB values to create RGBA color
var hexToRgba = function( hexString, alpha ) {
alpha = alpha || 1;
var hexColor = parseInt( hexString.substring(1), 16 );
return ( 'rgba(' + ( ( hexColor << 8 ) >>> 24 ) + ',' + ( ( hexColor << 16 ) >>> 24 ) + ',' + ( ( hexColor << 24 ) >>> 24 ) + ',' + alpha + ')' );
}
@ngehlenborg
ngehlenborg / yappi-profiling.py
Created August 19, 2015 01:05
Yappi profiling in current thread using wall clock time.
import yappi
yappi.set_clock_type("wall")
yappi.start(builtins=False,profile_threads=False)
# code to profile goes here
yappi.get_thread_stats().print_all()
yappi.stop()
yappi.clear_stats()
import string
input_file = open('massachusetts_municipalities.txt', 'r')
list_entries = {}
for line in input_file:
if line[0] not in list_entries:
list_entries[line[0]] = []
list_entries[line[0]].append(line.strip())
output_file = open('interleaved_list.txt', 'w')
import re
import sys
import csv
import json
import urllib2
from datetime import datetime
from collections import defaultdict as dd
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Matrix visualization</title>
<link href="../caleydo/bundle.css" type="text/css" rel="stylesheet">
<style type="text/css">
.select-selected {
fill: orange;
@ngehlenborg
ngehlenborg / fiddle.css
Last active February 23, 2016 03:57 — forked from flekschas/data.js
Caleydo Web Tutorial - AngularJS heatmap integration
@import url(https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700);
$colorBlindBlue: #50b4e9;
$colorBlindYellow: #f0e442;
$colorDirectHoverBg: #ccc;
$colorIndirectHoverBg: #e5e5e5;
$colorSelectedBg: $colorBlindYellow;
#app {
require(RISmed);
require(ggplot2);
makeJournalQuery <- function( journals ) {
query <- paste( "(" , paste( "\"", journals, "\"[Journal]", sep="", collapse=" OR " ), ")", sep="" );
return ( query );
}
queryPapers <- function( year, query, journals ) {

HiC data

Smaller test set

Real data set

FILENAME=rao_et_al/HMEC/5kb_resolution_intrachromosomal/chr1/MAPQGE30/chr1_5kb.RAWobserved
FILENAME=rao_et_al/HMEC/5kb_resolution_intrachromosomal/chr1/MAPQGE30/chr1_5kb.RAWobserved
FILENAME=rao_et_al/HUVEC/5kb_resolution_intrachromosomal/chr1/MAPQGE30/chr1_5kb.RAWobserved
@ngehlenborg
ngehlenborg / fy2016-nih-funding.csv
Last active March 16, 2017 12:51
Possible impact of proposed NIH budget on states.
State Awards Funding Winner Population Non_Hispanic_White Hispanic_or_Latino Black American_Indian_or_Alaskan_Native Asian Native_Hawaiian_or_Pacific_Islander Mixed_race
Alabama 654 294964217 Trump 4822023 67 3.9 26.2 0.6 1.1 0.1 1.5
Alaska 17 14594777 Trump 731449 64.1 5.5 3.3 14.8 5.4 1 7.3
Arizona 382 163447535 Trump 6553255 57.8 29.6 4.1 4.6 2.8 0.2 3.4
Arkansas 108 96652655 Trump 2949131 74.5 6.4 15.4 0.8 1.2 0.2 2
California 7720 3686026589 Clinton 38041430 40.1 37.6 6.2 1 13 0.4 4.9
Colorado 991 349974172 Clinton 5187582 70 20.7 4 1.1 2.8 0.1 3.4
Connecticut 1179 510609681 Clinton 3590347 71.2 13.4 10.1 0.3 3.8 0 2.6
Delaware 75 45371848 Clinton 917092 65.3 8.2 21.4 0.5 3.2 0 2.7
District Of Columbia 361 214175791 Clinton 632323 34.8 9.1 50.7 0.3 3.5 0.1 2.9