Skip to content

Instantly share code, notes, and snippets.

View peterk87's full-sized avatar

Peter Kruczkiewicz peterk87

  • Canadian Food Inspection Agency
  • Canada
View GitHub Profile
@peterk87
peterk87 / hierarchical_clustering_num_clusters_vs_distances_plots.py
Created May 2, 2013 23:35
Python: Hierarchical clustering plot and number of clusters over distances plot
from scipy.spatial.distance import *
from scipy.cluster.hierarchy import *
import pandas as pd
import numpy
import matplotlib as plt
from matplotlib.pylab import figure
import pylab as pl
import pp
def num_clusters(hc, d):
@peterk87
peterk87 / heatmap.py
Created May 2, 2013 21:41
Python: hierarchically clustered heatmap using Matplotlib
## {{{ http://code.activestate.com/recipes/578175/ (r1)
### hierarchical_clustering.py
#Copyright 2005-2012 J. David Gladstone Institutes, San Francisco California
#Author Nathan Salomonis - [email protected]
#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files (the "Software"), to deal
#in the Software without restriction, including without limitation the rights
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#copies of the Software, and to permit persons to whom the Software is furnished
@peterk87
peterk87 / chunk_seq.py
Created May 1, 2013 19:02
Python: Chunk up a nucleotide or amino acid sequence and return a list of tuples containing the chunk sequence name and the chunk sequence.
def chunk_seq(seq_name, sequence, chunk_size, chunk_increment):
"""
Chunk up a sequence and return a list of tuples with the chunked up
sequences and new sequence names with the position of the chunk in the
original sequence.
Args:
seq_name: Sequence name.
sequence: Nucleotide or amino acid sequence that is to be chunked up.
chunk_size: Size of chunks (e.g. 30 bp)
@peterk87
peterk87 / coursera_dark.css
Created May 1, 2013 03:32
CSS: Coursera dark CSS style
/*coursera dark CSS style*/
/*URL on domain: coursera.org*/
a {
color: rgb(140, 178, 228) !important;
}
body,.row-fluid .span9,.row-fluid .span3,.row-fluid, div, li, ul, ol, .course-navbar-list .course-navbar-item.active a {
background-color: rgb(31, 31, 31) !important;
color: rgb(170,170,170) !important;
}
@peterk87
peterk87 / feedly_dark.css
Created April 29, 2013 23:58
CSS: feedly.com dark theme
/*feedly.com dark CSS theme*/
.placeholder{
visibility: hidden !important;
}
.area,.summary, div, .light {
background-color: rgb(30,30,30) !important;
color: rgb(200,200,200) !important;
}
a {
color: #78B7F5 !important;
@peterk87
peterk87 / navbar.html
Created April 29, 2013 16:32
HTML: R Shiny app navigation bar
<style type="text/css">body { padding-top: 25px;}</style>
<div class="navbar navbar-fixed-top navbar-inverse" id="tool" data-nav-value="dataview">
<div class="navbar-inner">
<div class="container-fluid">
<a class="brand" href="#" data-value="dataview">Navigation bar title for whatever app!</a>
<div class="nav-collapse">
<ul class="nav">
<li><a href="#" data-value="dataview">View</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">EDAT<b class="caret"></b></a>
@peterk87
peterk87 / stack_trace.R
Created April 26, 2013 20:42
R: track down errors that come primarily from non-interactive R sessions; prints a stack trace and continues on
# Printing stack trace and continuing after error occurs in R
# http://stackoverflow.com/questions/1975110/printing-stack-trace-and-continuing-after-error-occurs-in-r
# Bob Albright
# I wrote this code about a week ago to help me track down errors that come primarily from non-interactive R sessions. It's still a little rough, but it prints a stack trace and continues on. Let me know if this is useful, I'd be interested in how you would make this more informative. I'm also open into cleaner ways to get this information.
options(warn = 2, keep.source = TRUE, error =
quote({
cat("Environment:\n", file=stderr());
# TODO: setup option for dumping to a file (?)
@peterk87
peterk87 / Bibliography.bib
Created April 26, 2013 17:39
bibtex: Massive bibliography used in MSc thesis
@article{olson_limited_2007,
title = {Limited genetic diversity in \emph{{Salmonella enterica}} Serovar {Enteritidis} {PT13}},
volume = {7},
copyright = {2007 Olson et al; licensee {BioMed} Central Ltd.},
issn = {1471-2180},
url = {http://www.biomedcentral.com/1471-2180/7/87/abstract},
doi = {10.1186/1471-2180-7-87},
abstract = {Salmonella enterica serovar Enteritidis has emerged as a significant foodborne pathogen throughout the world and is commonly characterized by phage typing. In Canada phage types ({PT)} 4, 8 and 13 predominate and in 2005 a large foodborne {PT13} outbreak occurred in the province of Ontario. The ability to link strains during this outbreak was difficult due to the apparent clonality of {PT13} isolates in Canada, as there was a single dominant pulsed-field gel electrophoresis ({PFGE)} profile amongst epidemiologically linked human and food isolates as well as concurrent sporadic strains. The aim of this study was to perform comparative genomic hybridization ({CGH)}, {DNA} sequen
@peterk87
peterk87 / mist_2013.bib
Created April 26, 2013 17:37
bibtex: MIST reference
@article{kruczkiewicz_mist,
title = {{MIST}: a tool for rapid \emph{in silico} generation of molecular data from bacterial genome sequences},
author = {Kruczkiewicz, Peter and Mutschall, Steven and Barker, Dillon and Thomas, James and Van Domselaar, Gary and Gannon, Victor P.J. and Carrillo, Catherine D. and Taboada, Eduardo N.},
year = {2013},
location = {Barcelona, Spain},
pages = {316--323},
isbn = {978-989-8565-35-8},
publisher = {SCITEPRESS},
journal = {Proceedings of Bioinformatics 2013: 4th International Conference on Bioinformatics Models, Methods and Algorithms}
}
@peterk87
peterk87 / ncix.css
Created April 26, 2013 04:42
CSS: NCIX.com dark theme
/*dark theme CSS for NCIX.com*/
div, table, b, td, tr, form, h1, h2, h3, h4, h5, input, select, span {
background: none !important;
}
div, table, b, td, tr, form, h1, h2, h3, h4, h5, textarea, input, select, span {
color: rgb(170,170,170) !important;
background-color: rgb(30,30,30) !important;
}