# #——包括= FALSE --------------------------------------------------------- knitr: opts_chunk美元集(错误= FALSE,警告= FALSE,消息= FALSE,崩溃= TRUE,评论 = "#>" ) 图书馆(“BiocStyle ") ## ---- 设置 -------------------------------------------------------------------- 库(densvis)图书馆(Rtsne)库(uwot)库(ggplot2) theme_set (theme_bw ()) set.seed(14) # #——数据 --------------------------------------------------------------------- 数据< - data.frame (x = c (rnorm (1000 5), rnorm (1000 0, 0.2)), y = c (rnorm (1000 5), rnorm(1000 0, 0.2)),类= c(代表(“1级”,1000年),代表(“二班”,1000)))ggplot () + aes(数据[1],数据[2],颜色=数据元类)+ geom_point (pch = 19) + scale_colour_discrete (name =“集群”)+ ggtitle(“原始坐标 ") ## ---- run-densne --------------------------------------------------------------- fit1 < - densne(数据[1:2],dens_frac = 0.5, dens_lambda = 0.5) ggplot () + aes (fit1 [1], fit1[2],颜色=数据元类)+ geom_point (pch = 19) + scale_colour_discrete (name = "类")+ ggtitle(“Density-preserving t-SNE”)+实验室(x =“t-SNE组件1”,2 y = " t-SNE组件 ") ## ---- run-tsne ----------------------------------------------------------------- fit2 < - Rtsne(数据[1:2])ggplot () + aes (fit2 $ Y [1], fit2 $ Y[2],颜色=数据元类)+ geom_point (pch = 19) + scale_colour_discrete (name = "类")+ ggtitle(“标准t-SNE”)+实验室(x = t-SNE组件1,Y =“t-SNE组件2 ") ## ---- run-densmap -------------------------------------------------------------- fit1 < - densmap(数据[1:2],dens_frac = 0.5,dens_lambda = 0.5) ggplot () + aes (fit1 [1], fit1[2],颜色=数据元类)+ geom_point (pch = 19) + scale_colour_discrete (name = "类")+ ggtitle(“Density-preserving UMAP”)+实验室(x = UMAP组件1,y =“UMAP组件2 ") ## ---- run-umap ----------------------------------------------------------------- fit2 < - umap(数据[1:2])ggplot () + aes (fit2 [1], fit2 [2],颜色=数据元类)+ geom_point (pch = 19) + scale_colour_discrete (name = "类")+ ggtitle(“标准UMAP”)+实验室(x = UMAP组件1,y =“UMAP组件2 ") ## ----------------------------------------------------------------------------- sessionInfo ()