0

I would appreciate it if someone could help me plot a KNN t-SNE using R. I've tried following some tutorials but all I've gotten to is https://i.stack.imgur.com/tpdtr.jpg, I'm trying to get to something like this https://i.stack.imgur.com/1cfwE.jpg. Thanks in advance.

the dataset can be downloaded from 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")
  • https://stackoverflow.com/questions/44837536/how-to-use-ggplot-to-plot-t-sne-clustering and https://stackoverflow.com/questions/51120412/adding-text-annotation-to-a-clustering-scatter-plot-tsne – GordonShumway Jul 05 '18 at 18:06
  • So you just don't like the results from your tSNE analysis? Different data will give different plots. What specifically are you trying to change? When asking for help, you should include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Jul 05 '18 at 18:11
  • Appreciate the response, still a little new to R and genuinely interested in learning. The thing is they are both from the same data. I am just wondering how do they get to their image. If its from the same data, it should just be tweaking the code parameters. Was hoping someone with experience could shed some light. Edit: Is there a way to make them more spread out? – ItchyHands Jul 05 '18 at 18:24

0 Answers0