Color palettes in ggpairs

Working on some code and was having a tough time configuring the color palette in GGally since it does not produce a ggplot object.  It appears to be a larger problem.  So, here is one hack, redefine the ggplot function and change the default palette there.  Need to make a dyerlab::palette now…

GStudio: An R Package for Spatial Analysis of Marker Data

This is the main package that provides data types and routines for spatial analysis of genetic marker data. The previous version is currently available on CRAN and you can install it rom within your R environtment by invoking the command


If you want to keep up with the latest developments of this package, you can use the version found on GitHub.  Install it from within R as:


and that should get you up-to-date.  You’ll need to have a fully working LaTeX install and some other stuff to build it if you fork.

The Users Manual for the package with several examples can be found here

I have started a github account for this package, you can get access to the whole codebase read about it on the wiki, and contribute to the project from its repo at

Extracting Data from Rasters

This document shows you how to extract data from rasters.


Getting The Libraries

First, I’ll load in some packages to get the ability to work with raster data and to load in the Arapatus attenuatus data set (it is part of the default gstudiopackage).


Loading and Cropping Rasters

We can load in the raster, and then crop it to just the are we need. These rasters were downloaded from [] and are much larger than the study area. This just makes it easier on the computer to not have to deal with such large areas. After cropping it, we will load in the annual precip and temperature data as well.


Getting Example Data from Araptus attenuatus

Now, lets grab the Araptus data and look at the data and plot out the locations.




Extracting Point Data

To elevation, temperature and precipitation from the rasters for each sampling location, we need to translate them into points first. I’ll first grab the coordinate data as a data.frame.


Then we can grab them using the normal functions in the sp library.



Plotting Trend lines.

Cool, lets sort this by latitude


and then plot out some values to look at what is going on.






Updating R and With Current Libraries

If you work in R for very long on mac, there comes a time when you upgrade and the framework process looses all your libraries!  In some sense this is pretty lame because you now have to install all these libraries again.  However, it can be a blessing if you install packages in a willy-nilly fashion as you will only reinstall the ones you use most often.  At any rate, it is kind of a pain.  Here is what I’ve been doing about this to automate the process.  The key here is that you need to do the first part before you upgrade.

Current Library

In the old version of R, prior to updating you’ll want to save the libraries that you have installed.  In R, this can be done as follows:


Install Updated R Version

Either download the latest package or update your svn repository and rebuild R and install it.  There are a lot of options for learning more about these options elsewhere on the web.

Install Missing Packages

Now, in the new version of R, you can figure out which are installed by default and then take the differences from what you have and what the previous version had installed and then install them.


And you should be done.