View source: R/pipeline_functions.R
draw.2D.interactive | R Documentation |
draw.2D.interactive
creats a 2D plot to visualize the sample clustering result with interactive mode realized by plotly.
draw.2D.interactive(
X,
Y,
sample_label = NULL,
color_label = NULL,
shape_label = NULL,
xlab = "PC1",
ylab = "PC2",
main = "",
point_cex = 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. |
sample_label |
a vector of characters, name of samples to be displayed on the figure. |
color_label |
a vector of characters, labels used to define the point color. |
shape_label |
a vector of characters, labels used to define the point shape. |
xlab |
character, the label for x-axis. Default is "PC1". |
ylab |
character, the label for y-axis. Default is "PC2". |
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. |
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. |
Return the plotly class object for interactive visualization.
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.2D.interactive(X=pc[,1],Y=pc[,2],
sample_label=rownames(pc),
color_label=pred_label,
pre_define = c('1'='blue','2'='red','3'='yellow','4'='green'))
draw.2D.interactive(X=pc[,1],Y=pc[,2],
sample_label=rownames(pc),
shape_label=pred_label)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.