View source: R/plot_embedding.R
plot_embedding | R Documentation |
Plot selected PCs from an embedding
plot_embedding( embedding, xpc = 1, ypc = xpc + 1, plot_title = paste0("Dim", xpc, " by Dim", ypc), color_vec = NULL, color_title = NULL, ellipse_vec = NULL, facet_vec = NULL, ptsize = 0.8, saveplot = FALSE, plotfn = paste(plot_title, xpc, sep = "_"), showplot = TRUE, returngg = FALSE, color_pal_vec = NULL, dimname = "Dim" )
embedding |
matrix or other tabular format where columns correspond to PCs and rows correspond to cells (entries). |
xpc |
int; which PC to put on the x-axis (defaults to 1) |
ypc |
int; which PC to put on the y-axis (defaults to the one after |
plot_title |
char; title of plot (defaults to titling based on |
color_vec |
vector; length should correspond to the number of rows in embedding, and each element of the vector classifies that cell (entry) in the embedding to that particular class, which will be colored the same. (e.g., this could be indicating which batch each cell is from) |
color_title |
char; what attribute the colors represent |
ellipse_vec |
vector; length should correspond to the number of rows in embedding, and each element of the vector classifies that cell (entry) in the embedding to that particular class, and elements of the same class will be circled in an ellipse. (e.g., this could be indicating the cell type or cell line; works best for attributes intended to be compact) |
facet_vec |
vector; length should correspond to the number of rows in embedding, and each element of the vector classifies that cell (entry) in the embedding to that particular class. Plot will be faceted by this attribute. |
ptsize |
numeric; the size of the points as passed to |
saveplot |
boolean; whether or not to save the plot, defaults |
plotfn |
char; what the filename is to be called. (defaults to making a name based on |
showplot |
boolean; whether or not to show the plot, defaults |
returngg |
boolean; whether or not to return a |
color_pal_vec |
char; hex codes for the color palette to be used. Default is to use the ggthemes few for plots with less than 9 colors, and to use/"stretch" pals polychrome if more colors are needed. |
dimname |
char; the name of the dimensions. defaults to "Dim" |
default none; options to display plot (showplot
), save plot (saveplot
), and/or return ggplot2
object (returngg
)
listofmats <- list(matrix(sample(seq(0,20,1),1000,replace = TRUE),nrow = 20), matrix(sample(seq(0,20,1),1000,replace = TRUE),nrow = 20)) corralm_obj <- corralm(listofmats, ncomp = 5) embed_mat <- corralm_obj$v cell_type_vec <- sample(c('type1','type2','type3'),100,replace = TRUE) plot_embedding(embedding = embed_mat, xpc = 1, plot_title = 'corralm plot', color_vec = cell_type_vec, color_title = 'cell type', saveplot = FALSE) # or, call directly on the corralm object plot_embedding(corralm_obj)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.