R/DistConsensus.R

# Calculate the average of a set of distance matrix generated by t-SNE runs on the same data set
DistConsensus <- function(ts, adj=NA) {
  # ts    A list of tSNE matrix
  # adj   Rescaling factor, a vector of positive number with the same length of <ts> if not NA
  
  d0 <- dist(ts[[1]]);
  if (!identical(NA, adj) & length(adj)==length(ts)) d0 <- adj[1]*d0;
  
  for (i in 2:length(ts)) {
    d1 <- dist(ts[[i]]);
    if (!identical(NA, adj) & length(adj)==length(ts)) d1 <- adj[i]*d1;
    d0 <- d0+d1;
  };
  
  d0 <- d0/length(ts);
}; 
zhezhangsh/tSNEd documentation built on May 7, 2019, 8:19 a.m.