R and Google Visualization API

Author  Scott Chamberlain

R interfaces with the powerful Google Visualization API with the package googleVis (see here). It's relatively easy to convert your graphics in R to interactive graphics to post on a web browser. And the graphics are quite nice, as seen below in a simple graph of some of my data collected from this summer on seed predation to Helianthus annuus seeds in Texas:



Data: data2, Chart ID: MotionChart_2011-01-08-19-31-57


R version 2.12.1 (2010-12-16),

Google Terms of Use






<%@include file="../src/simpleFooter.rsp"%>

Posted in  Ecology GoogleVis R

Author  Scott Chamberlain

Ecological networks from abundance distributions

Author  Scott Chamberlain

Another grad student and I tried recently to make a contribution to our understanding of the relationship between ecological network structure (e.g., nestedness) and community structure (e.g., evenness)...

...Alas, I had no luck making new insights. However, I am providing the code used for this failed attempt in hopes that someone may find it useful. This is very basic code. It was roughly based off of the paper by Bluthgen et al. 2008 Ecology (here). In my code the number of interactions is set to 600, and there are 30 plant species, and 10 animal species. This assumes they share the same abundance distributions and sigma values.

UPDATE: I changed the below code a bit to just output the metrics links per species, interaction evenness and H2.

#######################################################
library(bipartite)
 
# Set of mean and sd combinations of log-normal distribution
# In my case, these values were those empirically estimated
# from many bipartite networks from the Interaction Web Database
mu <- c(0.5,2.9,5.3)
sig <- c(0.75,1.6,2.45)
 
# Function to make a set of matrices based on some combination of mu and sigma values
make.matrices <- function(a,b,nmats){
plants <- round(rlnorm(n=30, meanlog=mu[a], sdlog=sig[b]))
animals <- round(rlnorm(n=10, meanlog=mu[a], sdlog=sig[b]))
plants <- plants(600/sum(plants))
animals <- animals
(600/sum(animals))
r2dtable(nmats,animals,plants)
}
 
# Output matrices
matrices11 <- make.matrices(1,1,100)
 
# Etc. for the remaining combinations of mu and sigma
#matrices12 <- make.matrices(1,2,100)
#matrices13 <- make.matrices(1,3,100)
#matrices21 <- make.matrices(2,1,100)
# etc.....
 
# Calculate some network metrics-e.g., for one combination of mu and sigma
linkspersp11 <- numeric(100)
inteven11 <- numeric(100)
h211 <- numeric(100)
 
for(i in 1:length(matrices11)){
m <- matrix(unlist(matrices11[i]),ncol=30,byrow=F)
metrics <- t(networklevel(m,index=c("links per species","H2","interaction evenness")))
linkspersp11[i] <- metrics[1]
inteven11[i] <- metrics[2]
h211[i] <- metrics[3]
}
 
linkspersp11
h211
inteven11
Created by Pretty R at inside-R.org

Posted in  Ecology Networks R

Author  Scott Chamberlain

R-bloggers

Author  Scott Chamberlain

Just a quick FYI note in case you haven't seen this site.

R-bloggers is an awesome site, bringing together more than 140 blogs (including mine) about R in a single location. See Tal Galili's motivation for creating the site, and his notes on the site here.

Posted in  R

Author  Scott Chamberlain

New approach to analysis of phylogenetic community structure

Author  Scott Chamberlain

Anthony Ives, of University of Wisconsin-Madison, and Matthew Helmus of the Xishuangbanna Tropical Botanical Garden, present a new statistical method for analyzing phylogenetic community structure in an early view paper in Ecological Monographs. See the abstract here.

Up to now, most phylogenetic community structure papers have calculated metrics and used randomization tests to determine if observed metrics are different from random. The approach of Ives and Helmus fits models to observed data, instead of calculating single metrics.

Furthermore, their approach gets around the limitation in studies of phylogenetic community structure of conducting many separate statistical tests, thereby inflating your chances of finding a significant effect purely by chance.

Their approach uses generalized linear mixed models (GLMMs). They provide Matlab code for running these models, but R code will be available in the Picante package in the future.

Posted in  Evolution Papers Ecology Phylogenetics Picante R

Author  Scott Chamberlain

Ngram ecological terms

Author  Scott Chamberlain

The recent availability of google ngram data is a great source of data on language use. Here are some terms from ecology from 1890 to 2000 (from here: http://ngrams.googlelabs.com/). Note that the word "ecology" doesn't appear at all until about 1890.

Notice the close alignment of "ecology" and "ecosystem", while "predation" and "facilitation" put in somewhat equal showings. "Parasitism" is almost constant through time, while "mutualism" falls way below predation and facilitation and parasitism. 


Google Ngram plot of six ecological terms + environmentalism for giggles

Posted in 

Author  Scott Chamberlain

Fork me on GitHub