-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3.Univariate and multivariate analysis.Rmd
More file actions
59 lines (47 loc) · 2.19 KB
/
3.Univariate and multivariate analysis.Rmd
File metadata and controls
59 lines (47 loc) · 2.19 KB
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
---
title: "Univariate and multivariate analysis"
author: "Yixiao(Lina) ZHU"
output: html_document
date: '2023-10-27'
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r}
rm(list = ls())
load("Data/STAD.exp.rdata")
load("Data/clin.data.rdata")
tar.lncRNA <- c("MIR200CHG", "AC104083.1", "LINC00578")
identical(clin.data$Sample, colnames(STAD.sub.exp))
for (i in 1:length(tar.lncRNA)) {
clin.data[, tar.lncRNA[i]] <- STAD.sub.exp[rownames(STAD.sub.exp) == tar.lncRNA[i], ]
}
clin.data[, "Stage1"] <- NA
clin.data$Stage1[clin.data$Stage %in% c("1", "2")] <- "T12"
clin.data$Stage1[clin.data$Stage %in% c("3", "4")] <- "T34"
library(survival)
## 1. Univariate analysis
tar <- c(tar.lncRNA, "Gender", "Stage1", "M.stage")
univ_formulas <- sapply(tar,
function(x) as.formula(paste('Surv(OS.time, OS.event)~', paste0("`",x,"`"))))
univ_models <- lapply(univ_formulas, function(x){coxph(x, data = clin.data)})
univ_results <- lapply(univ_models,
function(x){
x <- summary(x)
p.value<-signif(x$wald["pvalue"], digits=2)
wald.test<-signif(x$wald["test"], digits=3)
beta<-signif(x$coef[1], digits=2);#coeficient beta
HR <-round(x$coef[2], digits=2);#exp(beta)
HR.confint.lower <- format(x$conf.int[,"lower .95"], nsmall=2,digits=2)
HR.confint.upper <- format(x$conf.int[,"upper .95"],nsmall=2,digits=2)
HR.CI <- paste0(HR, " (",
HR.confint.lower, "-", HR.confint.upper, ")")
res<-c(beta, HR, HR.confint.lower, HR.confint.upper, HR.CI, p.value)
names(res)<-c("beta", "HR", "HR.lower","HR.upper", "HR.CI",
"Pvalue")
return(res)})
uni_res <- as.data.frame(do.call(rbind, univ_results))
uni_res
## 2. Multivariate analysis
coxph(Surv(OS.time, OS.event) ~ Gender + Stage1 + M.stage + MIR200CHG + AC104083.1 + LINC00578, data = clin.data)
```