mgForward: Forward selection of MEM eigenvectors against genetic...

Description Usage Arguments Details Value Author(s) Examples

View source: R/mgForward.R

Description

This function calls mgRDA repeatedly in order to identify a reduced set of all MEM eigenvectors (i.e. spatial patterns).

Usage

1
mgForward(genD, vectorsMEM, perm = 100, alpha = 0.05)

Arguments

genD

A symmetrical distance matrix giving the genetic distances among individual genotypes

vectorsMEM

A matrix giving a set of Moran's eigenvectors

perm

The number of permutations in a randomization test

alpha

The 1-alpha level for forward selection

Details

A wrapper for mgRDA designed for forward selection

Value

A list
$selectedMEM gives the indices of the input vectorsMEM that were selected and can then be used in a call to mgRDA(..., full=TRUE)

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
32
33
## 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)

memgene documentation built on May 2, 2019, 5:19 p.m.