Learn R Programming

tidyMicro (version 1.43)

pca_3d: Create 3d PCA plots

Description

Create three dimensional PCA plots from longitudinal data or multiple omics data sets.

Usage

pca_3d(
  micro_set,
  table,
  time_var,
  subject,
  y = clr,
  modes = c("AC", "BA", "CB"),
  dist_method = "euclidean",
  type = "PCoA",
  plot_scores = FALSE,
  n_compA,
  n_compB,
  n_compC,
  cex.axis = 1,
  cex.lab = 1,
  main = NULL,
  subtitle = NULL,
  scalewt = TRUE
)

Arguments

micro_set

A tidy_micro data set

table

OTU table of interest

time_var

The time point variable column name in your tidi_MIBI set

subject

The subject variable column name in your tidi_MIBI set

y

Value to calculate principle components or coordinates on. Default is centered log ratio (recommended)

modes

Components of the data to focus on: time, subjects, bacteria, etc. "AC" by default

dist_method

Dissimilartiy method to be calculated by vegdist. Euclidean by default

type

"PCA" for principle components or "PCoA" to calculated dissimilarity matrix using vegdist

plot_scores

Plot the scores instead of the principle components

n_compA

The number of components along first axis. See details

n_compB

The number of components along second axis. See details

n_compC

The number of components along third axis. See details

cex.axis

Options for scatterplot3d

cex.lab

Options for scatterplot3d

main

Plot title

subtitle

Plot subtitle

scalewt

Logical; center and scale OTU table, recommended

Details

Requires that you have columns for subject name and time point. Data must be complete across time points. The function will filter out inconsistent subjects

When type = "PCoA" the component matrices must be specified prior to the optimization. This is handled automatically.

If n_compA, n_compB, and n_compC aren't specified they will default to the number of complete subjects, the number of taxa, and the number of time points, respectively. This slows down performance slightly, but will not change the results.

References

vegdist

Examples

Run this code
# NOT RUN {
data(phy); data(cla); data(ord); data(fam); data(clin)

otu_tabs = list(Phylum = phy, Class = cla, Order = ord, Family = fam)
set <- tidy_micro(otu_tabs = otu_tabs, clinical = clin)

set %>% pca_3d(table = "Family", time_var = day, subject = study_id)
# }

Run the code above in your browser using DataLab