Skip to content

Instantly share code, notes, and snippets.

Erik Clarke eclarke

  • Janssen Research & Development
  • Philadelphia, PA
Block or report user

Report or block eclarke

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
eclarke /
Created Oct 22, 2014
Example file

Erik’s Lab Notebook

<2014-09-25 Thu>

Reading this [@Wang:2010fh], in particular Supp. report 4. Has to do with bootstrapping population estimates using the different enzymes used to find

eclarke / papers2bibtex.scpt
Last active Aug 29, 2015
Applescript to export Papers library as bibtex file
View papers2bibtex.scpt
tell application "Papers"
set outFile to "path_to_notebook_folder/library.bib"
export ((every publication item) as list) to outFile
end tell
eclarke / lab-notebook.el
Created Oct 21, 2014
Minor mode and functions for a lab notebook in emacs
View lab-notebook.el
(defun ensure-in-vc-or-checkin ()
(if (file-exists-p (format "%s" (buffer-file-name)))
(progn (vc-next-action nil) (message "Committed"))
(ding) (message "File not checked in.")))
(defun export-bibtex ()
"Exports Papers library using a custom applescript."
(message "Exporting papers library...")
eclarke / ggheatmap.R
Last active Oct 29, 2019
heatmaps ggplot style, with annotations and dendrograms
View ggheatmap.R
plot_ggheatmap <- function(obj, n=nrow(obj), norm=TRUE, log=TRUE,"NewSampleID",
col.annotation.width=4) {
View multiplot
# Multiple plot function
# ggplot objects can be passed in ..., or to plotlist (as a list of ggplot objects)
# - cols: Number of columns in layout
# - layout: A matrix specifying the layout. If present, 'cols' is ignored.
# If the layout is something like matrix(c(1,2,3,3), nrow=2, byrow=TRUE),
# then plot 1 will go in the upper left, 2 will go in the upper right, and
# 3 will go all the way across the bottom.
eclarke / ggheatmaps.R
Created Apr 8, 2014
Some r code relating to heatmaps and OTU counts
View ggheatmaps.R
prop_presence_absence <- function(, groups) {
# Creates a proportional presence-absence melted dataframe suitable for use in
# ggplot heatmaps to show varying within-group proportions of species.
# Args:
# Matrix of presence-absence data. Columns are samples, rows are
# species.
# groups: Grouping data frame. A column named "SampleID" should be unique
# list of sample identifiers that match the column names of
# The other column, named "group", should correspond to the group
eclarke /
Last active Aug 29, 2015
A hackety hack function to toggle SSH/SOCKS proxy on OS X Mavericks
function toggleproxy {
# checks to see if SOCKS proxy is enabled
if [[ $(networksetup -getsocksfirewallproxy Wi-Fi | grep '^Enabled') == "Enabled: No" ]]; then
networksetup -setsocksfirewallproxystate Wi-Fi on
echo "SOCKS on!"
# checks to see if there's an existing SSH tunnel and if not, it starts one
if [[ -z $(ps aux | grep '[0-9] ssh -D 8080') ]]; then
echo -ne "Don't see a ssh tunnel on 8080 active, starting one now..."
ssh -D 8080 -f -C -q -N USERNAME@HOSTNAME.EDU # Change this from the defaults!
[[ $? == 0 ]] && echo " success!" || echo " failed :("
#!/usr/bin/env python
"""Usage: python [FILE]
Converts an ITS taxonomy file to eliminate taxa marked as unidentified,
swaps [kpcofg]__unidentified;s__Fungi to k__Fungi, and eliminates species
taxa that are simply s__[genus]_sp.
Writes to stdout.
# Erik Clarke <>
eclarke /
Created Jun 15, 2012
Spawning processes in Python
import sqlite3
import multiprocessing
store_results_sql = """ some sql code here """
select_results_sql = """ some other sql code here """
def find_enriched(**kwargs):
# do some heavy computation task here
results = enrichment_analysis(**kwargs)
# sqlite is not ideal for parallel processing, but with a timeout it should be fine
eclarke /
Created May 2, 2012
filter obsolete go terms
#!/usr/bin/env python
import re
import json
import clint
def import_go(gofile='go.json'):
return json.loads(json.load(open(gofile)))
except IOError:
You can’t perform that action at this time.