-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodule_VST.R
41 lines (33 loc) · 1.14 KB
/
module_VST.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
# vst module
datasets <-
read_yaml("./data.yaml")
raw_data <- getwd()
t2g_hs <- read_rds("data/t2g_hs.rds")
t2g_mm <- read_rds("data/t2g_mm.rds")
vst_Server <- function(id, dataset_dds, dataset_choice) {
moduleServer(id, function(input, output, session) {
vst.create <- function(dds, dataset){
dds.file <- dds
vsd <-
vst(dds.file, blind = F)
#mouse or human?
is_hs <- grepl("t2g_hs", datasets[[dataset]]$t2g)
if(is_hs){
vst.table <- data.frame(assay(vsd)) %>%
rownames_to_column(., var = "ensembl_gene_id") %>%
left_join(unique(dplyr::select(t2g_hs, c(ensembl_gene_id, ext_gene))), ., by = 'ensembl_gene_id') %>%
na.omit(.)
} else {
vst.table <- data.frame(assay(vsd)) %>%
rownames_to_column(., var = "ensembl_gene_id") %>%
left_join(unique(dplyr::select(t2g_mm, c(ensembl_gene_id, ext_gene))), ., by = 'ensembl_gene_id') %>%
na.omit(.)
}
vst.table
}
vst.global <- reactive({
vst.create(dataset_dds(), dataset_choice())
})
return(vst.global)
})
}