I have a data set of 100 high-dimension matrices, each describing the state of a vector field at a different time. My goal is to use t-SNE to visualize how this vector field evolves over time. However, while I think I understand the general process of t-SNE well enough, I'm having a lot of trouble figuring out whether the few different ways I can think of to go about this are valid, and I've been unable to find a source that explains the process of t-SNE both clearly enough and with enough detail to allow me to figure this out.

The t-SNE function in R seems to only take a single matrix as a data input. While I can easily compute a matrix that gives the average state of the vector field over time and plug this into the t-SNE function, I'm not sure if this makes sense, given that my goal is to visualize how the vector field evolves over time.

The other idea I can think of would be to create a data frame or matrix where I essentially have each column filled with all of the entries from one of the 100 original data matrices, so this way each row of this matrix will describe the evolution of the vector at one of the locations in the field over time. My concern with this approach however is that I'm also supposed to check whether the visualization reveals any spacial correlations in the vector field, and I'm worried that by turning each of the data matrices into a column I'll have locations that are right next to each other in the vector field being represented far apart from each other in the data, thus causing the t-SNE visualization to not accurately represent any potential spacial correlations.

Which of these two approaches, if either of them, seems to make the most sense in terms of 1) being a valid implimentation of t-SNE, and 2) meeting the goals of visualizing the evolution of the vector field over time while also observing any potential spacial correlations as well?

I apologize if I haven't explained this clearly enough. I'm not sure I actually understand exactly what the t-SNE process does, how it works, or why/when it should be used, so if someone could try to give me a brief explanation of that as well it would be much appreciated.


1 Answer 1


I would advise you to read this for an how-to-use-it-effectively guide.

For your specific needs, you can use the package Rtsne in the following way (note: if your data-sets are particularly large use the theta var accordingly).

# making t-SNE
tsne_list <- as.list(rep(NA, 100))
for(i in 1:100){
  xx <- matrix(rnorm(1000, sd = 1:100), nrow = 100, ncol = 10) # obiouvsly you put your matrix
  tsne_list[[i]] <- Rtsne(X = xx, dims = 2,
                          perplexity = 30, verbose = TRUE, max_iter = 350, theta = 0.5) # theta is speed/accuracy trade-off

# plotting t-SNE
for(i in 1:100){
  cat('Element', i, '\n')
  tsne_tmp <- tsne_list[[i]]
  print(ggplot() + geom_point(mapping = aes(x = tsne_tmp$Y[,1], y = tsne_tmp$Y[,2])))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.