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
require(XML) | |
require(RCurl) | |
require(stringr) | |
require(rentrez) | |
require(rjson) | |
require(reshape2) | |
require(ggmap) | |
require(mapproj) | |
require(devtools) |
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
#' R implementation of `cond` from Lisp | |
#' allows for arbitrary numbers of conditionals without ugly nested if statements | |
#' conditionals are entered as pairs of expressions (clauses), | |
#' first the expression to be evaluated and second the return value if the expression is true | |
#' @param ... an even number of expressions as pairs (see example) | |
#' @param true the `else` expression (Taken from the Lisp (T resultN) see http://www.cis.upenn.edu/~matuszek/LispText/lisp-cond.html) | |
#' @return The paired value of the first true conditional expression or the value of true | |
#' @examples | |
#' x <- runif(1) | |
#' cond(x < 0.2, "lower tail", |
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
# R code to produce a simulated dataset for an experiment on a made up insect. | |
# Measures include sex, body length, thorax width, number of thoracic bristles and some measure of aggression behaviour. | |
# Also there is exposure to some treatment stimulus/drug. | |
# This simulation uses Copulas to generate correlated variables from binomial, Gaussian and Poisson distributions | |
require(copula) | |
set.seed(1888) | |
n <- 1000 |
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
require(devtools) | |
load_all(".") | |
site <- "/home/me/mysite" | |
skeleton(site) | |
setup_example_site(site) | |
## buggy - Have to run twice to get the tags to work... | |
samatha(site, rss = FALSE, initial = TRUE) | |
samatha(site, rss = FALSE, initial = TRUE) |
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
fast_rbind <- function(to_bind, cores = 12, splits = 10){ | |
# to_bind : list of dataframes to bind | |
require(multicore) | |
myseq <- c(seq(from = 1,to = length(dat2), | |
by = floor(length(dat2) / max(cores, splits))), | |
length(dat2)) | |
intermediates <- mclapply(1:length(myseq), | |
function(x) { | |
if(x != length(myseq)){ | |
do.call(`rbind`, dat2[myseq[x]:(myseq[x+1] -1)]) |
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
#!/usr/bin/Rscript | |
# Extracts a variety of organism, environmental, sequencing and project metadata | |
# From saved GOLDstamp files (genomesonline.org) | |
# and saves as a flatfile with 1 taxa per line | |
# See gist.github.com/2929217 to scrape the files from a treebase taxa list | |
require(XML) | |
url <- "http://www.treebase.org/treebase-web/search/study/taxa.html?id=10965" |
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
#!/usr/bin/python2 | |
# Quick and dirty web scraper for extracting html files of | |
# Organism information, Genome Project Information, | |
# Sequencing Information, Environmental Metadata | |
# and organism metadata | |
# from GOLD databases based on treebase taxa lists, via ncbi | |
# Saves pages in the current directory | |
from urllib2 import urlopen |