Description Usage Arguments Value Author(s) References Examples
Univariate and multivariable local spatial analysis. This program computes Getis-Ord G and G*, and LISA's (local Moran and local Geary) statistics for the data Z, with P-values or bootstrap confidence intervals.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
var |
Vector, matrix or data frame for the analysis. Multiple variables in columns. |
con |
An object of class eco.weight obtained with the function |
method |
Method of analysis: "G" for Getis-Ord G, "G*" for Getis-Ord G*, "I" for local Moran's I or "C" for local Geary's C. |
zerocon |
If zerocon = 0 the program assigns the value 0 to those individuals with no connections; if zerocon = NA the program assigns NA. Default is NA. |
nsim |
Number of Monte-Carlo simulations. |
conditional |
Logical. Should be used a conditional randomization? (Anselin 1998, Sokal and Thomson 2006). The option "auto" sets conditional = TRUE for LISA methods and G, as suggested by Sokal (2008). |
test |
If test = "bootstrap", for each individual test, the program generates a bootstrap resampling and the associated confidence intervals of the null hypotesis. If test = "permutation" (default) a permutation test is made and the P-value is computed. |
alternative |
The alternative hypothesis for "permutation" test. If "auto" is selected (default) the program determines the alternative hypothesis in each individual test. Other options are: "two.sided", "greater" and "less". |
adjust |
Correction method of P-values for multiple tests,
passed to |
multi |
multiple output format results. "list" for object with a list of individual test for each variable, or "matrix" for results as matrices of multiples variables. |
pop |
numeric factor with the population of each individual. Optional for multiple tests with multi = "matrix". |
For single test, the program returns an object of class "eco.lsa" with the following slots:
> OUT results - table with output results.
–> If test = "permutation": observed value of the statistic , null confidence interval and #rescaled observed value to [-1, 1] range, as in Sokal (2006)
–> If test = "bootstrap": observed and expected value of the statistic, alternative hypotesis, null confidence interval and rescaled observed value to [-1, 1] range, as in Sokal (2006)
> METHOD method (coefficent) used in the analysis
> TEST test method used (bootstrap, permutation)
> NSIM number of simulations
> PADJUST P-values adjust method for permutation tests
> COND conditional randomization (logical)
> XY input coordinates
For multiple test, if the parameter multi = "list", the program returns a list of eco.lsa objects (one element for each variable).
For multiple test, if the parameter multi = "matrix", the program returns an object of class "eco.multilsa" with the following slots:
> METHOD method used in the analysis
> TEST test method used (bootstrap, permutation)
> NSIM number of simulations
> PADJUST P-values adjust method for permutation tests
> COND conditional randomization (logical)
> XY input coordinates
> OBS observed value
> EXP expected value
> ALTER test alternative
> PVAL pvalue for permutation test
> LWR lower confidence interval bound of the null hypotesis
> UPPR upper confidence interval bound of the null hypotesis
> OBS.RES rescaled observed value to [-1, 1] range, as in Sokal (2006)
ACCESS TO THE SLOTS The content of the slots can be accessed with the corresponding accessors, using the generic notation of EcoGenetics (<ecoslot.> + <name of the slot> + <name of the object>). See help("EcoGenetics accessors") and the Examples section below
Leandro Roser learoser@gmail.com
Anselin L. 1995. Local indicators of spatial association-LISA. Geographical analysis. 27: 93-115.
Getis A., and J. Ord. 1992. The analysis of spatial association by use of distance statistics. Geographical analysis, 24: 189-206.
Ord J., and A. Getis. 1995. Local spatial autocorrelation statistics: distributional issues and an application. Geographical analysis, 27: 286-306.
Sokal R., N. Oden and B. Thomson. 1998. Local spatial autocorrelation in a biological model. Geographical Analysis, 30: 331-354.
Sokal R. and B. Thomson. 2006. Population structure inferred by local spatial autocorrelation: an example from an Amerindian tribal population. American journal of physical anthropology, 129: 121-131.
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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | ## Not run:
data(eco.test)
#---------------------------------------------------------------------------#
#####################
# LOCAL MORAN'S I
#####################
DETAILED EXAMPLE
#-------------------------
# TESTING PHENOTYPIC DATA-
#-------------------------
set.seed(10)
# test for a single variable---------------------------------
#computing weights
con <- eco.weight(eco[["XY"]], method = "knearest", k = 4, row.sd = TRUE)
# row standardized weights = TRUE
# test for the first trait of the data frame P
localmoran <- eco.lsa(eco[["P"]][, 1], con, method = "I", nsim = 99)
# "rankplot" graph
eco.plotLocal(localmoran)
# test for several variables---------------------------------
# ordering the factor "pop" in increasing order and the object "eco"
# in relation to this ordered factor prior to the multivariate analysis.
# This step is important for "localplot" graphs.
eco <- eco[order(eco[["S"]][,1])]
#computing weights with the ordered object
con <- eco.weight(eco[["XY"]], method = "knearest", k = 4, row.sd = TRUE)
# row standardized weights = TRUE
all.traits <- eco.lsa(eco[["P"]], con, method = "I", nsim = 99)
# Plot of the phenotypic spatial patterns
# "rasterplot" graph
eco.plotLocal(all.traits)
# in grey: non significant results (P > 0.05)
# set significant = FALSE for showing significant and no significant results
eco.plotLocal(all.traits, significant = FALSE)
# single plots using "rankplot" graphs
all.single.traits <- eco.lsa(eco[["P"]],con, method = "I", nsim = 99, multi="list")
eco.plotLocal(all.single.traits)
# removing legends for a better visualization
eco.plotLocal(all.single.traits, legend = FALSE)
# - individual plots support ggplot2 sintax (plot equivalent to the previous):
eco.plotLocal(all.single.traits) + ggplot2::theme(legend.position="none")
#-------------------------
# TESTING GENOTYPIC DATA-
#-------------------------
# eco[["A"]] is a matrix with the genetic data of "eco"
# as frequencies for each allele in each individual.
head(eco[["A"]]) # head of the matrix - 40 alleles
# ordering the factor "pop" in increasing order and the object "eco"
# in relation to this ordered factor prior to the multivariate analysis.
# This step is important for "localplot" graphs
data(eco.test) # for security this resets the data (unordered)
eco <- eco[order(eco[["S"]][,1])] # ordering
# computing weights with the ordered object
con <- eco.weight(eco[["XY"]], method = "knearest", k = 4, row.sd = TRUE)
# row standardized weights = TRUE
# test for a single allele
localmoran.geno <- eco.lsa(eco[["A"]][, 32], con, method = "I", nsim = 99)
# test for several alleles - 40 alleles (it runs in less than 1 min
# for 99 simulations per allele; 999 simulations takes ~ 11 s per allele,
# less than 8 min in total.)
all.alleles <- eco.lsa(eco[["A"]], con, method = "I", nsim = 99)
# plot all alleles to get an overview of the spatial patterns
eco.plotLocal(all.alleles)
# in grey: non significant results (P > 0.05)
# set significant = FALSE for showing significant and no significant results
eco.plotLocal(all.alleles, significant = FALSE)
# counting individuals with P < 0.05 for each allele (5 * 225 /100 ~ 12 significant tests
# by random)
signif <- apply(ecoslot.PVAL(all.alleles), 2, function(x) sum (x < 0.05))
# filtering alleles, loci with > 12 significant individual tests
A.local <- eco[["A"]][, signif > 12] #filtered matrix
all.alleles.f <- eco.lsa(eco[["A"]][, signif > 12] , con, method = "I", nsim = 99)
# Plot of the genotypic spatial patterns using "localplot" graphs
eco.plotLocal(all.alleles.f)
## using "rankplot" graphs
all.sf <- eco.lsa(A.local, 2, eco.lsa, con, method = "I", nsim = 99, multi = "list")
eco.plotLocal(all.sf, legend = FALSE)
#####################
# GETIS-ORD'S G*
#####################
con<- eco.weight(eco[["XY"]], method = "knearest", k = 4, self = TRUE) # self = TRUE for G*
getis.ak <- eco.lsa(eco[["P"]][, 1], con, method = "G*", nsim = 99, adjust = "none")
getis.ak
### to plot the results, the function "eco.lsa" calls "eco.rankplot"
### (see ?eco.rankplot) when test = "permutation" and "eco.forestplot" (see ?eco.forestplot)
### when test = "bootstrap"
p <- eco.plotLocal(getis.ak) # rankplot graph
p # points with colors of the color-scale:
# points with P < 0.05. Yellow points : points with P > 0.05
p <- eco.plotLocal(getis.ak, significant = FALSE)
p # all points have a color of the color-scale
#-----------------------
# ACCESSORS USE EXAMPLE
#-----------------------
# the slots are accessed with the generic format
# (ecoslot. + name of the slot + name of the object).
# See help("EcoGenetics accessors")
ecoslot.OUT(getis.ak)
## bootstrap example
getis.akb <- eco.lsa(eco[["P"]][, 1], con, method = "G*", nsim = 99, test = "bootstrap")
p <- eco.plotLocal(getis.akb) # forestplot graph
p2 <- eco.plotLocal(getis.akb, interactivePlot = FALSE)
p2 + ggplot2::theme_bw() # the plot can be modified with ggplot2
# In this case, the background is modified (white color)
#---------------------------------------------------------------------------#
#####################
# GETIS-ORD'S G
#####################
con <- eco.weight(eco[["XY"]], method = "knearest", k = 4)
# self = FALSE for G
getis <- eco.lsa(eco[["P"]][, 1], con, method = "G", nsim = 99)
eco.plotLocal(getis)
#---------------------------------------------------------------------------#
#####################
# LOCAL GEARY'S C
#####################
con<- eco.weight(eco[["XY"]], method = "knearest", k = 4, row.sd = TRUE)
# row standardized weights = TRUE
localgeary <- eco.lsa(eco[["P"]][, 1], con, method = "C", nsim = 99, adjust = "none")
eco.plotLocal(localgeary)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.