-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfittingtool_notebook.Rmd
90 lines (69 loc) · 1.95 KB
/
fittingtool_notebook.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
---
title: "Fitting tool notebook"
output: html_notebook
---
Load libraries and util
```{r}
library('NMF')
library("ggplot2")
library('MutationalPatterns')
source(file="utils.R")
```
Load data
```{r}
breast_cancer = read.csv(file="data/breast_cancer.csv",header=TRUE)
cosmic_signatures = read.csv(file="data/cosmic_signatures.csv",header=TRUE)
cosmic_signatures=cosmic_signatures[,3:ncol(cosmic_signatures)]
BC_exposure= read.delim(file = "data/extanded_breast_cancer_expousre.txt",header=T,sep="\t")
noise_BC_samples= read.delim(file = "data/noise_breast_cancer_samples.txt",header=T)
```
```{r}
as.matrix(BC_exposure)
nrow(BC_exposure)
ncol(BC_exposure)
rownames(BC_exposure)
```
```{r}
strsplit(colnames(BC_exposure)[1],"\\.")[[1]]
toString(BC_exposure[1,])
strsplit(toString(BC_exposure[1,])," ")[[1]]
```
Breast cancer exposure
```{r}
BC_exposure= read.delim(file = "data/extanded_breast_cancer_expousre.txt",header=T,sep="\t")
BC_expo=matrix(0, nrow=560, ncol=66)
colnames(BC_expo)=strsplit(colnames(BC_exposure)[1],"\\.")[[1]]
for(i in seq(1,560)){
spl=strsplit(toString(BC_exposure[i,])," ")[[1]]
for(j in seq(1,66)){
BC_expo[i,j]=as.numeric(spl[j+1])
}
}
```
Breast cancer samples (ideal + noise)
```{r}
BC_samples=matrix(0, nrow=96, ncol=560)
colnames(BC_samples)=strsplit(colnames(noise_BC_samples)[1],"\\.")[[1]]
for(i in seq(1,96)){
spl=strsplit(toString(noise_BC_samples[i,])," ")[[1]]
for(j in seq(1,560)){
BC_samples[i,j]=as.numeric(spl[j+1])
}
}
```
```{r}
source(file="add_signatures.R")
source(file="fitting_probabilities.R")
#source(file="Hparams.R")
#source(file="main.R")
source(file="probabilities_to_exposure.R")
source(file="remove_signatures.R")
source(file="remove_small_exposure.R")
source(file="remove_specific_signatures.R")
source(file="sparse_filter.R")
```
```{r}
probs=fitting_probabilities(mut_mat=BC_samples[,1:5],
signatures = cosmic_signatures,
ind_prior_knowledge = c(1))
```