Question: Simple Question About Pvclust In R
gravatar for Max
9.8 years ago by
Max10 wrote:

Hey, im a beginner to R and trying to run pvclust so as to test a cluster solution.

I've managed to load data and run the heirachical cluster, however the code i find online for running pvclust is constantly producing errors - just wondering if someone can point out where I'm going wrong...

here is my code (data already transposed)


transpose <- 
  read.table("C:/Users/Tim/University/Advanced Design and Data Analysis/Assignment/transposed.csv",
   header=TRUE, sep=",", na.strings="NA", dec=".", strip.white=TRUE)

hello <- hclust(dist(model.matrix(~-1 + 
   transpose)) , method= "ward")

plot(hello, main= "Cluster Dendrogram for Solution hello", xlab= 
  "Observation Number in Data Set transpose", sub="Method=ward; 

###all the abiove works fine, except the bwlo where i try the pvclust


fit <- pvclust(transpose, method.hclust="ward",

pvrect(fit, alpha=.95)

the error comes back=

> fit <- pvclust(transpose, method.hclust="ward",
+    method.dist="euclidean")
Warning in dist(t(x), method) : NAs introduced by coercion
Error in hclust(distance, method = method.hclust) : 
  NA/NaN/Inf in foreign function call (arg 11)
> plot(fit) 
Error in plot(fit) : object 'fit' not found
> pvrect(fit, alpha=.95)
Error in nrow(x$edges) : object 'fit' not found
R • 5.5k views
ADD COMMENTlink modified 16 months ago by Biostar ♦♦ 20 • written 9.8 years ago by Max10

put your csv in a web accessible location

ADD REPLYlink written 9.8 years ago by Jeremy Leipzig19k
gravatar for Neilfws
9.8 years ago by
Sydney, Australia
Neilfws49k wrote:

Basically, what the errors are telling you is this:

  1. When you run pvclust(), it calls a function named dist(). For some reason, this introduces NA (= missing values) into the data.
  2. pvclust() then uses the function hclust(), which fails because it cannot accept missing values.
  3. There is then no point running plot() or pvrect(), because the preceding operations failed to generate the object named 'fit', hence: object 'fit' not found.

So your problem is to figure out why "NAs introduced by coercion" is occurring. It's probably because the input data (transpose) is not in the correct form.

Can't provide much more help than that without seeing the CSV file. I suggest reading the package documentation (difficult for beginners, I know) to try and understand how each function works and what arguments it expects. For example, pvclust comes with some sample data which you can load using data(lung), examine to see how it is structured and run through some of the package functions. See the pvclust PDF.

Copy/paste from the Web is rarely a good idea when you don't understand the underlying processes.

ADD COMMENTlink modified 9.8 years ago • written 9.8 years ago by Neilfws49k

thanks you were right, the data needed to be represented as a table i.e., t(x). thanks, fixed

ADD REPLYlink written 9.8 years ago by Max10

You're welcome. Votes for answers are appreciated.

ADD REPLYlink written 9.8 years ago by Neilfws49k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 2460 users visited in the last hour