title: 有序分类Logistic回归 tags: [] id: '2099' categories:
group <- t(readRDS('prad_tpm_Cu_death.rds'))
clinical <- read.csv('TCGA-PRAD_clinical.csv', row.names = 'bcr_patient_barcode')
f_TCGA_gleason_grade <- function(primary_gleason_grade, secondary_gleason_grade){
primary_gleason_grade <- as.numeric(unlist(data.frame(strsplit(primary_gleason_grade, ' '))[2,]))
secondary_gleason_grade <- as.numeric(unlist(data.frame(strsplit(secondary_gleason_grade, ' '))[2,]))
primary_gleason_grade + secondary_gleason_grade
}
clinical[['gleason']] <- f_TCGA_gleason_grade(clinical$primary_gleason_grade, clinical$secondary_gleason_grade)
mergeID <- intersect(rownames(clinical), rownames(group))
df <- cbind(group[mergeID,], clinical[mergeID, c('gleason', 'dcf_time', 'dcf_status', 'os_time', 'os_status')])
df[,'dcf_status'] = ifelse(df[,'dcf_status']==1,0,1)
df
require(foreign)
require(ggplot2)
require(MASS)
require(Hmisc)
require(reshape2)
lmf <- paste0("factor(gleason)~", paste(colnames(df)[1:10], collapse = '+'))
lmf
m <- polr(formula(lmf), data = df, Hess = TRUE)
m
drop1(m,test="Chi")
(ci <- confint(m))
exp(cbind(OR = coef(m), ci))
res <- as.data.frame(exp(cbind(OR = coef(m), ci)))
res[['Pvalue']] <- drop1(m,test="Chi")[rownames(res),'Pr(>Chi)']
res[['VarName']] <- rownames(res)
colnames(res)[1:3] <- c('mean', 'lower', 'upper')
res
saveRDS(res, 'Logistic.rds')
df <- readRDS('Logistic.rds')
options(repr.plot.width=8, repr.plot.height=6)
f_forestplot(df, zero = 1)