Repository navigation
Expand file tree
/
Copy pathPCA.R
More file actions
69 lines (49 loc) · 1.58 KB
/
Copy pathPCA.R
File metadata and controls
69 lines (49 loc) · 1.58 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
# heatmap
output$PCA_plot <- renderPlot({
pca_c = PCA_C()
pca_l = PCA_L()
tmp = EXP()
Expression = tmp$Expression
condition = tmp$condition
if(is.null(Expression)){
return(NULL)
}
library(ggfortify)
if (pca_c == "sample"){
condition.info = data.frame(Sample = colnames(Expression))
rownames(condition.info) = colnames(Expression)
autoplot(prcomp(t(Expression)), data = condition.info, colour = "Sample", size=5, alpha = 0.5, label = pca_l, label.vjust = 1.8) +
theme_bw(base_size = 30) +
theme(panel.border = element_rect(colour = "black", size = 2),
legend.position = PCA_G())
} else {
condition.info = t(condition)
colnames(condition.info) = c("Condition")
autoplot(prcomp(t(Expression)), data = condition.info, colour = "Condition", size=5, alpha = 0.5, label = pca_l, label.vjust = 1.8) +
ggtitle("PCA") +
theme_bw(base_size = 30) +
theme(panel.border = element_rect(colour = "black", size = 2),
legend.position = PCA_G())
}
})
output$PCA.ui <- renderUI({
plotOutput("PCA_plot", width = paste0(input$PCA_Width, "px"), height = paste0(input$PCA_Height, "px"))
})
PCA_C = reactive({
switch(input$PCA_color,
"sample" = "sample",
"condition" = "condition"
)
})
PCA_L = reactive({
switch(input$PCA_label,
"Show" = TRUE,
"Hide" = FALSE
)
})
PCA_G = reactive({
switch(input$PCA_legend,
"Show" = "right",
"Hide" = "none"
)
})