swarm_space: Create a Swarm Space

View source: R/swarm_space.R

swarm_spaceR Documentation

Create a Swarm Space

Description

This function runs a PCA (Principal component analysis) or a t-SNE (t-distributed Stochastic Neighbor Embedding) over the global and pairwise metrics of collective motion per each event to produce a swarm space. The PCA is computed with the stats::prcomp function and the t-SNE with the Rtsne::Rtsne function.

Usage

swarm_space(
  metrics_data,
  space_type = "pca",
  event_dur_limit = NA,
  tsne_rand_seed = NA,
  tsne_perplexity = 25
)

Arguments

metrics_data

A dataframe with metrics of collective motion per event.

space_type

A string, stating the choice between PCA ("pca") and t-SNE ("tsne"), default = "pca".

event_dur_limit

Numeric, capturing an event duration value in seconds. Used to filter out events that are shorter that this value. Default = NA, no filtering is applied.

tsne_rand_seed

Numeric, the random seed for the t-SNE analysis, to ensure reproducibility. Default = NA, but a value should be given if the t-SNE analysis is selected.

tsne_perplexity

Numeric, the perplexity parameter for the t-SNE analysis. Usually between 10-50, default = 25.

Value

A list with 3 elements: a dataframe representing the swarm space (x and y coordinates per event of each species), a reference dataframe (ref) including all the additional event information from the input metric data dataframe, a dataframe for the t-SNE analysis (tsne_setup) that includes the input parameters used, and a list for the PCA analysis (pca) with the output of the stats::prcomp command.

Author(s)

Marina Papadopoulou m.papadopoulou.rug@gmail.com

See Also

group_metrics, pairwise_metrics, nn_metrics, col_motion_metrics

Examples


data(multi_species_metrics)
ss <- swarm_space(multi_species_metrics)


swaRmverse documentation built on May 29, 2024, 8:57 a.m.