View source: R/pipeline_functions.R
draw.3D | R Documentation |
draw.3D
creates a 3D plot to visualize the sample clustering result.
draw.3D(
X,
Y,
Z,
class_label,
xlab = "PC1",
ylab = "PC2",
zlab = "PC3",
legend_cex = 0.8,
main = "",
point_cex = 1,
legend_pos = "topright",
legend_ncol = 1,
use_color = NULL,
pre_define = NULL,
...
)
X |
a vector of numerics, the x coordinates of points in the plot. If user would like to create a PCA biplot, this parameter should be the first component. |
Y |
a vector of numerics, the y coordinates of points in the plot. If user would like to create a PCA biplot, this parameter should be the second component. |
Z |
a vector of numerics, the z coordinates of points in the plot. If user would like to create a PCA biplot, this parameter should be the third component. |
class_label |
a vector of characters, labels or categories of samples. The vector name should be sample names. |
xlab |
character, the label for x-axis. Default is "PC1". |
ylab |
character, the label for y-axis. Default is "PC2". |
zlab |
character, the label for z-axis. Default is "PC3". |
legend_cex |
numeric, giving the amount by which the text of legend should be magnified relative to the default. Default is 0.8. |
main |
character, an overall title for the plot. Default is "". |
point_cex |
numeric, giving the amount by which the size of the data points should be magnified relative to the default. Default is 1. |
legend_pos |
character, the position of legend. Default is "topright". |
legend_ncol |
integer, number of columns of legend. Default is 1. |
use_color |
a vector of color codes, colors to be assigned to each member of display label. Default is brewer.pal(9, 'Set1'). |
pre_define |
a vector of characters, pre-defined color codes for a certain input (e.g. c("blue", "red") with names c("A", "B")). Default is NULL. |
... |
other paramters used in |
Return a logical value. If TRUE, the plot has been created successfully.
mat1 <- matrix(rnorm(2000,mean=0,sd=1),nrow=100,ncol=20)
rownames(mat1) <- paste0('Gene',1:nrow(mat1))
colnames(mat1) <- paste0('Sample',1:ncol(mat1))
pc <- stats::prcomp(t(mat1))$x
pred_label <- kmeans(pc,centers=4)$cluster ## this can use other cluster results
draw.3D(X=pc[,1],Y=pc[,2],Z=pc[,3],class_label=pred_label)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.