Ecology unconference at ESA 2013

So I heard many people say after or during the recent ESA conference in Portland that they really enjoyed the converstations more than listening to talks or looking at posters. There was some chatter about doing an unconference associated with next year’s ESA conference in Minneapolis. And Sandra Chung (@sandramchung) got on it and started a wiki that we can all conribute ideas to. The wiki is here What is an unconference? The idea of an unconference is to have a community organized meetup in which interactions among people are emphasized over the traditional lecture and poster format. For example, many sessions may just be organized a single idea, and people attending have a discussion around the topic. The format can be decided by the community. ...

August 30, 2012 · 2 min · Scott Chamberlain

Making matrices with zeros and ones

So I was trying to figure out a fast way to make matrices with randomly allocated 0 or 1 in each cell of the matrix. I reached out on Twitter, and got many responses (thanks tweeps!). Here is the solution I came up with. See if you can tell why it would be slow. {% highlight r linenos %} mm <- matrix(0, 10, 5) apply(mm, c(1, 2), function(x) sample(c(0, 1), 1)) {% endhighlight %} ...

August 30, 2012 · 4 min · Scott Chamberlain

ggplot2 maps with insets

UPDATE: changed data source so that the entire example can be run by anyone on their own machine. Also, per Joachim’s suggestion, I put a box around the blown up area of the map. In addition, rgeos and maptools removed, not needed. Here’s a quick demo of creating a map with an inset within it using ggplot. The inset is achieved using the gridExtra package. Install libraries install.packages(c("ggplot2", "maps", "grid", "gridExtra")) library("ggplot2") library("maps") library("grid") library("gridExtra") Create a data frame dat <- data.frame(ecosystem = rep(c("oak", "steppe", "prairie"), each = 8), lat = rnorm(24, mean = 51, sd = 1), lon = rnorm(24, mean = -113, sd = 5)) head(dat) #> ecosystem lat lon #> 1 oak 49.58285 -107.6930 #> 2 oak 52.58942 -116.6920 #> 3 oak 50.49277 -114.5542 #> 4 oak 50.05943 -116.5660 #> 5 oak 51.76492 -112.1457 #> 6 oak 52.82153 -112.8858 Get maps using the maps library Get a map of Canada ...

August 22, 2012 · 3 min · Scott Chamberlain

Hitting the Global Names Resolver API

Example of using the Global Names Resolver API to check species names There are a number of options for resolution of taxonomic names. The Taxonomic Name Resolution Service (TNRS) comes to mind. There is a new service for taxonomic name resoultion called the Global Names Resolver. They describe the service thusly “Resolve lists of scientific names against known sources. This service parses incoming names, executes exact or fuzzy matching as required, and displays a confidence score for each match along with its identifier.”. ...

July 20, 2012 · 2 min · Scott Chamberlain

Recent R packages for ecology and evolution

Many R packages/tools have come out recently for doing ecology and evolution. All of the below were described in Methods in Ecology and Evolution, except for spider, which came out in Molecular Ecology Resources. Here are some highlights. mvabund paper - get R pkg Model-based analysis of multivariate abundance data. Visualising data, fitting predictive models, checking assumptions, hypothesis testing. popdemo paper - get R pkg Population demography using projection matrix analysis. motmot paper - get R pkg Models of trait macroevolution on trees spider paper - get R pkg Analysis of species identity and evolution, with particular reference to DNA barcoding BaSTA paper - get R pkg Bayesian estimation of age-specific survival from incomplete mark–recapture/recovery data with covariates abc paper - get R pkg Approximate Bayesian Computation (ABC) RNetLogo paper - get R pkg Running and exploring individual-based models implemented in NetLogo phytools paper - get R pkg Tools for phylogenetic comparative biology smatr paper - get R pkg Estimation and inference about allometric lines RBrownie paper - get R pkg ? Testing hypotheses about rates of evolutionary change polytomy resolver paper - get R pkg Resolve polytomies on dated phylogenies with their R scripts [here][]. And a cool tool came out for the Python programming language. ...

June 14, 2012 · 2 min · Scott Chamberlain

Visualize your Github stats (forks and watchers) in a browser with R!

So OpenCPU is pretty awesome. You can run R in a browser using URL calls with an alphanumeric code (e.g., x3e50ee0780) defining a stored function, and any arguments you pass to it. Go here to store a function. And you can output lots of different types of things: png, pdf, json, etc - see here. Here’s a function I created (originally from https://gist.github.com/2602432): # Store a function with man lines # Go Here: http://beta.opencpu.org/apps/opencpu.demo/storefunction/ # number: x3e50ee0780 # link: http://beta.opencpu.org/R/call/store:tmp/x3e50ee0780/png?id='ropensci'&type='org' the <- function (id = 'hadley', type = 'user') { require(RCurl); require(RJSONIO); require(ggplot2); require(reshape2); require(plyr) if(type == 'user'){ url = "https://api.github.com/users/" } else if(type == 'org'){ url = "https://api.github.com/orgs/" } else stop("parameter 'type' has to be either 'user' or 'org' ") url2 <- paste(url, id, "/repos?per_page=100", sep = "") xx <- getURL(url2) tt <- fromJSON(xx) if(!length(tt) == 1) { tt <- tt } else { stop("user or organization not found - search GitHub? - https://github.com/") } out <- ldply(tt, function(x) t(c(x$name, x$forks, x$watchers))) names(out) <- c("Repo", "Forks", "Watchers") out$Forks <- as.integer(out$Forks) out$Watchers <- as.integer(out$Watcher) out2 <- melt(out, id = 1) out2$value <- as.numeric(out2$value) out2$Repo <- as.factor(out2$Repo) repoorder <- unique(out2[order(out2$value, decreasing=FALSE),][,1]) out2$Repo <- factor(out2$Repo, levels = repoorder) ggplot(out2, aes(Repo, value)) + geom_bar() + coord_flip() + facet_wrap(~variable) + theme_bw(base_size = 18) } the() # default for hadley the(id='defunkt', type='user') # works - a user with even more repos than Hadley the(id='ropensci', type='org') # works - organization example the(id='jeroenooms', type='user') # works - organization example the(id='SChamberlain', type='org') # error message - mismatch of username with org type the(id='adsff', type='user') # error message - name does not exist It makes a ggplot2 graphic of your watchers and forks on each repo (up to 100 repos), sorted by descending number of forks/watchers. ...

May 5, 2012 · 2 min · Scott Chamberlain

mvabund - new R pkg for multivariate abundance data

There is a new R package in town, mvabund, which does, as they say “statistical methods for analysing multivariate abundance data”. The authors introduced the paper in an online early paper in Methods in Ecology and Evolution here, R package here. The package is meant to visualize data, fit predictive models, check model assumptions, and test hypotheses about community-environment associations. Here is a quick example (originally from https://gist.github.com/2112141) #### mvabund play # install mvabund from CRAN pkg repository install.packages("mvabund") require(mvabund) # plot abundance by copepod species data(Tasmania) attach(Tasmania) tasmvabund <- mvabund(Tasmania$copepods) plot(tasmvabund ~ treatment, col = as.numeric(block)) # fit negative binomial model for each species and plot residuals vs. fitted tas.nb <- manyglm(copepods ~ block*treatment, family="negative.binomial") plot(tas.nb) ...

March 19, 2012 · 1 min · Scott Chamberlain

Journal Articles Need Interactive Graphics

I should have thought of it earlier: In a day and age when we are increasingly reading scientific literature on computer screens, why is it that we limit our peer-reviewed data representation to static, unchanging graphs and plots? Why do we not try to create dynamic visualizations of our rich and varied data sets? Would we not derive benefits in the quality and clarity of scientific discourse from publishing these visualizations? ...

February 25, 2012 · 4 min · Pascal Mickelson

Take the INNGE survey on math and ecology

Many ecologists are R users, but we vary in our understanding of the math and statistical theory behind models we use. There is no clear consensus on what should be the basic mathematical training of ecologists. To learn what the community thinks, we invite you to fill out a short and anonymous questionnaire on this topic here. The questionnaire was designed by Frédéric Barraquand, a graduate student at Université Pierre et Marie Curie, in collaboration with the International Network of Next-Generation Ecologists (INNGE). ...

February 17, 2012 · 1 min · Scott Chamberlain

Scraping Flora of North America

So Flora of North America is an awesome collection of taxonomic information for plants across the continent. However, the information within is not easily machine readable. So, a little web scraping is called for. rfna is an R package to collect information from the Flora of North America. So far, you can: Get taxonomic names from web pages that index the names. Then get daughter URLs for those taxa, which then have their own 2nd order daughter URLs you can scrape, or scrape the 1st order daughter page. Query Asteraceae taxa for whether they have paleate or epaleate receptacles. This function is something I needed, but more functions will be made like this to get specific traits. Further functions will do search, etc. ...

January 27, 2012 · 2 min · Scott Chamberlain