Use least-cost path distances among sampling locations on a resistance surface, rather than Euclidean distances (as in `mgQuick`

), to extract MEM eigenvectors. The goal is to compare multiple resistance surfaces (i.e. representing alternative hypotheses about landscape resistance) in terms of the proportion of variation in genetic distance they explain. This is often a goal in landscape genetic analysis. By default Euclidean distances (i.e. representing a surface with no landscape resistance) are also analyzed unless `euclid=FALSE`

.

The analysis steps are as follows:

1. Find MEM eigenvectors given a distance matrix extracted from the
coordinates (`coords`

). In the case of a resistance surface the
distances are least-cost paths among sampling locations found using the
function `gdistance::costDistance`

. In the Euclidean case
Euclidean distances are used. For all distance matrices a minimum spanning tree
of the locations is found, followed by truncation of the tree (see `mgMEM`

)

2. Perform separate forward selections of positive and
negative MEM eigenvectors against genetic distance (`genD`

),
to identify a significant
subset, using parameters `forwardPerm`

as the number of
permutations and `forwardAlpha`

as the alpha level
for a significant eigenvector. NOTE: The number of permutations
`forwardPerm`

is set at 100 by default to reduce analysis time for
exploratory analyses. This number should be increased for final analyses.

3. Use variation partitioning against the genetic distance matrix to find the proportion of variation in genetic distance explained by the selected positive and negative MEM eigenvectors (i.e. fraction [a] representing spatial genetic variation explained by the resistance surface hypothesis) and the matrix of coordinates (i.e. fraction [c] representing spatial genetic variation not explained by the resistance hypothesis). These [a] and [c] fractions can be used to inform model selection (see below).

1 2 3 4 | ```
mgLandscape(resistance, genD, coords, euclid=TRUE, forwardPerm=100,
forwardAlpha=0.05, finalPerm=1000, verbose=TRUE)
## S3 method for class 'mgLandscape'
print(x, ...)
``` |

`resistance` |
A |

`genD` |
A symmetrical distance matrix giving the genetic distances among individual genotypes or populations |

`coords` |
A two column |

`euclid` |
If |

`forwardPerm` |
The number of permutations in the randomization test for the forward selection of MEM eigenvectors.
The default |

`forwardAlpha` |
The 1-alpha level for the forward selection process |

`finalPerm` |
The number of permutations to test the significance of the [a], [c] and [abc] fractions. |

`verbose` |
If |

`x` |
An object of class |

`...` |
Additional parameters passed to |

A code$summary table giving the results of the variation partitioning. The following table
provides an interpretation of each of the fractions returned:

Proportion of variation in genetic distance that is... `(RsqAdj)`

`[abc] explained by spatial predictors`

`[a] spatial and explained by selected patterns in the model`

`[c] spatial and explained by coordinates not patterns in the model`

`[b] spatial and confounded between the model and coordinates`

`[d] residual not explained by the spatial predictors`

A good model will have a relatively high [a] fraction and relatively low [c] fraction indicating
that the selected patterns in the landscape model have captured a large proportion of the spatial variation in genetic distance.

Pedro Peres-Neto (peres-neto.pedro@uqam.ca)

Paul Galpern (pgalpern@ucalgary.ca)

Galpern, P., Peres-Neto, P., Polfus, J., and Manseau, M. 2014. MEMGENE: Spatial pattern detection in genetic distance data. Submitted.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | ```
## Not run:
## Compare data generated using the radial data against three landscape models
##
## Prepare two resistance surfaces to test (the true radial, and the false river)
## These are produced as a RasterStack object
if (require(raster)) {
resistanceMaps <- stack(
raster(system.file("extdata/radial.asc", package="memgene")),
raster(system.file("extdata/river.asc", package="memgene")))
} else {
stop("raster package required for mgLandscape.")
}
## Prepare the radial data for analysis
radialData <- read.csv(system.file("extdata/radial.csv", package="memgene"))
radialGen <- radialData[, -c(1,2)]
radialXY <- radialData[, 1:2]
if (require(adegenet)) {
radialDM <- codomToPropShared(radialGen)
} else {
stop("adegenent package required to produce genetic distance matrix in example.")
}
## Analyse the two resistance surfaces and a Euclidean model
## and produce a table comparing the three
## Set permutations at low values for a faster (though less accurate) run
compareThree <- mgLandscape(resistanceMaps, radialDM, radialXY, euclid=TRUE,
forwardPerm=100, finalPerm=100)
print(compareThree)
## Results can vary between runs because selected MEM eigenvectors may vary.
## Setting forwardPerm higher will increase consistency in this regard.
##
## We see that the true radial surface has the highest [a] fraction and
## the lowest [c] fraction indicating that it does well at capturing
## the spatial genetic variation that we expect in this simulated genetic data
## End(Not run)
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.