View source: R/pipeline_functions.R
draw.2D.ellipse | R Documentation |
draw.2D.ellipse
creates a 2D plot with an ellipse drawn around each cluster to visualize the sample clustering result.
draw.2D.ellipse(
X,
Y,
class_label,
xlab = "PC1",
ylab = "PC2",
legend_cex = 0.8,
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 creat 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 creat a PCA biplot, this parameter should be the second 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". |
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. |
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 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 <- stats::kmeans(pc,centers=4)$cluster ## this can use other cluster results
draw.2D.ellipse(X=pc[,1],Y=pc[,2],class_label=pred_label)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.