0

I'm trying to place heatmap and a ggplot next to each other, I tried:

plot_grid(heatmap(df.01mk)+stat_bin2d() + 
  scale_fill_gradient(trans="log10"), df0x+stat_bin2d() +
  scale_fill_gradient(trans="log10"), nrow= 1, ncol = 2)

But I get this: enter image description here

head(dput(df.01mk):

structure(c(1138L, 6L, 754L, 447L, 426L, 5L, 1L, 512L, 1024L, 
2964L, 220L, 866L, 1997L, 490L, 1951L, 14L, 2941L, 267L, 281L, 
666L, 1180L, 688L, 2363L, 411L, 8L, 5098L, 976L, 8939L, 543L, 
6L, 1133L, 386L, 551L, 222L, 2054L, 3156L, 11L, 1575L, 70L, 630L, 
8979L, 1011L, 42L, 2296L, 4610L, 2863L, 11763L, 1457L, 9L, 4589L, 
1027L, 5L, 682L, 467L, 466L, 4L, 0L, 504L, 1015L, 2797L, 241L, 
854L, 1861L, 461L, 2067L, 14L, 3088L, 243L, 308L, 659L, 1233L, 
717L, 2306L, 402L, 7L, 4931L, 901L, 8249L, 544L, 6L, 1196L, 389L, 
585L, 243L, 1874L, 3204L, 10L, 1490L, 65L, 618L, 9368L, 1081L, 
44L, 2199L, 4581L, 3137L, 11613L, 1482L, 9L, 4450L), .Dim = c(50L, 
2L), .Dimnames = list(c("1", "2", "3", "4", "5", "6", "7", "8", 
"9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", 
"20", "22", "23", "24", "25", "27", "28", "29", "30", "31", "32", 
"33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", 
"44", "45", "46", "47", "48", "49", "50", "51", "52"), c("expr", 
"randomizer")))

head(dput(df0x)) is big, so I will include some of it:

              gene_id   expr      grp Var     g2 group  Group
1     ENSG00000000003   1138 xxxxx3XX   0  Other     0  Other
2     ENSG00000000005      6 xxxxx5XX   0  Other     0  Other
3     ENSG00000000419    754 xxxxx4XX   4 Group4     4 Group4
4     ENSG00000000457    447 xxxxx4XX   4 Group4     4 Group4
5     ENSG00000000460    426 xxxxx4XX   4 Group4     4 Group4
6     ENSG00000000938      5 xxxxx9XX   9 Group9     9 Group9
7     ENSG00000000971      1 xxxxx9XX   9 Group9     9 Group9
8     ENSG00000001036    512 xxxxx1XX   0  Other     0  Other
9     ENSG00000001084   1024 xxxxx1XX   0  Other     0  Other
10    ENSG00000001167   2964 xxxxx1XX   1  Other     1  Other
user432797
  • 593
  • 4
  • 13
  • 3
    It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Oct 13 '20 at 04:40
  • I updated the question per your request @MrFlick – user432797 Oct 13 '20 at 04:54
  • 2
    The output of `df0x` isn't easily usable for someone trying to help you. Can you truncate the dataframe and then use `dput`? – Dylan_Gomes Oct 13 '20 at 05:08
  • @Dylan_Gomes I tried to save it `df0x.csv<-write.csv(df0x,'df0x.csv', row.names = FALSE)` but I'm getting an error `Error in as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors = stringsAsFactors): cannot coerce class ‘c("gg", "ggplot")’ to a data.frame` – user432797 Oct 13 '20 at 05:24
  • @Dylan_Gomes I also tried 'dput(head(df0x[1:10,]))` but I got an error `Error in df0x[, ]: incorrect number of dimensions Traceback` – user432797 Oct 13 '20 at 05:26
  • try `dput(df0x[c(1:10),])` – Dylan_Gomes Oct 13 '20 at 05:30
  • @Dylan_Gomes I get this error `Error in df0x[c(1:10), ]: incorrect number of dimensions Traceback` – user432797 Oct 13 '20 at 05:33
  • what do you get with `class(df0x)`? Where are you getting this data from? Are you reading it in from a csv? – Dylan_Gomes Oct 13 '20 at 14:05
  • 1
    It looks like `df0x` is already a gg object. We need the data and code used to create that object if we are going to help you. Or you need to create a reproducible example using fake data as @MrFlick suggests above – Dylan_Gomes Oct 13 '20 at 14:08

0 Answers0