# Extraction of MEMGENE variables using redundancy analysis (RDA)

### Description

Performs a redundancy analysis (RDA) given Moran's eigenvectors and a genetic distance matrix. Optionally performs a permutation test for the RDA. Returns the MEMGENE variables, which are the product of a PCA conducted on the fitted values of this RDA.

### Usage

1 |

### Arguments

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

`vectorsMEM` |
A matrix giving a set of any number of Moran's eigenvectors |

`perm` |
The number of permutations in a randomization test |

`full` |
If |

### Details

Any type of genetic distance matrix `genD`

giving pairwise
distances among individual genotypes could be used. Population genetic distances (e.g. pairwise
Fst among populations) could also be used in principle, in which case the sampling centroids
of populations should be used to develop the Moran's eigenvectors.

### Value

A list:

`$RsqAdj`

is the adjusted R2 for the RDA, understood as the proportion of
all genetic variation that is explicable by spatial pattern (i.e. spatial genetic
signal)

`$memgene`

gives the MEMGENE variables ordered according to the eigenvalues
which are given in `$sdev`

### Author(s)

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

Paul Galpern (pgalpern@ucalgary.ca)

### Examples

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 | ```
## Not run:
## 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]
radialDM <- codomToPropShared(radialGen)
## Find Moran's eigenvectors given sampling locations
## by first finding the Euclidean distance matrix
radialEuclid <- dist(radialXY)
radialMEM <- mgMEM(radialEuclid)
## Forward select significant Moran's eigenvectors using RDA
## Positive Moran's eigenvectors (positive spatial autocorrelation) first
radialPositive <- mgForward(radialDM,
radialMEM$vectorsMEM[ , radialMEM$valuesMEM > 0])
## Negative Moran's eigenvectors (negative spatial autocorrelation) second
radialNegative <- mgForward(radialDM,
radialMEM$vectorsMEM[ , radialMEM$valuesMEM < 0])
## Summarize the selected MEM eigenvectors
allSelected <- cbind(radialMEM$vectorsMEM[, radialMEM$valuesMEM > 0][
, na.omit(radialPositive$selectedMEM)],
radialMEM$vectorsMEM[, radialMEM$valuesMEM < 0][
, na.omit(radialNegative$selectedMEM)])
## Use the selected Moran's eigenvectors in a final model
radialAnalysis <- mgRDA(radialDM, allSelected, full=TRUE)
## End(Not run)
``` |

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker. Vote for new features on Trello.