View source: R/spinning_3d_pca_link.R
spinning_3d_pca_link | R Documentation |
Plot PCA scores in 3d space. Link to locally saved 3d html plot gets made and opens automatically in browser after function is run.
spinning_3d_pca_link(
scores,
info.type,
X = PC1,
Y = PC2,
Z = PC3,
title = "3d PCA plot",
colorlst = NULL,
marker = NULL
)
scores; |
the output from PCA_from_file that has been read in using read.delim - first column includes the samples |
info.type; |
info.type column is in the same order as samples in scores and is a factor. Points will be colored by info.type. It is recommended to make info.type a new column in the scores file. |
X; |
default is PC1 |
Y; |
default is PC2 |
Z; |
default is PC3 |
title; |
title name for 3d plot and the name that is used in saving the html file |
colorlst; |
optional: list of colors that correspond to the unique(info.type) |
marker; |
optional: can use this parameter to adjust size, shape, opacity of points |
html link to 3d Spinning PCA plot
my_PCA_scores <- read.delim("my_PCA_scores.txt")
my_PCA_scores$type <- info$type[match(my_PCA_scores$Score, info$sample)]
my_PCA_scores$type <- factor(my_PCA_scores$type, levels = unique(my_PCA_scores$type))
spinning_3d_pca_link(scores = my_PCA_scores, info.type = my_PCA_scores$type, X = my_PCA_scores$PC1, Y = my_PCA_scores$PC2, Z = my_PCA_scores$PC3, title = "3d PCA plot", colorlst=c("red", "dodgerblue", "pink", "orange"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.