View source: R/pipeline_functions.R
draw.2D.text | R Documentation |
draw.2D.text
creates a 2D plot with sample names labeled, to visualize the sample clustering result.
draw.2D.text(
X,
Y,
class_label,
class_text = NULL,
xlab = "PC1",
ylab = "PC2",
legend_cex = 0.8,
main = "",
point_cex = 1,
text_cex = NULL,
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. |
class_label |
a vector of characters, labels or categories of samples. The vector name should be sample names. |
class_text |
a vector of characters, the user-defined sample names to label each data points in the plot.
If NULL, will use the names of |
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. |
text_cex |
numeric, giving the amount by which the text of |
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 <- kmeans(pc,centers=4)$cluster ## this can use other cluster results
draw.2D.text(X=pc[,1],Y=pc[,2],class_label=pred_label,
point_cex=5,text_cex=0.5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.