-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMEanalysis.R
25 lines (25 loc) · 1.06 KB
/
MEanalysis.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
MEanalysis <- function(somMuts, pathways){
install.packages("Rediscover", repos='http://cran.us.r-project.org')
if (!require("BiocManager", quietly = TRUE)){
install.packages("BiocManager", repos='http://cran.us.r-project.org')
}
BiocManager::install("maftools", repos='http://cran.us.r-project.org')
library("Rediscover")
library("tidyverse")
library("discover")
out = data.frame(names=character(), p_value=double())
if (nrow(pathways) > 0){
for (row in 1:nrow(pathways)) {
if (nchar(pathways[row, "Somatically_Mutated_Genes"])>2){
genes <-as.vector(strsplit(substring(pathways[row, "Somatically_Mutated_Genes"], 2,nchar(pathways[row, "Somatically_Mutated_Genes"])-1), ", "))[[1]]
A = data.matrix(somMuts)
PM <- getPM(A)
x= data.frame(rownames(somMuts))
x$indices = rownames(x)
p_val = getMutexGroup(data.matrix(A[genes,]), PM[as.numeric(c(filter(x, rownames.somMuts. %in% genes)$indices)),], "Coverage")
out[nrow(out) + 1,] = c(pathways[row, "Pathway_Name"], p_val)
}
}
}
return(out)
}