1

I am trying to plot heatmap in linux.

this is the script i have written:

#!/bin/R

setwd("~/scratch/peerfactors")

library(readr)

library(png)

#install.packages("Pheatmap")

library(pheatmap)

r_80 <- read_table2("GVDS_predixcan_n80.txt")

d <- r_80$IID

m <- as.matrix(r_80[, -1])
 rownames(m) <- d 
m1 <- m[,2:120]
m1 <- as.data.frame(m1)
library(pheatmap)
pheatmap(m, cutree_rows = 4)

But it gives an error:

Error in .External2(C_dataviewer, x, title) : unable to start data viewer

Calls: View

In addition: Warning message:

In View(m) : unable to open display

Execution halted

    dput(m1[1:5,1:5])

structure(list(ENSG00000183307.3 = c(" 9.834121e-02", "-2.178226e-01", 
" 8.384525e-02", "-5.512204e-02", "-6.575162e-02"), ENSG00000237438.1 = c("-5.037736e-01", 
"-4.624093e-01", "-5.317209e-01", "-2.272977e-01", "-1.035980e-01"
), ENSG00000015475.14 = c("-2.714692e-01", "-2.925210e-01", " 1.571337e-01", 
" 8.176208e-02", " 1.216378e-01"), ENSG00000093100.12 = c("-1.730031e-01", 
" 9.960370e-02", "-1.026636e-01", " 1.027736e-01", "-8.116346e-02"
), ENSG00000243156.2 = c("-0.5487500919", "-0.0768463310", "-0.3728799856", 
"-0.0511935902", "-0.5747430589")), row.names = c("HG00096", 
"HG00097", "HG00099", "HG00100", "HG00101"), class = "data.frame")
Phil
  • 7,287
  • 3
  • 36
  • 66
Rhea Bedi
  • 123
  • 6
  • So it's not plotting the heat map you are struggling with, but `View`? If you ignore this line, can you still draw the heat map? Why do you need to `View` the data first? If you want to see the raw data you could just `print(m)` – Allan Cameron Apr 25 '22 at 22:33
  • pheatmap(m1, cutree_rows = 4) Error in cut.default(x, breaks = breaks, include.lowest = T) : 'x' must be numeric Its giving me error when I try to use pheatmap command – Rhea Bedi Apr 25 '22 at 23:30
  • Spelling? Pheatmap != pheatmap – IRTFM Apr 26 '22 at 00:46
  • yes, i typed pheatmap. in this i wrote capital P. – Rhea Bedi Apr 26 '22 at 01:03

1 Answers1

1

Two problems: spelling of pheatmap and that character class of the values in the dataframe: try this:

m1[] <- lapply(m1, as.numeric)
pheatmap(m1, cutree_rows = 4)

enter image description here

IRTFM
  • 258,963
  • 21
  • 364
  • 487