Can somebody tell me how to interpret heatmaps?

I have tried you tube and all, but I do not understand them.. For Example: I want to show a correlation of Sodium uptake and potassium uptake in various plant parts with varying concentrations of sodium.

Can you post some or all of your data? You can post the output of the dput() function to do that. If your data frame is named DF, your can show 20 rows of data with

dput(head(DF,20))
1 Like

I have a dataset containing measurements of Ca and Mg concentrations in various plant parts across four species, each with four groups exposed to different calcium concentrations. I'd like to investigate the correlation between calcium treatment/ concentration levels and Ca and Mg concentrations in different plant parts.

structure(list(Species = c("A", "A", "A", "A", "A", "B", "B",
"B", "B", "B", "C", "C", "C", "C", "C", "D", "D", "D", "D", "D"
), Conc. = c(0, 25, 100, 150, 200, 0, 25, 100, 150, 200, 0, 25,
100, 150, 200, 0, 25, 100, 150, 200), Ca in Leaves = c(0, 6.4,
22.8, 45.7, 67.8, 0, 6, 20, 54, 65, 0, 32.67, 68.44, 88.98, 117.98,
0, 7.8, 13.5, 17.5, 23.7), Mg in Leaves = c(5650, 4233.5, 3393.3,
2180.4, 2080.4, 4800, 4100, 3260, 2438.2, 2100, 4323.8, 3518.5,
2984.5, 2487.9, 1987.7, 3987.98, 2894.8, 2145.67, 1756.98, 1265.98
), Ca in Shoot = c(0, 21.7, 43.79, 75.7, 99.4, 0, 2, 6, 13.3,
66, 0, 6.46, 82.3, 118.67, 317.67, 0, 21.3, 45.29, 64.3, 77.5
), Mg in Shoot = c(6540.89, 4802.1, 2598.6, 1788.8, 1198.9,
4250, 3536, 2943.2, 2744, 2000, 7291.2, 6892.3, 5709.2, 4350.8,
2984.5, 6598.34, 5687.34, 4876.34, 3876.45, 2687.45), Ca in Root = c(0,
28.4, 56.8, 81.2, 109.6, 0, 2, 34, 40, 128, 0, 2.4, 9.3, 26.6,
82.3, 0, 13.7, 22.4, 34.7, 44.7), Mg in Root = c(33800.8, 27890.6,
24100.7, 19260.8, 13438, 32800.8, 21555, 18856, 13560, 11700,
5389.25, 4350.56, 3307.75, 2984.5, 1147.5, 4156.56, 3645.87,
2897.54, 2165.87, 1098.34)), row.names = c(NA, -20L), class = c("tbl_df",
"tbl", "data.frame"))

This is not an answer to your question but your dput() output does not work. You have spaces in the variable names and R does not like that .

This should work

dat1 <- structure(list(Species = c("A", "A", "A", "A", "A", "B", "B",
"B", "B", "B", "C", "C", "C", "C", "C", "D", "D", "D", "D", "D"
), Conc. = c(0, 25, 100, 150, 200, 0, 25, 100, 150, 200, 0, 25,
100, 150, 200, 0, 25, 100, 150, 200), Ca_in_Leaves = c(0, 6.4,
22.8, 45.7, 67.8, 0, 6, 20, 54, 65, 0, 32.67, 68.44, 88.98, 117.98,
0, 7.8, 13.5, 17.5, 23.7), Mg_in_Leaves = c(5650, 4233.5, 3393.3,
2180.4, 2080.4, 4800, 4100, 3260, 2438.2, 2100, 4323.8, 3518.5,
2984.5, 2487.9, 1987.7, 3987.98, 2894.8, 2145.67, 1756.98, 1265.98
), Ca_in_Shoot = c(0, 21.7, 43.79, 75.7, 99.4, 0, 2, 6, 13.3,
66, 0, 6.46, 82.3, 118.67, 317.67, 0, 21.3, 45.29, 64.3, 77.5
), Mg_in_Shoot = c(6540.89, 4802.1, 2598.6, 1788.8, 1198.9,
4250, 3536, 2943.2, 2744, 2000, 7291.2, 6892.3, 5709.2, 4350.8,
2984.5, 6598.34, 5687.34, 4876.34, 3876.45, 2687.45), Ca_in_Root = c(0,
28.4, 56.8, 81.2, 109.6, 0, 2, 34, 40, 128, 0, 2.4, 9.3, 26.6,
82.3, 0, 13.7, 22.4, 34.7, 44.7), Mg_in_Root = c(33800.8, 27890.6,
24100.7, 19260.8, 13438, 32800.8, 21555, 18856, 13560, 11700,
5389.25, 4350.56, 3307.75, 2984.5, 1147.5, 4156.56, 3645.87,
2897.54, 2165.87, 1098.34)), row.names = c(NA, -20L), class = c("tbl_df",
"tbl", "data.frame"))
``

I don't normally use heatmaps so I may be missing something but why do you want to use heatmaps with this data?

Expanding a bit on @jrkrideau's comment. I looked at the correlation between Conc. and the Ca or Mg values in each plant part for each species. Almost all the correlation values have an absolute value above 0.95, so the color of the heat map will not be informative. The Ca values are close to 1.0 and the Mg values are close to -1.0.

1 Like

As a relatively new R user, I've been exploring visualization options for my research. In addition to line graphs, I thought that heatmaps were useful for correlations. So should I just use line graphs for correlations?

Actually I was just trying to plot something I haven't plotted before...

Depends on what you are doing but for a start, probably yes.

ggplot(dat1, aes(Conc., Ca_in_Leaves, colour = Species )) +
   geom_point()  + geom_line()

looks interesting.

Thank you but I have made several line graphs.. I was asking are there any other plots I can use for correlation?