-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscratch_heatMap_code.R
More file actions
78 lines (70 loc) · 2.96 KB
/
scratch_heatMap_code.R
File metadata and controls
78 lines (70 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# scratch heat map code
# correlations
# get summary stats for plots
meanGDDs<-spread(zStats,threshold,GDDValue)
meanGDDs<-meanGDDs[,c(1,2,3,5,4,6)]
corrGDD <- meanGDDs %>%
group_by(cluster) %>% # add in threshold
#summarise(corrs = cor(GDDValue, GDDValue))
do(data.frame(Cor=t(cor(.[,4:6], .[,4:6], method="kendall"))))
# add in split period correlations
# plot in heatmap, http://sebastianraschka.com/Articles/heatmaps_in_r.html
library(gplots)
rnames <- as.matrix(corrGDD[,1])
mat_data <- round(data.matrix(corrGDD[,2:ncol(corrGDD)]),2)
mat_data_all <- round(data.matrix(corrGDD[,2:ncol(corrGDD)]),2)
rownames(mat_data) <- rnames
heatmap.2(mat_data,
cellnote = mat_data, # same data set for cell labels
main = "1948-2016 GDD Correlations (mean GDDs, Kendall r)", # heat map title
notecol="black", # change font color of cell labels to black
density.info="none", # turns off density plot inside color legend
col=rev(heat.colors(256)),
margins =c(7,7),
rowsep = seq(0,35,3),
sepcolor = "black",
Colv="NA",
Rowv = "NA",
dendrogram = "none",
trace="none") # turn off column clustering
# late period correlation 1981-2016
meanGDDs <- meanGDDs[ which(meanGDDs$year >= 1981),]
corrGDD <- meanGDDs %>%
group_by(cluster) %>% # add in threshold
#summarise(corrs = cor(GDDValue, GDDValue))
do(data.frame(Cor=t(cor(.[,4:6], .[,4:6], method="kendall"))))
# add in split period correlations
# plot in heatmap, http://sebastianraschka.com/Articles/heatmaps_in_r.html
library(gplots)
rnames <- as.matrix(corrGDD[,1])
mat_data <- round(data.matrix(corrGDD[,2:ncol(corrGDD)]),2)
mat_data_late <- round(data.matrix(corrGDD[,2:ncol(corrGDD)]),2)
rownames(mat_data) <- rnames
heatmap.2(mat_data,
cellnote = mat_data, # same data set for cell labels
main = "1981-2016 GDD Correlations (mean GDDs, Kendall r)", # heat map title
notecol="black", # change font color of cell labels to black
density.info="none", # turns off density plot inside color legend
col=rev(heat.colors(256)),
margins =c(5,5),
rowsep = seq(0,35,3),
sepcolor = "black",
Colv="NA",
Rowv = "NA",
dendrogram = "none",
trace="none") # turn off column clustering
# corr diff heatmap
mat_data<-mat_data_late-mat_data_all
heatmap.2(mat_data,
cellnote = mat_data, # same data set for cell labels
main = "GDD Correlations late-all", # heat map title
notecol="black", # change font color of cell labels to black
density.info="none", # turns off density plot inside color legend
col=rev(heat.colors(256)),
margins =c(5,5),
rowsep = seq(0,35,3),
sepcolor = "black",
Colv="NA",
Rowv = "NA",
dendrogram = "none",
trace="none") # turn off column clustering