需要将stage或者grade变成1,2,3, 4这种数值型的变量
dd=tcga_pck2
dd$pathologic_stage=gsub("A|B|C","",dd$pathologic_stage)
##dd$pathologic_stage=gsub(".A|B|C","",dd$pathologic_stage)###必须去点号
table(dd$pathologic_stage)
dd$pathologic_stage[dd$pathologic_stage=="Stage I"]=1
dd$pathologic_stage[dd$pathologic_stage=="Stage II"]=2
dd$pathologic_stage[dd$pathologic_stage=="Stage III"]=3
dd$pathologic_stage[dd$pathologic_stage=="Stage IV"]=4
result_tcga<-lm( PCK2 ~ factor(pathologic_stage,ordered = T),data=dd)
summary(result_tcga)
tstats <- coef(result_tcga) / sqrt(diag(vcov(result_tcga)))
pvalue<-2 * pt(abs(tstats), df = df.residual(result_tcga), lower.tail = FALSE)
pred<-predict(result_tcga,interval = 'confidence',data=dd)
str(dd)
plot(dd$pathologic_stage,dd$PCK2),data=dd,pch=16,col=c("#36648B"),main="SBSN (P=1.73e-22) ",xlab="Grade",ylab = "Expression level")
abline(result3,lty=1,lwd=2)
lines(gene_clic$Neoplasm.Histologic.Grade,pred[,2],lty=3)
lines(gene_clic$Neoplasm.Histologic.Grade,pred[,3],lty=3)