This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Parse gaggle apache server logs to compile usage stats | |
## ...with thanks to: https://github.com/lethain/apache-log-parser | |
## Track number of accesses by IP address, accesses to Java Web Starts (.jnlp files) | |
## and subversion access. | |
import sys | |
import re | |
import subprocess | |
import argparse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################################ | |
## A hacky script to extract features from a GFF3 file ## | |
## and output them in a format compatible with the ## | |
## Gaggle genome browser. ## | |
## ## | |
## J. Christopher Bare, March 2012 ## | |
## ## | |
############################################################ | |
# I got the gene annotations in GFF format from here: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Extract expression data | |
# ======================= | |
# | |
# Gene expression data comes from the cmonkey output RData file: | |
# ~/Documents/work/projects/network_portal/cm_session.RData | |
# | |
# ...in a variable: env$ratios$ratios, a 3491 by 739 matrix | |
conditions <- c('X130.1', 'X127.1', 'X435.8', 'X435.7', 'X435.6', 'X435.1', 'X435.2', 'X435.3', 'X435.4', 'X435.10', 'X435.9', 'X435.5', 'X435.11', 'X449.1', 'X450.1', 'X450.2', 'X450.3', 'X450.4', 'X450.5', 'X1271.1', 'X1271.2', 'X1271.3', 'X1271.4', 'X1271.5', 'X1271.7', 'X1271.9', 'X1271.10', 'X1709.2', 'X1709.3', 'X1709.4', 'X1709.5', 'X1709.6', 'X1709.7', 'X1709.8', 'X1709.9', 'X1709.10', 'X1709.12', 'X1709.13', 'X1709.14', 'X1709.15', 'X1713.1', 'X1713.2', 'X1713.3', 'X1713.4', 'X1713.5', 'X1736.5', 'X1736.10', 'X1736.17', 'X1736.19', 'X1736.21') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# read in files extracted from the database | |
hg <- read.table(file='halo.go.txt', header=F, sep="\t", stringsAsFactors=F) | |
hs <- read.table(file='halo.id.synonyms.txt', header=F, sep="\t", stringsAsFactor=F) | |
colnames(hs) <- c('name', 'synonym') | |
colnames(hg) <- c('name', 'go') | |
# join the two tables and translate gene names to their synonyms | |
hg2 <- merge(hg,hs,by="name",all.x=TRUE) | |
# na.omit(hg2)[1:20,] | |
hg2$name[!is.na(hg2$synonym)] <- hg2$synonym[!is.na(hg2$synonym)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
## Linear regression by gradient descent | |
## | |
## A learning exercise to help build intuition about gradient descent. | |
## J. Christopher Bare, 2012 | |
## | |
# generate random data in which y is a noisy function of x | |
x <- runif(1000, -5, 5) | |
y <- x + rnorm(1000) + 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns poker-kata.core) | |
;; Functions to evaluate (5 card) poker hands, based on the code kata | |
;; at http://codingdojo.org/cgi-bin/wiki.pl?KataPokerHands | |
;; A card is represented by a vector with a numeric rank and a suit. | |
;; example cards: | |
;; 5 of diamonds [5 :diamonds] | |
;; ace of spades [14 :spades] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## S4 classes for talented people | |
## | |
## Code to go along with a blog post about | |
## object oriented programming in R: | |
## | |
## http://digitheadslabnotebook.blogspot.com/2012/09/oo-in-r.html | |
## | |
################################################################ | |
# define an S4 class for people |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Poker.R | |
## Evaluate poker hands | |
## | |
## by: Christopher Bare | |
############################################################ | |
## define suits and ranks | |
suits <- c('c','d','h','s') | |
ranks <- c(2:10,"J","K","Q","A") | |
suit_names <- c(c="clubs", d="diamonds", h="hearts", s="spades") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# How the "missingness" status of arguments can be passed down | |
# the call stack. (Thanks Martin Morgan!) | |
bar <- function(q,...) { | |
cat(q) | |
foo(...) | |
} | |
foo <- function(a=123) { | |
if (missing(a)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Cbare's code from Machine Learning for Hackers | |
## Chapter 1 - cleaning up data on UFO sightings | |
## | |
## for data files and lot's more R code, see: | |
## https://github.com/johnmyleswhite/ML_for_Hackers | |
## | |
############################################################ | |
library(ggplot2) | |
library(scales) |
OlderNewer