View source: R/beta_diversity_3d.R
beta_diversity_3d | R Documentation |
This is a wrapper function for plot_ly
with the
"scatterplot3d" option. It can be used on a data frame, or directly on the
output of phyloseq::ordinate
with the NMDS or PCoA method
(or vegan::metaMDS
or ape::pcoa
, respectively),
or on the output of limma::plotMDS
.
Default categorical colors are from dittoSeq.
beta_diversity_3d(x, ...) ## S3 method for class 'data.frame' beta_diversity_3d(x, axes = colnames(x)[1:3], color.column = colnames(x)[4], label.column = colnames(x)[5], color.key = NULL, ...) ## S3 method for class 'monoMDS' beta_diversity_3d(x, metadata, color.column, label.column = NULL, color.key = NULL, ...) ## S3 method for class 'pcoa' beta_diversity_3d(x, metadata, color.column, label.column = NULL, color.key = NULL, ...) ## S3 method for class 'MDS' beta_diversity_3d(x, metadata, color.column, label.column = NULL, color.key = NULL, ...)
x |
A data frame, |
axes |
If |
color.column |
The name of a numeric or categorical column to be used for coloring points.
This column should be found in |
label.column |
The name of a character column to be used for labeling points.
This column should be found in |
color.key |
If |
metadata |
A data frame of sample metadata, in the same order as |
... |
Optional arguments passed to |
A "plotly"
object.
Lindsay Clark
## Not run: # Perform NMDS with Bray distance ord_mfiber_prop1a <- ordinate(ps_mfiber_prop, "NMDS", "bray", k = 3) beta_diversity_3d(ord_mfiber_prop1a, sample_data(ps_mfiber_prop), "TRT", "Label") # NMDS with UniFrac distance (ordinate won't let you adjust k) dist_mfiber_4 <- phyloseq::distance(ps_mfiber_prop, "unifrac") ord_mfiber_prop4a <- vegan::metaMDS(dist_mfiber_4, k = 3) beta_diversity_3d(ord_mfiber_prop4a, sample_data(ps_mfiber_prop), "TRT", "Label") # MDS of gene expression with limma mds1 <- plotMDS(logCPM.filt, top = 5000) beta_diversity_3d(mds1, metadata = d.filt$samples, color.column = "Group") # Changing title and axis labels, manually setting colors, and saving mfiber_colors <- c(CO = "magenta", BP = "black", MF = "turquoise", FOS = "orange", RS = "skyblue", TP = "green") p1 <- beta_diversity_3d(ord_mfiber_prop1a, sample_data(ps_mfiber_prop), "TRT", "Label", color.key = mfiber_colors) %>% plotly::layout(title = "NMDS with Bray distance", scene = list(xaxis = list(title = "Axis 1"), yaxis = list(title = "Axis 2"), zaxis = list(title = "Axis 3"))) htmlwidgets::saveWidget(partial_bundle(p1), file = "results/NMDS_Bray_MFiber_plotly.html") ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.