Giter Site home page Giter Site logo

Comments (1)

dipetkov avatar dipetkov commented on September 5, 2024

How to combine multiple EEMS runs (for the same African elephant dataset)

library(dplyr,warn.conflicts=FALSE) ## Useful package for manipulating data frames
library(rEEMSplots) ## Defines eems.plots, which visualizes EEMS results

There are results from running EEMS once with four different densities: nDemes = 360, 540, 900, 1200.

eems.output = list.dirs("./elephants",recursive = FALSE) ## Show thesubdirectories in ./elephants/
eems.output
## [1] "./elephants/V3b-nohyb-nIndiv1124-nDemes1200-chain1"
## [2] "./elephants/V3b-nohyb-nIndiv1124-nDemes360-chain1" 
## [3] "./elephants/V3b-nohyb-nIndiv1124-nDemes540-chain1" 
## [4] "./elephants/V3b-nohyb-nIndiv1124-nDemes900-chain1"

Let's look at the results separately for each of the four runs. First generate the figures by calling eems.plots.

for (run in seq(4)) {
  eems.plots(mcmcpath = eems.output[run],
             plotpath = eems.output[run],
             longlat = TRUE,
             add.grid = TRUE,
             add.demes = TRUE)
}

Here nDemes = 360:
combine runs-unnamed-chunk-5-1

Here nDemes = 540:
combine runs-unnamed-chunk-6-1

Here nDemes = 900:
combine runs-unnamed-chunk-7-1

Here nDemes = 1200:
combine runs-unnamed-chunk-8-1

In each plot, I have added the population grid to illustrate that the density is different but the surfaces are qualitatively similar. Still, with higher density, the effective barrier to migration -- the area in dark brown that curves through the habitat -- gets to be estimated more precisely. (By this I mean that it is wider in some places and thinner in others.)

Next, let's combine combine the four results. Remember that eems.output is a list of four EEMS output directories.

## mcmcpath can be (ideally, will be) a list of multiple EEMS runs to average
combined.mcmcpath = eems.output
## plotpath should be one string (not a list of strings) for the averaged results
combined.plotpath = "./elephants/V3b-nohyb-nIndiv1124-combined-results"

eems.plots(mcmcpath = combined.mcmcpath,
           plotpath = combined.plotpath,
           longlat = TRUE)

combine runs-unnamed-chunk-9-1

That is, eems.plots works with one or mulitple EEMS output directories. The estimated migration rates (and diversity rates -- not shown above) are averaged to produce a surface/contour plot that often smoother and, more importantly, averages the effects of different population grids. [In practice, I run the program several times for a few different grids.]

While it is straightforward to combine the migration and diversity contour plots for multiple grids/runs, the diagnostic scatter plots are not so easy to combine. Recall that there is a diagnostic scatter plot that shows the observed and fitted dissimilarities between demes.

Between-demes dissimilarities for nDemes = 360:
combine runs-unnamed-chunk-10-1

There is also a diagnost scatter plot that shows the observed and fitted dissimilarities within demes. Within-demes dissimilarities for nDemes = 360
combine runs-unnamed-chunk-11-1

However, as the density varies and the population grid changes, the demes change as well -- most obviously, the number of demes but also their location. This means that the points in the between-demes scatter plot for nDemes = 360 do not correspond to the points in the between-demes scatter plot for nDemes = 540.

So if mcmcpath contains results for different population grids, eems.plots does not generate diagnostic plots by default. Instead it plots two different population grids. These contain no information but "explain" why there are no scatter plots.

Here nDemes = 1200:
combine runs-unnamed-chunk-12-1

Here nDemes = 360:
combine runs-unnamed-chunk-13-1

from eems.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.