spacemix.procrustes: Performs a Procrustes superimposition

View source: R/space.mix.MCMC.R

spacemix.procrustesR Documentation

Performs a Procrustes superimposition

Description

This function performs a full Procrustes superimposition of the geogenetic locations estimated with SpaceMix onto a reference set of observed geographic sampling coordinates. This superimposition consists of a rotation, reflection, scaling, and translation of the estimated locations so that they most closely match the reference coordinates. This function can also be used to transform the estimated sources of admixture along with the geogenetic locations, so that both are in the same frame of reference.

Usage

spacemix.procrustes(X, Y, k, admix.source.locs = NULL, option)

Arguments

X

A k x 2 matrix of the reference coordinates.

Y

A k x 2 matrix of the coordinates to be transformed.

k

The number of samples. This should be nrow(X).

admix.source.locs

The k x 2 matrix of estimated sources of admixture. This may be left NULL if the geogenetic locations are being transformed.

option

This argument, which takes the values 1 or 2, specifies whether the function returns the transformed geogenetic locations (1) or transformed sources of admixture (2).

Value

This function returns a k x 2 matrix of transformed coordinates, either those of the geogenetic locations (if option 1 is specified), or those of the sources of admixture (if option 2 is specified).

Examples


# load example location data
data(spacemix.location.data)

# perform Procrustes superimposition of 
#  geogenetic locations onto sampling coordinates
proc.geogen.coords <- spacemix.procrustes(X = spacemix.location.data$sample.coords,
						Y = spacemix.location.data$geogen.coords,
 						k = nrow(spacemix.location.data$sample.coords),
 						admix.source.locs = NULL,
 						option = 1)
# perform Procrustes superimposition of 
#  admixture locations into same frame of
#  reference as the superimposition of the
#  geogenetic locations onto the sampling coordinates
proc.admix.coords <- spacemix.procrustes(X = spacemix.location.data$sample.coords,
						Y = spacemix.location.data$geogen.coords,
 						k = nrow(spacemix.location.data$sample.coords),
 						admix.source.locs = spacemix.location.data$admix.coords,
 						option = 2)
par(mfrow=c(1,3))
	plot(spacemix.location.data$sample.coords,
			pch=20,xlab='',ylab='',main="Sample coordinates",
		col=spacemix.location.data$pop.colors)
	plot(spacemix.location.data$geogen.coords,
		pch=20,xlab='',ylab='',main="Raw geogenetic and admixture coordinates",
		col=spacemix.location.data$pop.colors)
	points(spacemix.location.data$admix.coords,
		col=spacemix.location.data$admix.colors,pch=8)
	plot(proc.geogen.coords,pch=20,xlab='',ylab='',
	main="Procrustes superimposition\n of geogenetic and admixture coordinates",
	col=spacemix.location.data$pop.colors)
	points(proc.admix.coords,col=spacemix.location.data$admix.colors,pch=8)

gbradburd/SpaceMix documentation built on Oct. 19, 2022, 12:43 p.m.