Package fgpt. February 19, 2015

Similar documents
Package logitnorm. R topics documented: February 20, 2015

Package assortnet. January 18, 2016

Package MDSGUI. February 19, 2015

Package epitab. July 4, 2018

Package quickreg. R topics documented:

Package marinespeed. February 17, 2017

Package bisect. April 16, 2018

Package ccapp. March 7, 2016

Package splithalf. March 17, 2018

Package ssd. February 20, Index 5

Package Numero. November 24, 2018

Package simtool. August 29, 2016

Package superbiclust

Package longitudinal

Package reval. May 26, 2015

Package catenary. May 4, 2018

Package EnQuireR. R topics documented: February 19, Type Package Title A package dedicated to questionnaires Version 0.

Package RCA. R topics documented: February 29, 2016

Package OptimaRegion

Package semisup. March 10, Version Title Semi-Supervised Mixture Model

Package filematrix. R topics documented: February 27, Type Package

Package ptinpoly. February 20, 2015

Package iterators. December 12, 2017

Package hextri. April 22, 2016

Package optimus. March 24, 2017

Package rococo. October 12, 2018

Package lmesplines. R topics documented: February 20, Version

Package DiffCorr. August 29, 2016

Package PedCNV. February 19, 2015

Package orderbook. R topics documented: February 20, Type Package Title Orderbook visualization/charting software

Package lhs. R topics documented: January 4, 2018

Package cooccurnet. January 27, 2017

Package TPD. June 14, 2018

Package mgc. April 13, 2018

Package SSLASSO. August 28, 2018

Package imgur. R topics documented: December 20, Type Package. Title Share plots using the imgur.com image hosting service. Version 0.1.

Package diagis. January 25, 2018

Package corclass. R topics documented: January 20, 2016

Package OmicKriging. August 29, 2016

Package sigqc. June 13, 2018

Package MultiMeta. February 19, 2015

Package uclaboot. June 18, 2003

Package truncreg. R topics documented: August 3, 2016

Package intcensroc. May 2, 2018

Package recoder. R topics documented: July 10, Type Package Title A Simple and Flexible Recoder

Package Corbi. May 3, 2017

The ctest Package. January 3, 2000

Package dirmcmc. R topics documented: February 27, 2017

The simpleboot Package

Package cgh. R topics documented: February 19, 2015

Getting started with simulating data in R: some helpful functions and how to use them Ariel Muldoon August 28, 2018

Package NetCluster. R topics documented: February 19, Type Package Version 0.2 Date Title Clustering for networks

Package weco. May 4, 2018

Package clusterrepro

Package cattonum. R topics documented: May 2, Type Package Version Title Encode Categorical Features

Package GCAI.bias. February 19, 2015

Package RTNduals. R topics documented: March 7, Type Package

Package TSzip. February 15, 2013

Package EBglmnet. January 30, 2016

Package furniture. November 10, 2017

Package allehap. August 19, 2017

Practical OmicsFusion

Package diggit. R topics documented: January 11, Version Date

Package CRF. February 1, 2017

Package CUFF. May 28, 2018

Package spcadjust. September 29, 2016

Package desplot. R topics documented: April 3, 2018

Package widyr. August 14, 2017

Package sparsereg. R topics documented: March 10, Type Package

Package MetaLonDA. R topics documented: January 22, Type Package

Package mcmcse. February 15, 2013

Package OLScurve. August 29, 2016

Package mdftracks. February 6, 2017

Package GUTS. R topics documented: October 10, Type Package

Package parcor. February 20, 2015

Package sciplot. February 15, 2013

Package batchmeans. R topics documented: July 4, Version Date

Package ridge. R topics documented: February 15, Title Ridge Regression with automatic selection of the penalty parameter. Version 2.

Package ClustGeo. R topics documented: July 14, Type Package

Package gggenes. R topics documented: November 7, Title Draw Gene Arrow Maps in 'ggplot2' Version 0.3.2

Package smoothr. April 4, 2018

Package bingat. R topics documented: July 5, Type Package Title Binary Graph Analysis Tools Version 1.3 Date

Package rococo. August 29, 2013

Package CvM2SL2Test. February 15, 2013

Package treedater. R topics documented: May 4, Type Package

Package PCGSE. March 31, 2017

Package MOJOV. R topics documented: February 19, 2015

Package mrbsizer. May 2, 2018

Package flsa. February 19, 2015

Package orloca. April 21, Type Package Depends methods, png, ucminf Suggests grdevices, graphics, knitr VignetteBuilder knitr

Package clustvarsel. April 9, 2018

Package geojsonsf. R topics documented: January 11, Type Package Title GeoJSON to Simple Feature Converter Version 1.3.

Package NB. R topics documented: February 19, Type Package

Package compartmap. November 10, Type Package

Package REGENT. R topics documented: August 19, 2015

Package Combine. R topics documented: September 4, Type Package Title Game-Theoretic Probability Combination Version 1.

Package vinereg. August 10, 2018

Package skelesim. November 27, 2017

STENO Introductory R-Workshop: Loading a Data Set Tommi Suvitaival, Steno Diabetes Center June 11, 2015

Package Cubist. December 2, 2017

Transcription:

Type Package Title Floating Grid Permutation Technique Version 2.3 Date 2015-02-19 Author Reinder Radersma & Ben Sheldon Package fgpt February 19, 2015 Maintainer Reinder Radersma <reinder.radersma@zoo.ox.ac.uk> A permutation technique to explore and control for spatial autocorrelation. This package contains low level functions for performing permutations and calculating statistics as well as higher level functions. Higher level functions are an easy to use function for performing spatially restricted permutation tests and summarize and plot results. VignetteBuilder knitr Suggests knitr License GPL Repository CRAN Repository/R-Forge/Project fgm Repository/R-Forge/Revision 48 Repository/R-Forge/DateTimeStamp 2015-02-19 05:46:51 Date/Publication 2015-02-19 07:44:06 Depends R (>= 2.10) NeedsCompilation no R topics documented: fgpt-package........................................ 2 fgeasy............................................ 2 fgperm............................................ 4 fgstat............................................ 6 fyshuffle........................................... 8 Gpulex............................................ 9 Pmajor............................................ 10 Index 11 1

2 fgeasy fgpt-package Floating Grid Permutation Technique FGPT is a spatially restricted permutation technique. The package contains both low level functions to produce permuted datasets as well as higher level functions to perform spatially restricted permutation tests and functions to summarize and plot the results. Details fgeasy is the single step version of the FGPT, which is most suitable for first time users. Please read the vignette for a more extensive discription of the method and functions. Author(s) Reinder Radersma & Ben Sheldon fgeasy Single step version of the Floating Grid Permutation Technique The Floating Grid Permutation Technique is a spatially restricted permutation technique. Please read the reference mentioned below and/or the vignette before using this function. fgeasy can be used to perform single step permutation tests. This function can be used for detecting spatial autocorrelation for univariate observations (using Moran s I), pairwise observations (using a correlation coefficient) or multivariate observations for both single and pairwise sets of multivariate observations (using mean distance or relatedness). fgeasy(xy, group=1, marks, iter=999, ratio=1, scale.seq=seq(from=0, to=max(dist(xy)), length.out=21)[2:21], bootstrap=false, pairwise=false, correlate=false)

fgeasy 3 Arguments xy group marks iter Geographical locations of observations. Group membership for the observations. group is optional. Should be a vector containing all observations, a two-column matrix containing two paired observations or a squared matrix containing relationships or distances between all observations (such as genetic relatedness or distance). The latter can be used to perform multivariate analyses. Note that the squared matrix does not need to be symmetrical: for instance, the genetic relatedness between paired individuals can be investigated by using males as columns and females as rows. NAs are allowed. Number of iterations for every grid cell size. Default is 999, though it is adviseable to perform 9999 interations for the final results. ratio The ratio between the sides of the grid cells. Default is 1. scale.seq bootstrap pairwise correlate Sequence of all grid cell sizes that will be tested. The number, order and values of this sequence are completely free, as long as they are numeric. Default is 20 equaly spaced out grid cell sizes from slightly larger than 0 to the maximum distance between any two individuals. TRUE if observations should to be drawn with replacement, FALSE if not. Default is FALSE. TRUE if observations consist of two paired marks per observation, FALSE if not. Default is FALSE. If pairwise==false Moran s I is used as test statistic. If one wants to compare two paired observations correlations between the observations can be used. The argument correlate can be used to pass on the peferred method of correlation as available in cor.test; so "pearson", "kendall" or "spearman". If marks is not a two-column matrix correlate should be FALSE. Default is FALSE. Value fgeasy returns an object of class "fg", which can be accessed with the functions summary and plot. Author(s) Reinder Radersma See Also cor.test

4 fgperm Examples ## A simple univariate example ## ## Produce 49 geographical locations in a regular grid. loc.x <- rep(1:7,7) loc.y <- rep(1:7, each=7) ## Produce 49 observations with negative spatial autocorrelation. marks <- c(rep(c(1,2), 24),1)+rnorm(49,0,0.1) fg1 <- fgeasy(xy=cbind(loc.x,loc.y), marks=marks, iter=99) summary(fg1) plot(fg1) ## An example for two paired marks ## ## Produce 20 geographical locations. loc.x <- 1:20 loc.y <- runif(20,0,5) ## Produce 2 x 20 phenotypes. type1 <- 11:30+runif(20,0,5) type2 <- 11:30+runif(20,0,5) fg2 <- fgeasy(xy=cbind(loc.x,loc.y), marks=cbind(type1,type2), iter=99, pairwise=true, correlate="pearson") summary(fg2) plot(fg2) fgperm Floating Grid Permutation Technique The fgperm function produces sets of permuted observations or indices using the Floating Grid Permutation Technique, which is a method for spatially restricted permutations. fgploc offers additional functionality to manipulate observations within grid cells, for instance observations could be scaled with grid cells. fgperm(xy,z=1:dim(xy)[1], scale, group=1, iter=999, ratio=1, FUN=fyshuffle,..., add.obs=false, as.matrix=false) fgploc(xy, scale, group=1, iter=999, ratio=1, FUN=fyshuffle, FUN.mani,..., marks, pass.rand=false)

fgperm 5 Arguments xy Two-column matrix with the geographical locations of observations. z Vector with the observations. If left empty z will be a vector of indices from 1 to the total number of geographical locations. Those indices can be later be used for calculating statistics with fgstat. scale group iter Value indicating the spatial scale of the permutations. scale should be positive. Optional group membership of observations. group can be used when observations are for instance collected over multiple years. Number of iterations for every grid cell size. Default is 999. Note that in order to produce a probability an observation is assigned to any of the geographical locations is a negative function of the distance between its original and assigned location many iterations are needed. ratio The ratio between the sides of the grid cells. Default is 1. FUN Details FUN.mani Function to perform randomizations. Note that the function must be able to randomize one value, which is for instance a issue if using sample. For solutions see the Details and Examples of sample. The default is the Fisher-Yates shuffle fyshuffle. Function to perform manipulations of the observations within grid cells. This functionality should be used together with cal.stat to calculate specific statistics.... Optional arguments to FUN and FUN.mani. marks add.obs as.matrix pass.rand Should either be left empty, be a vector or a matrix. When z contains observations marks should be left empty. If the randomization procedure is for testing one variable, marks should be a vector for which the row numbers correspond to the index values in z. If the randomization procedure is for testing two variables (for instance the distance between them), marks should be a matrix for which the row numbers correspond to the index values in z. If TRUE the first set in the output will be the observed values. If TRUE the output will be a matrix. If FALSE the output will be a list, which is needed when analyzing the data with cal.stat. If TRUE The sets of randomized observations are also passed on to the output. Default is FALSE. Before using those functions please read the reference or vignette. Alternatively use the more userfriendly function fgeasy. If there are missing values for the observations, leave z empty and enter the observations as marks in the fgstat function. Value fgperm returns a list or a matrix, depending on the setting of argument as.matrix. Author(s) Reinder Radersma

6 fgstat Examples ## 200 random geographical locations xy <- array(runif(400,0,2), dim=c(200,2)) ## run fgperm to produce 99 randomizations for scale 1 test <- fgperm(xy, scale=1, iter=99, add.obs=true) ## run fgperm to produce 99 bootstraps for scale 1 test <- fgperm(xy, scale=1, iter=99, FUN=function(x){ x[sample.int(length(x),replace=true)]}, add.obs=true) ## 200 times 200 random distances (e.g. genetic relatedness between mated pairs) trait <- array(rnorm(200*200,0.6,0.1), dim=c(200,200)) ## make the observed pairs more alike diag(trait) <- diag(trait)+0.02 ## make two rows and two colums empty trait[,3] <- NA trait[,50] <- NA trait[6,] <- NA trait[12,] <- NA ## calculate means; will give NAs because there are missing values calc <- fgstat(test,trait,mean) ## calculate means calc <- fgstat(test,trait,mean, na.rm=true) ## plot means hist(calc) abline(v=calc[1], col="red", lwd=2) fgstat Calculate statistics for FGPT Calculates a set of values for a particular statistic or sets of observations, typically for observed values and multiple sets of randomized observations. fgstat(rand,marks,fun=mean,...)

fgstat 7 Arguments rand marks FUN Details Value A list for which the elements are either sets of randomized variables or randomized index values. rand can, but not necessarily is, the output of the function fgperm. Should either be left empty, be a vector or a matrix. When rand contains randomized variables marks should be left empty. If the randomization procedure is for testing one variable, marks should be a vector for which the row numbers correspond to the index values used in rand. If the randomization procedure is for testing two variables (for instance the distance between them), marks should be a matrix for which the row numbers correspond to the index values used in rand. Any function used to calculate the statistic of interest (e.g. mean, median, var, sd). Default for FUN is mean.... Optional arguments to FUN. A particular useful one if dealing with missing values and using one of the functions from base is na.rm=true. fgstat is designed to calculate statistics for spatial explicit data for which randomized data sets are generated with fgperm. fgstat returns a vector of statistics. If rand is the output of fgperm and add.obs=true, the first value is the statistic for the observed data and the rest for randomizations. Author(s) Reinder Radersma Examples #### Example for fgrand ## 200 random geographical locations xy <- array(runif(400,0,2), dim=c(200,2)) ## run fgperm to produce 99 randomizations for scale 1 test <- fgperm(xy, scale=1, iter=99, add.obs=true) ## run fgperm to produce 99 bootstraps for scale 1 test <- fgperm(xy, scale=1, iter=99, FUN=function(x){ x[sample.int(length(x),replace=true)]}, add.obs=true)

8 fyshuffle ## 200 times 200 random distances (e.g. genetic relatedness between mated pairs) trait <- array(rnorm(200*200,0.6,0.1), dim=c(200,200)) ## make the observed pairs more alike diag(trait) <- diag(trait)+0.02 ## make two rows and two colums empty trait[,3] <- NA trait[,50] <- NA trait[6,] <- NA trait[12,] <- NA ## calculate means; will give NAs because there are missing values calc <- fgstat(test,trait,mean) ## calculate means calc <- fgstat(test,trait,mean, na.rm=true) ## plot means hist(calc) abline(v=calc[1], col="red", lwd=2) fyshuffle Fisher-Yates shuffle Function to shuffle vectors according to the Fisher-Yates procedure fyshuffle(x) Arguments x Vector containing the sequence which needs to be shuffled. This vector can be of any type and it is allowed to have one element. Details Value Other than the sample function fyshuffle treats a single value as a vector with one element and will therefore return this element as the shuffled version of the original vector (which are similar). A randomized version of the input vector.

Gpulex 9 Author(s) Reinder Radersma See Also Durstenfeld (1964) Communications of the ACM 7(7):420 sample Examples x <- 1:10 fyshuffle(x) y <- c("a","b","c","d","e","f") fyshuffle(y) Gpulex Size assortative pairing in a freshwater shrimp (Gammarus pulex) Format Source This is a simulated data set of geographical locations and body size measurements for two populations of fresh water Crustaceans. Both populations share the geographical locations and female phenotypes, but not the male phenotypes (m.pheno and m.pheno2 respectively). The first population does not show size assortative pairing, while the second does. Gpulex An R data object containing one two-column matrix with geographical coordinates (Gp.xy) and three vectors with female (f.pheno) and male body size measurements (m.pheno and m.pheno2). Code to produce this data set can be found in electronic supplementary materials of the following reference.

10 Pmajor Pmajor Inbreeding avoidance in the Great Tit (Parus major) Format Source This is a simulated data set of geographical locations and relatedness measures for two populations of Great Tits, a small passerine. Both populations share the geographical locations, but not the relatedness tables. The first population does not show inbreeding avoidance, while the second does. Pmajor An R data object containing one two-column matrix with geographical coordinates (xy) and two relatedness tables between all females and males of the populations (rel1 and rel2 respectively). Code to produce this data set can be found in electronic supplementary materials of the following reference.

Index Topic datasets Gpulex, 9 Pmajor, 10 Topic distribution fgperm, 4 Topic package fgpt-package, 2 Topic univar fgstat, 6 cor.test, 3 f.pheno (Gpulex), 9 fgeasy, 2 fgperm, 4 fgploc (fgperm), 4 fgpt-package, 2 fgstat, 6 fyshuffle, 8 Gp.xy (Gpulex), 9 Gpulex, 9 m.pheno (Gpulex), 9 m.pheno2 (Gpulex), 9 plot.fg (fgeasy), 2 Pmajor, 10 rel1 (Pmajor), 10 rel2 (Pmajor), 10 sample, 9 summary.fg (fgeasy), 2 xy (Pmajor), 10 11