Skip to content

Instantly share code, notes, and snippets.

View brwnj's full-sized avatar
👈

Joe Brown brwnj

👈
  • Invitae
  • Portland, OR
  • 16:21 (UTC -07:00)
View GitHub Profile
@brwnj
brwnj / norm_count_table.R
Last active December 17, 2015 03:28
Return a normalized counts table from DESeq by calling Rscript. Assumes DESeq library is installed and file is tab delimited.
# Usage:
# Rscript norm_count_table.R file_in.tab file_out.tab
# source("http://bioconductor.org/biocLite.R")
# biocLite("DESeq")
library(DESeq)
args <- commandArgs(TRUE)
filein <- args[1]
fileout <- args[2]
@brwnj
brwnj / zhead
Last active January 24, 2017 23:56
zhead
#!/usr/bin/env bash
n=$#
a=("${@}")
b=("${a[@]:0:$n-1}")
f=${a[$n-1]}
zcat $f | head ${b[*]}
@brwnj
brwnj / example.sh
Created March 6, 2013 19:40
command line usage example of bsub
#!/usr/bin/env bash
#BSUB -J example
JOBIDS=""
# example loop
for (( i = 0; i < 10; i++ )); do
RUNSCRIPT=example.sh
echo "#! /usr/bin/env bash" > $RUNSCRIPT
echo "#BSUB -J example_slave" >> $RUNSCRIPT
@brwnj
brwnj / align.sh
Created February 25, 2013 23:19
old gsnap/cuffdiff
#! /usr/bin/env bash
#BSUB -J align[1-12]
#BSUB -e gsnap.%J.%I.err
#BSUB -o gsnap.%J.%I.out
#BSUB -q normal
#BSUB -R "select[mem>16] rusage[mem=16] span[hosts=1]"
#BSUB -n 4
<<DOC
align rnaseq samples using gsnap against mm9
@brwnj
brwnj / mrna_counts.py
Created January 25, 2013 21:10
mRNA counts on reads which were aligned to mirbase
#! /usr/bin/env python
# encoding: utf-8
"""counts of mRNAs per sample where the reads have been aligned to mirbase."""
import sys
import pybedtools
import pandas as pd
import os.path as op
from collections import Counter
def main(args):
@brwnj
brwnj / weather.py
Created November 27, 2012 02:32
grab the current temp and the forecast for the next few days
#! /usr/bin/env python
# encoding: utf-8
import json
import urllib2
# weather underground api key
api_key = ''
u = urllib2.urlopen("http://api.wunderground.com/api/%s/geolookup/q/autoip.json" % api_key)
@brwnj
brwnj / mapping.txt
Created November 12, 2012 19:33
mapping stats
Hela_Pit1_T220A_0
# Read Sequences: 1937152
# Aligned: 535159
# Unique Alignment: 396716
# Gapped Alignment: 36685
# Quality Filter: 342465
# Homopolymer Filter: 285
Hela_Pit1_T220A_1
# Read Sequences: 3214272
@brwnj
brwnj / README.md
Created November 2, 2012 04:51
parallelizing miso

TODO

  • would be nice to be able to send kwargs to run_miso.py
  • doesn't account for your paired-end samples at the moment
@brwnj
brwnj / joinreads.py
Last active August 15, 2016 21:09
join paired-end or print unique single-end reads
#!/usr/bin/env python
# encoding: utf-8
"""
Join R1 and R2, or print unpaired reads of R1 or R2
This script assumes there is whitespace separating the readname from the pair number:
> <
@HW-ST997:140:D0UA5ACXX:8:1101:1497:2138 1:N:0:ATCACG
@HW-ST997:140:D0UA5ACXX:8:1101:1497:2138 2:N:0:ATCACG
@brwnj
brwnj / qvality.py
Created September 10, 2012 16:15 — forked from brentp/qvality.py
"""
qvality must be on the $PATH.
run on a file with pvalues in column 4:
$ python qvality.py --column 4 input.bed > output.bed
output file will have extra columns for PEP (posterior error prob)
and q-value.
if input.bed has a header, it is retained.