简体   繁体   中英

Error in hclust(d, method = method) : NA/NaN/Inf in foreign function call (arg 11)

I am really new to RStudio and desperately trying to get to grips with it all, so I apologise if this is a silly question. I am trying to generate a heatmap for my RNA Seq Data set using pheatmap, however I am coming up again a number of errors. My data looks like this:

在此处输入图片说明

And I am attempting to use the code below, which has been taken from another user.

heatmap code

pheatmap(
  mat               = mydata,
  color             = inferno(10),
  border_color      = black,
  show_colnames     = FALSE,
  show_rownames     = FALSE,
  annotation_col    = mydata$sample_1,
  annotation_colors = mydata$value_1,
  drop_levels       = TRUE,
  fontsize          = 10,
  main              = "Default Heatmap")

When I input this into the system I get this error: Error in hclust(d, method = method) : NA/NaN/Inf in foreign function call (arg 11) In addition: Warning messages: 1: In dist(mat, method = distance) : NAs introduced by coercion 2: In dist(mat, method = distance) : NAs introduced by coercion

I have tried looking for the answer, but it very hard to relate it to my data. I've looked at my dataframe, which seems to be the go to response for this type of error, however there does not appear to be anything obvious that is causing my issues. I have given you my dataframe below so you can see what I am talking about. If I have missed anything please let me know.

'data.frame':   6436 obs. of  15 variables:  
$ test_id          : Factor w/ 1517 levels "ABCA6","ABCA8",..: 273 370 273    
$ sample_1       : Factor w/ 5 levels "BAMBI_kd","BAMBI_PPARg_kd",..: 1 2 5    
$ sample_2         : Factor w/ 5 levels "BAMBI_kd","BAMBI_PPARg_kd",..: 3 3     
$ status           : Factor w/ 1 level "OK": 1 1 1 1 1 1 1 1 1 1 ...  
$ value_1          : num  0.0872 0.0894 0.098 0.099 0.099 ... 
$ value_2          : num  0.482 0.475 0.482 1.224 1.506 ...  
$ log2.fold_change.: num  2.47 2.41 2.3 3.63 3.93 ...  
$ test_stat       : num  2.37 1.86 2.32 3.45 3.74 ...  
$ p_value          : num  0.00045 0.0006 0.0006 0.00005

Thank you and I look forward to your responses.

I'm not sure if this applies when creating heatmaps, but I got this error when attempting to create a visual correlation matrix using rcorr() and corrplot(). I had no NA, NaN or Inf but realized that one of my variables had only 0's (or all the same values). Fixed by filtering that variable from the data set.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM