-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path00_demo_hadaca3_framework.Rmd
153 lines (95 loc) · 3.45 KB
/
00_demo_hadaca3_framework.Rmd
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
---
title: "Demo HADACA3 Framework"
author: "Hugo Barbot and Florent Chuffart "
date: "`r Sys.Date()`"
output:
rmarkdown::html_document:
toc: true
toc_float: true
toc_depth: 3
number_sections: true
---
```{r, include=(FALSE)}
knitr::opts_chunk$set(collapse=TRUE, comment="#>", fig.width=9, fig.height=6, eval=TRUE, echo=TRUE, results="verbatim")
options(knitr.duplicate.label = "allow")
```
# Load data
Demo adapted from baseline_teamF and teamF_Source_prior_known_feature (attachment). Scripts are located here : https://gricad-gitlab.univ-grenoble-alpes.fr/hadaca3/hadaca3_private/-/tree/main/baselines/attachement?ref_type=heads, and were copied in the `src` folder.
Data were downloaded from the HADACA3 challenge starting kit.
```{r}
ref = readRDS("00_demo_data/data/reference_pdac.rds")
mix = readRDS("00_demo_data/data/mixes1_SBN5_pdac.rds")
source("scr/teamF_Source_prior_known_features.R")
```
# Block Preprocessing (PP)
Takes as input a multimodal .txt.gz, outputs a multimodal txt.gz
```{r}
program_blockPP <- function(mix = NULL, ref = NULL,
...) {
# Normalize input matrices
ref$ref_bulkRNA = normalize_matrix(ref$ref_bulkRNA)
ref$ref_met = normalize_matrix(ref$ref_met)
multi_data = list(mix = mix,
ref = ref)
return(multi_data)
}
PP_data = program_blockPP(mix = mix,
ref = ref)
```
# Block Feature selection (FS)
Takes as input a multimodal .txt.gz, outputs a multimodal txt.gz
```{r}
program_blockFS <- function(multi_data) {
drop_null_ref_cols <- function(ref_matrix){
non_null_rows = apply(ref_matrix != 0,MARGIN = 1, FUN = any, simplify = TRUE)
return(ref_matrix[non_null_rows,])
}
ref_matrix = multi_data$ref$ref_bulkRNA
multi_data$ref$ref_bulkRNA <- drop_null_ref_cols(ref_matrix)
return(multi_data)
}
FS_data = program_blockFS(multi_data = PP_data)
```
# Block SPLIT (SP)
```{r}
program_blockSP <- function(multi_data) {
uni_data_RNA = list(mix = multi_data$mix$mix_rna,
ref = list(bulk = multi_data$ref$ref_bulkRNA,
scRNA = multi_data$ref$ref_scRNA))
uni_data_met = list(mix = multi_data$mix$mix_met,
ref = list(bulk = multi_data$ref$ref_met))
uni_data = list(RNA = uni_data_RNA,
met = uni_data_met)
return(uni_data)
}
SP_data = program_blockSP(multi_data = FS_data)
```
# Block Deconvolution (DE)
Takes as input a multimodal mix.txt.gz and a ref.txt.gz, output a prediction.txt.gz
```{r}
uni_data = SP_data$RNA
program_blockDE <- function(uni_data) {
## RNA:
#if ( !( is.null(x = mix_rna) ) ) {
idx_feat = intersect(rownames(uni_data$mix), rownames(uni_data$ref$bulk))
uni_data$mix = uni_data$mix[idx_feat,]
uni_data$ref$bulk = uni_data$ref$bulk[idx_feat,]
uni_pred = get_prop_nnls(uni_data$mix, uni_data$ref$bulk)
return(uni_pred) # MAG : je ne sais pas quoi sortir
}
pred_RNA = program_blockDE(uni_data = SP_data$RNA)
pred_met = program_blockDE(uni_data = SP_data$met)
```
# Block Late integration (LI)
Takes as input a a multimodal prediction.txt.gz, outputs an integrated prediction
```{r}
program_blockLI <- function(pred1, pred2) {
multi_pred <- (pred1 + pred2) / 2
return(multi_pred) # MAG : je ne sais pas quoi sortir
}
final_pred = program_blockLI(pred_RNA, pred_met)
```
# Session Information
```{r, results="verbatim"}
sessionInfo()
```