rpvclust

applying the pvclust R function to a precomputed dist object


I'm using R to perform an hierarchical clustering. As a first approach I used hclust and performed the following steps:

  1. I imported the distance matrix
  2. I used the as.dist function to transform it in a dist object
  3. I run hclust on the dist object

Here's the R code:

distm <- read.csv("distMatrix.csv")
d <- as.dist(distm)
hclust(d, "ward")

At this point I would like to do something similar with the function pvclust; however, I cannot because it's not possible to pass a precomputed dist object. How can I proceed considering that I'm using a distance not available among those provided by the dist function of R?


Solution

  • It's not clear to me whether you only have a distance matrix, or you computed it beforehand. In the former case, as already suggested by @Vincent, it would not be too difficult to tweak the R code of pvclust itself (using fix() or whatever; I provided some hints on another question on CrossValidated). In the latter case, the authors of pvclust provide an example on how to use a custom distance function, although that means you will have to install their "unofficial version".