Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

export_to_mvmapper

Export analysis for mvmapper visualisation


Description

mvmapper is an interactive tool for visualising outputs of a multivariate analysis on a map from a web browser. The function export_to_mvmapper is a generic with methods for several standard classes of analyses in adegenet and ade4. Information on individual locations, as well as any other relevant data, is passed through the second argument info. By default, the function returns a formatted data.frame and writes the output to a .csv file.

Usage

export_to_mvmapper(x, ...)

## Default S3 method:
export_to_mvmapper(x, ...)

## S3 method for class 'dapc'
export_to_mvmapper(x, info, write_file = TRUE, out_file = NULL, ...)

## S3 method for class 'dudi'
export_to_mvmapper(x, info, write_file = TRUE, out_file = NULL, ...)

## S3 method for class 'spca'
export_to_mvmapper(x, info, write_file = TRUE, out_file = NULL, ...)

Arguments

x

The analysis to be exported. Can be a dapc, spca, or a dudi object.

...

Further arguments to pass to other methods.

info

A data.frame with additional information containing at least the following columns: key (unique individual identifier), lat (latitude), and lon (longitude). Other columns will be exported as well, but are optional.

write_file

A logical indicating if the output should be written out to a .csv file. Defaults to TRUE.

out_file

A character string indicating the file to which the output should be written. If NULL, the file used will be named 'mvmapper_data_[date and time].csv'

Details

Value

A data.frame which can serve as input to mvmapper, containing at least the following columns:

  • key: unique individual identifiers

  • PC1: first principal component; further principal components are optional, but if provided will be numbered and follow PC1.

  • lat: latitude for each individual

  • lon: longitude for each individual

In addition, specific information is added for some analyses:

  • spca: Lag_PC columns contain the lag-vectors of the principal components; the lag operator computes, for each individual, the average score of neighbouring individuals; it is useful for clarifying patches and clines.

  • dapc: grp is the group used in the analysis; assigned_grp is the group assignment based on the discriminant functions; support is the statistical support (i.e. assignment probability) for assigned_grp.

Author(s)

Thibaut Jombart thibautjombart@gmail.com

See Also

Examples

# An example using the microsatellite dataset of Dupuis et al. 2016 (781
# individuals, 10 loci, doi: 10.1111/jeb.12931)

# Reading input file from adegenet

input_data <- system.file("data/swallowtails.rda", package="adegenet")
data(swallowtails)


# conducting a DAPC (n.pca determined using xvalDapc, see ??xvalDapc)

dapc1 <- dapc(swallowtails, n.pca=40, n.da=200)


# read in swallowtails_loc.csv, which contains "key", "lat", and "lon"
# columns with column headers (this example contains additional columns
# containing species identifications, locality descriptions, and COI
# haplotype clades)

input_locs <- system.file("files/swallowtails_loc.csv", package = "adegenet")
loc <- read.csv(input_locs, header = TRUE)


# generate mvmapper input file, automatically write the output to a csv, and
# name the output csv "mvMapper_Data.csv"
out_dir <- tempdir()
out_file <- file.path(out_dir, "mvMapper_Data.csv")

out <- export_to_mvmapper(dapc1, loc, write_file = TRUE, out_file = out_file)

adegenet

Exploratory Analysis of Genetic and Genomic Data

v2.1.3
GPL (>= 2)
Authors
Thibaut Jombart [aut] (<https://orcid.org/0000-0003-2226-8692>), Zhian N. Kamvar [aut, cre] (<https://orcid.org/0000-0003-1458-7108>), Caitlin Collins [ctb], Roman Lustrik [ctb], Marie-Pauline Beugin [ctb], Brian J. Knaus [ctb], Peter Solymos [ctb], Vladimir Mikryukov [ctb], Klaus Schliep [ctb], Tiago Maié [ctb], Libor Morkovsky [ctb], Ismail Ahmed [ctb], Anne Cori [ctb], Federico Calboli [ctb], RJ Ewing [ctb], Frédéric Michaud [ctb], Rebecca DeCamp [ctb], Alexandre Courtiol [ctb] (<https://orcid.org/0000-0003-0637-2959>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.