PlotTSNE {scAlign} | R Documentation |
Helper function to plot aligned data from the results of running scAlign().
PlotTSNE( object, data.use, labels.use = "scAlign.labels", cols = NULL, title = "", legend = "none", point.size = 3, seed = 1234, ... )
object |
scAlign class object with aligned data |
data.use |
Specifies which alignment results to use. |
labels.use |
Specifies "dataset" or "celltype" labeling from object meta.data. |
cols |
Colours for plot |
title |
ggplot title |
legend |
Determines if legend should be drawn |
point.size |
Size of geom_point |
seed |
Random seed for reproducability |
... |
Additional arguments to Rtsne function |
labels |
Object labels |
ggplot2 object
library(SingleCellExperiment) ## Input data, 1000 genes x 100 cells data = matrix( rnorm(1000*100,mean=0,sd=1), 1000, 100) rownames(data) = paste0("gene", seq_len(1000)) colnames(data) = paste0("cell", seq_len(100)) age = c(rep("young",50), rep("old",50)) labels = c(c(rep("type1",25), rep("type2",25)), c(rep("type1",25), rep("type2",25))) ctrl.data = data[,which(age == "young")] stim.data = data[,which(age == "old")] ## Build the SCE object for input to scAlign using Seurat preprocessing and variable gene selection ctrlSCE <- SingleCellExperiment( assays = list(scale.data = data[,which(age == "young")])) stimSCE <- SingleCellExperiment( assays = list(scale.data = data[,which(age == "old")])) ## Build the scAlign class object and compute PCs scAlignHSC = scAlignCreateObject(sce.objects = list("YOUNG"=ctrlSCE, "OLD"=stimSCE), labels = list(labels[which(age == "young")], labels[which(age == "old")]), pca.reduce = FALSE, cca.reduce = FALSE, project.name = "scAlign_Kowalcyzk_HSC") ## Run scAlign with high_var_genes scAlignHSC = scAlign(scAlignHSC, options=scAlignOptions(steps=100, log.every=100, norm=TRUE, early.stop=FALSE), encoder.data="scale.data", supervised='none', run.encoder=TRUE, run.decoder=FALSE, log.results=FALSE, log.dir=file.path(tempdir(),'gene_input'), device="CPU") ## Plot alignment for 3 input types example_plot = PlotTSNE(scAlignHSC, "ALIGNED-GENE", "scAlign.labels", title="scAlign-Gene", perplexity=30)