plot_trajectory: Plot trajectory for time series

View source: R/plot_trajectory.R

plot_trajectoryR Documentation

Plot trajectory for time series

Description

When looking at PCA-plots for different time series, we often want to study their evolution in time. This convenience functions does so by adding arrows between the samples in their chronological order in the PCA plot

Usage

plot_trajectory(
  time_series_list,
  distance = "bray",
  subset = names(time_series_list),
  label = FALSE,
  label_size = 3,
  color = NULL,
  linetype = NULL
)

Arguments

time_series_list

A list of OTU_time_series objects

distance

The name of any distance metric in vegdist

subset

Character, the subsets of time series to plot, based on the names of the list.

label

Logical, should each point be labelled with the time point?

label_size

Positive numeric, the font size of the label. Ignored if text=FALSE.

color

Character, the color mapping to use in the plot. Defaults to the time series

linetype

Character, the linetype mapping to be used. Defaults to solid

Details

The function utilzes the entire table to make the principal components, even if some data points are excluded. Note the columns 'time_series' and 'time_points' which are available in the object being returned.

Value

A ggplot object showing the trajectory in the two first principal components

Examples

library(micInt)
library(phyloseq)
data("seawater")
physeq_list <- subdivide_by_environment(seawater,"Reactor")
time_series <- lapply(physeq_list$phyloseq,OTU_time_series,
time_points = "Week")
plot_trajectory(time_series,distance = "euclidean")

AlmaasLab/micInt documentation built on April 1, 2022, 10:37 a.m.