50% off: Unlimited data and AI learning.
State of Data and AI Literacy Report 2025

tidyMicro (version 1.47)

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,
  dist_method = "euclidean",
  type = "PCoA",
  plot_scores = FALSE,
  pch = 16,
  cex.axis = 1,
  cex.lab = 1,
  cex = 1,
  main = NULL,
  subtitle = NULL,
  scalewt = TRUE,
  print.legend = TRUE,
  legend.title = "Time Points",
  legend.position = "right"
)

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)

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

pch

Plotting "character", i.e. symbol to use.

cex.axis

Options for scatterplot3d

cex.lab

Options for scatterplot3d

cex

Options for scatterplot3d

main

Plot title

subtitle

Plot subtitle

scalewt

Logical; center and scale OTU table, recommended

print.legend

Logical; print plot legend

legend.title

Title for plot legend. Ignored if print.legend = FALSE

legend.position

'x' argument in legend

Details

Requires that you have separate columns for subject ID and time point. Data must be complete across time points. The function will automatically filter out incomplete cases with a warning message.

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

References

vegdist

Examples

Run this code
# NOT RUN {
data(bpd_phy); data(bpd_cla); data(bpd_ord); data(bpd_fam); data(bpd_clin)
otu_tabs = list(Phylum = bpd_phy, Class = bpd_cla,
Order = bpd_ord, Family = bpd_fam)

set <- tidy_micro(otu_tabs = otu_tabs, clinical = bpd_clin)

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

Run the code above in your browser using DataLab