Skip to content

Instantly share code, notes, and snippets.

View daler's full-sized avatar

Ryan Dale daler

  • National Institutes of Health (NIH), National Institute of Child Health and Human Development (NICHD)
  • Bethesda, MD
View GitHub Profile
#!/usr/bin/python
usage = """
Ensures start/stop coords in a BED file are integers
and not in exponential notation (like 9.3e+07)
Usage:
python fix_coords.py input.bed > fixed.bed
"""
import sys
@daler
daler / pick_event_bug.py
Created October 23, 2010 18:36
Example script to show a bug in pick_event
"""
Clicking the indicated point on the left-hand side causes the indicated point on the top right to
be highlighted. Adding 0.1 to the x-value of the left-hand side one seems to alleviate this
problem -- but not adding 0.01.
"""
import numpy as np
import matplotlib.pyplot as plt
x = np.array([-0.58178965,
"""
PWMSearch
Searches through a fasta sequence for the relevant Position Weight Matrices
from the Jaspar Database.
"""
from __future__ import division
from optparse import OptionParser
@daler
daler / classify_reads.py
Created May 26, 2011 14:36
classify reads using HTSeq
#!/usr/bin/python
# GPLv3 license
# Copyright 2011 Ryan Dale, all rights reserved
# dalerr@niddk.nih.gov
import HTSeq
import argparse
import sys
import time
@daler
daler / dnaa.sh
Created July 8, 2011 22:34 — forked from brentp/dnaa.sh
sudo apt-get install libtool
git clone git://dnaa.git.sourceforge.net/gitroot/dnaa/dnaa dnaa-git
cd dnaa-git
# bfast required. see above gist
cp -r ../bfast-git ./bfast
# samtools require. see above gist.
cp -r ../samtools-svn/ ./samtools
sh autogen.sh && ./configure && make && sudo make install
@daler
daler / revigo_download.py
Created April 27, 2013 15:42
Run REVIGO on some example data, download R scripts, and run them.
#!/usr/bin/python
"""
- Submit example data to REVIGO server (http://revigo.irb.hr/)
- Download and run R script for creating the treemap
- Download and run R script for creating the scatterplot
Creates files:
treemap.R, treemap.Rout, revigo_treemap.pdf
scatter.R, scatter.Rout, revigo_scatter.pdf
@daler
daler / dictprofile.py
Created May 15, 2013 23:11
profiling different flavors of dictionary implementations
import sys
from gffutils.helpers import DefaultOrderedDict
from collections import defaultdict
from collections import OrderedDict
import random
kind = sys.argv[1]
nlines = 200000
nkeys = 5
@daler
daler / merger.py
Created October 1, 2013 00:01
Implement the merging algorithm from Zhang et al (2013) Mol Cell 51(6): 792-806
import numpy as np
import logging
logging.basicConfig(format='%(message)s', level=logging.DEBUG)
class Merger(object):
def __init__(self, bin_size=5, diff_thresh=0.3,
start_thresh=5., extend_thresh=3.):
"""
Implements the merging alrogithm described in [1] for a NumPy array.
@daler
daler / metaseq_demo.py
Last active July 3, 2017 11:24
metaseq demo
# From http://www.biostars.org/p/83800/:
# "What I want to do is to plot reads of my histone marks (in bam file)
# around TSS with CpG and TSS without CpG (Essentially a coverage profile)."
#
#
# To install metaseq and dependencies, see:
#
#
# https://pythonhosted.org/metaseq/install.html
@daler
daler / gencode-db.py
Created January 4, 2014 18:54
creation of gffutils database from Gencode v19 annotations
import gffutils
import datetime
# Annotations from:
# ftp://ftp.sanger.ac.uk/pub/gencode/Gencode_human/release_19/gencode.v19.annotation.gtf.gz
v19gff = 'gencode.v19.annotation.gtf'
v19db_filename = v19gff + '.db'
gene_transcript = set(('gene', 'transcript'))