Category Archives: Landscape Ecology

A great idea: R Markdown for Undergrads

A recently published paper by Baumer et al (2014) caught my eye today (HT to Bruce Caron).  I wanted to share it here because I thought it was cool and also had a few comments to make about some of the issues the authors raised.

First, a bit about the paper.  Partly in response to all the media attention to the crisis in reproducibility in science (e.g. Nature) Baumer and colleagues made some changes to introductory statistics classes at Duke, Smith, and Amherst.  The primary change was to require the use of R Markdown for all homework.  RStudio was the editor they used and it appears any cutting and pasting of code, figures, etc. was not allowed.  They conducted a survey of the students early in the class and after the class.  The end result was that students preferred using R Markdown over the typical mode of cut and paste.  They may have grumbled a bit about learning R Markdown but the benefits were obvious to them.

Getting these students using R Markdown and creating reproducible homework assignments is a fantastic thing, in my opinion.  I have worked with younger researchers (although not undegrads) and with older ones.  Convincing younger researchers of the benefits of R Markdown and the general concept of reproducibility is pretty easy.  To put it bluntly, the older researchers are a pain…  There are ALWAYS long conversations (er, arguments) about why their method is not any different than a reproducible one, why their method it is better, etc.  I suppose the “old dog, new tricks” is apropos.  The moral of the story is that teaching undergrads reproducibility and Open Science in general will have many long term benefits and what Baumer and colleagues have done should be more widely adopted.

Aside from my being a big fan of what they did, I have one response to an issue they raised in the paper.  On pages 16-17 the authors discuss the need to collaborate on R Markdown documents and suggest Dropbox as a possible solution. While that might work, I think a better option is to use Git and Github.  This is, I think a great opportunity to introduce version control early on to the students and it fits right inline with the open science and reproducibility theme of the authors efforts.

So in short, what Baumer and colleagues are doing is great. It would be FANTASTIC if they added Git/Github to the mix.

SPARROW + Lake Volume + Field Data = PLOS ONE Paper

So this one goes in the category of shameless self-promotion (or shameless promoting of my co-authors).  We have a new paper out in PLOS ONE about how we combined the USGS SPARROW model, modeled lake depth and volume, and field data from the National Lakes Assessment to improve predicitons of TN and TP.

There is no need for me to re-hash this here, you can check out my blog post on EPA’s It All Starts With Science Blog.

Ref:

Milstead WB, Hollister JW, Moore RB, Walker HA (2013) Estimating Summer Nutrient Concentrations in Northeastern Lakes from SPARROW Load Predictions and Modeled Lake Depth and Volume. PLoS ONE 8(11): e81457. doi:10.1371/journal.pone.0081457

Post-Doc Position: Landscape Scale Cyanobacteria Modelling

So, I normally try to keep work stuff and blog stuff separated, but I figured the four of you who read this might be or know of someone who might be interested in a one year (with possible extension) contract position with my research group at US EPA in Narragansett, RI. And besides, its my blog. I can do what I want.

Our group works on various aspects of Cyanobacteria including toxicology, epidemiology, economics, and ecology. The focus of the post-doc is to help build National scale models of the probability of cyanobacteria bloom events in lakes across the US. Candidates with backgrounds in limnology, aquatic ecology, landscape ecology, and statistics would all be very competitive. Experience with R, Python, Bayesian methods and/or machine learning a definite plus. More information is here.

Please be aware this position is a contract position so the announcement reads a bit different. Don’t let that dissuade you. We are a fun group!

An R function to download shapefiles

This post is a follow up from my latest Things I Forget post on reading in shapefiles.  That post assumed that you already had access to all the relevant files (e.g. .shp, .shx, .prj, .dbf, etc.).  A task that I routinely need to do is locate shapefiles on a website, grab those files, and read them in.  Instead of having to do this manually I wrote a function a while back to take care of this task.  The function simply requires shape_url, a link to the location of the files, and layer, the name of the shapefile. Currently the layer should not contain the .shp extension. There is also an optional parameter outfile that can be used to create a different name for the downloaded files.

I haven’t spent much time on error handling. For instance this function assumes you already have rgdal and sp installed and loaded. If you try to use this and get an error, let me know in the comments and I’ll try to fix it. Or better yet suggest a change and I’ll throw it in!

So here is the function.

download.shapefile<-function(shape_url,layer,outfile=layer)
{
  #written by: jw hollister
  #Oct 10, 2012

  #set-up/clean-up variables
  if(length(grep("/$",shape_url))==0)
  {
    shape_url<-paste(shape_url,"/",sep="")
  }
  #creates vector of all possible shapefile extensions
  shapefile_ext<-c(".shp",".shx",".dbf",".prj",".sbn",".sbx",
                   ".shp.xml",".fbn",".fbx",".ain",".aih",".ixs",
                   ".mxs",".atx",".cpg")

  #Check which shapefile files exist
  if(require(RCurl))
  {
    xurl<-getURL(shape_url)
    xlogic<-NULL
    for(i in paste(layer,shapefile_ext,sep=""))
    {
      xlogic<-c(xlogic,grepl(i,xurl))
    }

    #Set-up list of shapefiles to download
    shapefiles<-paste(shape_url,layer,shapefile_ext,sep="")[xlogic]
    #Set-up output file names
    outfiles<-paste(outfile,shapefile_ext,sep="")[xlogic]   }
    #Download all shapefiles
    if(sum(xlogic)>0)
    {
      for(i in 1:length(shapefiles))
      {
        download.file(shapefiles[i],outfiles[i],
                      method="auto",mode="wb")
      }
      } else
      {
      stop("An Error has occured with the input URL
            or name of shapefile")
    }
}

And now to prove it works I can do something like the following:

#Download the NH State Boundaries
download.shapefile("ftp://ftp.granit.sr.unh.edu/pub/GRANIT_Data/Vector_Data/Administrative_and_Political_Boundaries/d-nhsenatedists/2012",
                   "NHSenateDists2012")
#Read shapefiles in SpatialPolygonsDataFrame
NHBnd<-readOGR(".","NHSenateDists2012")
#Plot it
plot(NHBnd)
New Hampshire State Boundary and Senate District

New Hampshire State Boundary and Senate District

Lastly, there are some other approaches for tackling related problems listed below.

claimtoken-5249c78db4c7a

Open Access and Landscape Ecology

I’ve got a dilemma.  I recently received a request to review a manuscript for the journal, Landscape Ecology.  It is the primary journal for the field.  If I am to be a good landscape ecology citizen I really should do the review.  The problem is that Landscape Ecology is not an Open Access journal.  If I am to be a good science citizen then, I believe, I should do all I can to support Open Access.  So, I am left with the decision to support the field and society I have been active in for years or support Open Access, which I support fully yet am only a recent convert. As I see it I have four options:

  • Review and be quiet
  • Don’t review and be quiet
  • Don’t review, but provide an explanation to the editor.    This is much like what Scott Chamberlain, Casey Bergman, Michael Ashburner and others have done.
  • Review, but provide an explanation to the editor and try to start a discussion about migrating Landscape Ecology to Open Access.

I have decided on the last option.  First, I respect the decision others have made to say no to the review.  In some case, I think that would be the best path.  However, I have been active with US-IALE for several years and would feel more hypocritical just saying no.   Thus, for me, the decision I feel best with is to try and support the journal while also pushing for change.  In short,  I am hoping that I will be able to serve both sides.

By doing this,  I can feel as if I am doing my landscape ecological duty and provide a good and constructive review (assuming of course that I am capable of a review that is both good and constructive).  But at the same time I can register my discomfort with the current publishing model to which my field’s flagship journal adheres.  My plan is to agree to the review, but also include some language in my acceptance about my hesitation due to the closed nature of our journal.   Additionally, I will share my thoughts with the papers authors and suggest that, if feasible, they explore publishing the article under the open access license.   Lastly, I plan to start a discussion within our national chapter of the society.  At a minimum I can at least raise the issue.  If I am a bit more successful , then I can hopefully encourage others to act similarly.  At best, I can start a conversation with our journals editorial board to plan how and when Landscape Ecology could go completely Open Access. I do wonder what others think about this plan to encourage change and also what the consensus is on Landscape Ecology switching to an open access model.

Whither the landscape ecology blogger?

I started this blog for myself, mostly.  I wanted to get better at writing, to keep track of some R tricks, talk about Open Science, and learn about others doing the same.  It’s this last thing that is turning out to be a bit of a challenge.  Not so much for finding other R bloggers or Open Science Bloggers or GIS bloggers or ecology bloggers.  They are ubiquitous.  It’s the landscape ecology bloggers that seems to be mostly missing.

Just for illustration, I turn, of course, to Google. The first set of terms looks at various sub-disciplines of ecology. The two with the least number of hits are indeed those that would be most closely associated with the field of Landscape Ecology.

Search Terms Number of Hits 
“Spatial Ecology” Blog  79,600
“Landscape Ecology” Blog  118,000
“Marine Ecology” Blog  133,000
“Ecosystem Ecology” Blog  142,000
“Evolutionary Ecology” Blog  415,000

This last set of search terms are just for comparisons sake.  I know it is apples and oranges, but hey it makes my point, kind of.

Search Terms Number of Hits 
“Open Science” Blog  327,000
“Geographic Information System” Blog  7,300,000
Ecology Blog 26,000,000
R Statistics Blog  159,000,000

Looking a bit closer at the actual results for both “”Spatial Ecology” Blog” and “”Landscape Ecology” Blog” reveals that many of these listed blogs are out of date (i.e., no posts in the last 3 months), are primarily lab websites, or are landscape ecology class websites.    Lastly, there is almost no representation, that I could find, from landscape ecologists active in the International Association of Landscape Ecology or the US Chapter (US-IALE, of which I am an active member).  The very few exceptions to this, that I am aware of, I have listed in my blogroll.

Is the field of landscape ecology getting left behind in the Web 2.0 world of science?  Probably not yet.    At this point,  I think it represents an opportunity.  I hope this blog will partly fill the gap.   But given I am merely on post number 2, it is hard to say.  Heck, I don’t know if I can keep up the blogging nor if I have anything interesting enough to say that others might want to read.

Regardless of whether or not I do anything of consequence with Landscape Ecology 2.0, I believe this gap will be filled.  It will be filled by all the fantastic landscape ecology students with whom I have interacted with via US-IALE.  If any of you are actually reading this, take note.  There is a niche to be filled and, in my opinion, engaging in online discussion of science, and specifically landscape ecology, can be a great thing for your career.  Start a blog about your research, about your graduate career, about anything related to landscape ecology.  Then, get it picked up by an aggregator.  The one I found out about recently is EcoBloggers.  For more info on that head over to Jabberwocky Ecology for details.

Also read more about the general topic of research blogging in ecology.  There are growing number of ecology bloggers who make this case much better than I.

In particular, check out these following posts for some of the more cogent arguments:

And lastly, if I have missed the boat completely and my read on the, uh, blogging landscape (sorry) is wrong, let me know.  Who are the landscpe ecology bloggers you follow?  Give me more stuff to read, already!