Skip to content

Instantly share code, notes, and snippets.

View slowkow's full-sized avatar
🐄
moooooo

Kamil Slowikowski slowkow

🐄
moooooo
View GitHub Profile
@danielecook
danielecook / orthologs.sh
Last active August 29, 2015 13:58
Generates the pairwise mapping between human <==> c. elegans genes #bash
wget 'ftp://ftp.ncbi.nih.gov/pub/HomoloGene/current/homologene.data'
egrep "\t9606\t" homologene.data | sort | cut -f 1,3,4 > human.txt
egrep "\t6239\t" homologene.data | sort | cut -f 1,3,4 > celegans.txt
join -1 1 -2 1 -t $'\t' human.txt celegans.txt | cut -f 2,3,4,5 | sort | echo -e "Human_Entrez\tHuman_Symbol\tElegans_Entrez\tElegans_Symbol\n$(cat -)" > orthologs.txt
rm human.txt celegans.txt homologene.data
@msund
msund / First draft
Last active August 29, 2015 14:01
R Notebook
{
"metadata": {
"name": "",
"signature": "sha256:4abc3bda22c03a05e4c028a06c0fdb0efbd5a6220ac512d85f9529fe8f08d9b7"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
tell application "System Events"
-- get current clipboard contents as a string
set CurrentClipboard to the clipboard as string
-- set the clipboad to your password
set the clipboard to "Y0urVPNPa$$w0rd"
-- start playing with the VPN
tell current location of network preferences
@drewconway
drewconway / get.stack.R
Created December 9, 2010 22:21
Returns the number of tags for a given token on StackOverflow.com
# Get StackOverflow data
get.stack<-function(tok) {
# Must check for XML install, thanks onertipaday!
if (!require(XML)) install.packages('XML')
library(XML)
# Enter a SO tag as character string, and number of tags are returned
tok<-gsub("(/| )","-",tok)
tok<-gsub("#","%23",tok,fixed=TRUE)
base.stack<-"http://stackoverflow.com/questions/tagged/"
stack.tree<-htmlTreeParse(paste(base.stack,tok,sep=""),useInternalNodes=TRUE)
@lindenb
lindenb / Makefile
Last active April 13, 2016 18:58
generating a simple NGS workflow with JSON, apache velocity and jsvelocity https://github.com/lindenb/jsvelocity
REF=/path/to/ref.fasta
.PHONY:all
all: align/variants.vcf
align/variants.vcf: align/Sample1_sorted.bam align/Sample2_sorted.bam align/Sample3_sorted.bam
/path/to/samtools mpileup -uf ${REF} $^ |\
/path/to/bcftools view -vcg - >$@
#AUROC calculation code
auroc<-function(score,cls){
n1<-sum(!cls); sum(cls)->n2;
U<-sum(rank(score)[!cls])-n1*(n1+1)/2;
return(1-U/n1/n2);
}
#... as a cryptic one-liner
auroc1l<-function(score,cls)
mean(rank(score)[cls]-1:sum(cls))/sum(!cls)
@1wheel
1wheel / README.md
Last active April 26, 2018 15:10
conventions-layers

d3-jetpack's d3.conventions can now create canvas and html elements. Here d3.conventions({layers: 'csd'}) makes an canvas ctx, svg and div with a shared coordinate system. Yellow shapes are drawn on canvas, cyan on svg and purple on html.

Layers are position absolutely on top of each other in the order listed in the layer string. To create an svg with two canvas elements on top:

var {layers: [svg, bg_ctx, fg_ctx]} = d3.conventions({layers: 'scc'})

Hurricane How-To describes using multiple renders for something more practical than bouncing circles.

@johan
johan / README.md
Created October 28, 2011 09:06
User script to view SVG files both as image and text at gist.github.com

Click "raw" below to install. Requires Google Chrome, Firefox + Greasemonkey, or some other browser supporting user scripts / content scripts / user javascript.

@msund
msund / Plots!
Last active October 10, 2019 23:10
Data Science Demo
{
"metadata": {
"name": "Reproducible figures"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@hypercompetent
hypercompetent / pearson_residuals.R
Last active January 7, 2021 16:53
Pearson residuals function in R, from Lause, Berens, and Kobak
pearson_residuals <- function(counts, theta = 100) {
counts_sum0 <- as(matrix(Matrix::colSums(counts),nrow=1),"dgCMatrix")
counts_sum1 <- as(matrix(Matrix::rowSums(counts),ncol=1),"dgCMatrix")
counts_sum <- sum(counts@x)
#get residuals
mu <- (counts_sum1 %*% counts_sum0) / counts_sum
z <- (counts - mu) / sqrt(mu + mu^2/theta)
#clip to sqrt(n)