-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lehmann_traits.R
99 lines (71 loc) · 2.52 KB
/
Lehmann_traits.R
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#### script for Lehmann subtype comparison
#### load the individual Bur type signatures
leh6 <- read.table("Lehmann_subtype_genes.txt", sep = "\t", header = TRUE)
### BL1
list <- intersect(rownames(datExpr2), leh6[,1])
bl1_m <- datExpr2[list,]
### BL2
list <- intersect(rownames(datExpr2), leh6[,2])
bl2_m <- datExpr2[list,]
## IM
list <- intersect(rownames(datExpr2), leh6[,3])
im_m <- datExpr2[list,]
## M
list <- intersect(rownames(datExpr2), leh6[,4])
m_m <- datExpr2[list,]
### MSL
list <- intersect(rownames(datExpr2), leh6[,5])
msl_m <- datExpr2[list,]
### LAR
list <- intersect(rownames(datExpr2), leh6[,6])
lar_m <- datExpr2[list,]
##################################################
####get the mean centred ave of all of these sample
# create function to center : 'colMeans()'
center_colmeans <- function(x) {
xcenter = colMeans(x)
x - rep(xcenter, rep.int(nrow(x), ncol(x)))
}
centre_t <- center_colmeans(t(lar_m))
meta_ave <- as.data.frame(rowMeans(centre_t))
rownames(meta_ave) <- colnames(lar_m)
colnames(meta_ave)[1] <- "LAR_signature"
### for M
centre_t <- center_colmeans(t(m_m))
meta_ave$M_signature <- rowMeans(centre_t)
## for MSL
centre_t <- center_colmeans(t(msl_m))
meta_ave$MSL_signature <- rowMeans(centre_t)
## for IM
centre_t <- center_colmeans(t(im_m))
meta_ave$IM_signature <- rowMeans(centre_t)
## for BL1
centre_t <- center_colmeans(t(bl1_m))
meta_ave$BL1_signature <- rowMeans(centre_t)
## for BL2
centre_t <- center_colmeans(t(bl2_m))
meta_ave$BL2_signature <- rowMeans(centre_t)
##### META_AVE is now the mean-centred average expression
## of each signautre for each sample
## write out
write.table(meta_ave, "Lehmann_METABRIC.txt", sep = "\t")
##Try correlations again
### try with the TCGA pam50
nGenes = ncol(ME_2A);
nSamples = nrow(ME_2A);
moduleTraitCor5 = cor(ME_2A, meta_ave, use = "p");
moduleTraitPvalue5 = corPvalueStudent(moduleTraitCor5, nSamples);
pdf("Heat_leh_subtype_meta.pdf",height=8,width=10)
fontsize = 10
## recall that setting treeheight_col or _row to '0' will remove
##dendro for that side
pheatmap(t(moduleTraitCor5),
color = colorRampPalette(rev(brewer.pal(n = 10, name = "RdYlBu")))(100),
kmeans_k = NA, breaks = NA, border_color = "grey60",
cellwidth = NA, cellheight = NA, scale = "none",
cluster_rows = TRUE, cluster_cols = TRUE,
fontsize_row = 10,
annotation_legend = TRUE, drop_levels = TRUE,
show_rownames = T,show_colnames = T,
main = "Expression of Lehmann subtype by module (METABRIC)")
dev.off()