how to plot one-dimeson heatmap using R
1
0
Entering edit mode
10 weeks ago
szp770 ▴ 10

I am intersted in one perticular gene, and I want to see the correlation of this gene and other hundreds of genes, so I generate a one-dimension matrix like this:

geneA--interested_gene    0.86
geneB--interested_gene    0.23
........
geneZ--interested_gene    -0.15


How to plot heatmap using this data?

R heatmap • 301 views
0
Entering edit mode

Please post the data and the code you tried.

0
Entering edit mode

the example data is just like what I showed above, the first column is the genes name, and the second column is the correlation value of the gene in first column with the interested gene, I loaded this data in R and plot heatmap using pheatmap directly.

0
Entering edit mode
0
Entering edit mode
9 weeks ago
zx8754 10k

Try this example:

# example data
set.seed(1); d <- data.frame(
g1 = paste0("gene", 1:5),
g2 = "myGene",
cor = runif(5))

library(ggplot2)

ggplot(d, aes(g1, g2, fill = cor)) +
geom_tile() +
theme_minimal()