I did a tSNE with the function Rtsne
. Now I want to visualize it. I have predefined groups. Like the Species in iris. I want to color the points by this groups. This does not help me Coloring the points by category in R.
So far, i did this
iris <- unique(iris)
iris_num <- iris[ ,1:4]
iris_matrix <- as.matrix(iris_num)
tsne_out_iris <- Rtsne(iris_matrix,perplexity = 15)
tsne_plot_iris <- data.frame(x = tsne_out_iris$Y[, 1],y = tsne_out_iris$Y[, 2])
plot <- plot(tsne_plot_iris)
tsne_iris <- ggplot(tsne_plot_iris) + ggtitle("iris, perplexity equals 15")
tsne_plot_iris <- as.numeric(unlist(tsne_plot_iris))
tsne_iris2 <- ggplot(tsne_plot_iris + geom_point(aes(x=x,y=y)) + ggtitle("iris, perplexity equals 15") + aes(color=iris$Species))
plot
gives me a plot with black dots. tsne_iris
and tsne_iris2
give me an empty plot, without anything, not even the title.