This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Multiple Files For Reading,Heatmap And Saving

I have multiple files to read and also do heatmap after which the outputs will be saved. Somehow, there is a problem(s) with my code below and I can't figure out why it is not working. Files: mxn.dat, scu.dat, emun.dat, ser.dat

files <- list.files(pattern=".dat")
for (i in length(files)){
data <-read.table(files[i],row.names=1,header=T,sep='\t')
      for in length(files){
      png('i.png') 
      pheatmap(t(data[i]), cellwidth = 32, cellheight = 14, fontsize = 5, show_colnames = T, cluster_cols = FALSE)
      dev.off()
      } 
}

Any help will be appreciated to get the code working.

Thanks

Rob

r

Please also post what kind of error you are getting !!!!

1 answer

not sure if code debugging questions would belong here vs stack exchange but I think your problem is the the png('i.png') line. you should replace it with png(paste0(i, ".png")) to prevent overwriting your pictures everytime (I assume that is the problem you are getting)

Log in to answer this question.