如果有人可以帮助我使用R绘制KNN t-SNE,我将不胜感激。我尝试了一些教程,但是我所要做的只是https://imgur.com/EBizwKl,我正在尝试着一些东西像这样https://imgur.com/IidYp6d。预先感谢。
可以从here
下载数据集Current code is :
#load libraries
library(caret)
library(Rtsne)
#load dataset
data=read.delim("F:/Dropbox/NRI/10X_expression_data.tab ", header = T, stringsAsFactors = F, sep = "\t")
number_of_dim <- dim(data)
data_tsne <- data[2:number_of_dim[1],2:number_of_dim[2]]
#run t-SNE
set.seed(9)
tsne_model_1 = Rtsne(as.matrix(data_tsne), verbose=TRUE, check_duplicates=FALSE, pca=TRUE, perplexity=30, theta=0.5, dims=2)
d_tsne_1 = as.data.frame(tsne_model_1$Y)
## plotting the results without clustering
ggplot(d_tsne_1, aes(x=V1, y=V2)) +
geom_point(size=0.25) +
guides(colour=guide_legend(override.aes=list(size=6))) +
xlab("") + ylab("") +
ggtitle("t-SNE") +
theme_light(base_size=20) +
theme(axis.text.x=element_blank(),
axis.text.y=element_blank()) +
scale_colour_brewer(palette = "Set2")