-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.R
52 lines (42 loc) · 1.46 KB
/
functions.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
42
43
44
45
46
47
48
49
50
51
52
library(dplyr)
library(tidyr)
library(readxl)
library(matrixStats)
library(grid)
library(ggplot2)
library(ggrepel)
library(ggpubr)
library(ComplexHeatmap)
library(circlize)
library(RColorBrewer)
# library(GSVA)
library(survminer)
require(survival)
library(gtools)
library(forestplot)
library(data.table)
parse_gmt = function(gmt_path){
db = readLines(gmt_path)
geneset = list()
for (line in db){
line =
words = as.vector(strsplit(line, "\\s{1,}")[[1]])
set_name = words[1]
genes = words[-c(1,2)]
geneset[[set_name]] = genes
}
return(geneset)}
coxConvert = function(x){ x <- summary(x)
p.value<-signif(x$wald["pvalue"], digits=2)
wald.test<-signif(x$wald["test"], digits=2)
beta<-signif(x$coef[1], digits=2);#coeficient beta
HR <-signif(x$coef[2], digits=2);#exp(beta)
HR.confint.lower <- signif(x$conf.int[,"lower .95"], 2)
HR.confint.upper <- signif(x$conf.int[,"upper .95"],2)
HR <- paste0(HR, " (",
HR.confint.lower, "-", HR.confint.upper, ")")
res<-c(beta, HR, wald.test, p.value)
names(res)<-c("beta", "HR (95% CI for HR)", "wald.test",
"p.value")
return(res)
}