首先調(diào)取Xena網(wǎng)頁的TCGA數(shù)據(jù)做Cox生存分析,數(shù)據(jù)可以通過hiplot官網(wǎng)自主研發(fā)的ucsc-xena-shiny直接在線獲取
訪問https://hiplot.com.cn/advance/ucsc-xena-shiny
然后全屏
顯示,點擊Qucik PanCan Analysis
下方的TCGA:Molcular Profile Cox Analysis
Molcular Profile Cox Analysis
輸入一個你想要的基因,比如RAC3
,Select Measure for plot
可以設(shè)置OS
,PFI
,DSS
和DFI
,然后點上方的搜索??,就可以看到出的圖了
需要的結(jié)果
繼續(xù)往下滾動鼠標(biāo),就可以看到數(shù)據(jù)了,而且還可以下載
數(shù)據(jù)在這
得到數(shù)據(jù)以后就可以用R畫圖了,注意,這里的HR和CI都是Log過的結(jié)果,跟別的地方計算的Cox結(jié)果有些不一樣,可能是方法不一樣吧,是因為網(wǎng)站計算的HR結(jié)果相差太大了嗎?
由于是log過的結(jié)果,所以森林圖的X軸不再是HR=1為分界線了,而是以log2HR=
0
為分界線。。。
unicox <- read_csv("~/Desktop/RAC3_mRNA_OS_pancan_unicox.csv") ##加載csv數(shù)據(jù)
library(ggplot2)
ggplot(RAC3_mRNA_OS_pancan_unicox, aes(HR_log, cancer, col=Type))+ ##定義X軸和Y軸,以類型分類
geom_point(size=2.5)+ #固定點的大小
geom_errorbarh(aes(xmax =upper_95_log, xmin = lower_95_log), height = 0.4)+ ##設(shè)置95%CI區(qū)間,就是誤差線
scale_x_continuous(limits= c(-2, 2), breaks= seq(-1, 1, 1))+ ##設(shè)置X軸范圍,分割點從-1到1,以1為分界,具體分界看數(shù)字分布
geom_vline(aes(xintercept = 0))+ #以0為分界線
xlab('HR(95%CI)') + ylab(' ')+ #定義標(biāo)簽
theme_bw(base_size = 12)+ #主題和字體
scale_color_manual(values = c("gray", "steelblue", "red")) #設(shè)置顏色
點的大小固定為2.5
ggplot(RAC3_mRNA_OS_pancan_unicox, aes(HR_log, cancer, col=Type,shape=Type))+ #設(shè)置不同的形狀
geom_point(size=3)+
geom_errorbarh(aes(xmax =upper_95_log, xmin = lower_95_log), height = 0.4)+
scale_x_continuous(limits= c(-2, 2), breaks= seq(-1, 1, 1))+
geom_vline(aes(xintercept = 0))+
xlab('HR(95%CI)') + ylab(' ')+
theme_bw(base_size = 12)+
scale_color_manual(values = c("gray", "steelblue", "red"))
不同的形狀
# 以-log10P值定義點的大小,點越大,P值越小,越有統(tǒng)計學(xué)意義
ggplot(RAC3_mRNA_OS_pancan_unicox, aes(HR_log, cancer, col=Type,shape=Type))+
geom_point(aes(size=-log10(p.value)))+
geom_errorbarh(aes(xmax =upper_95_log, xmin = lower_95_log), height = 0.4)+
scale_x_continuous(limits= c(-2, 2), breaks= seq(-1, 1, 1))+
geom_vline(aes(xintercept = 0))+
xlab('HR(95%CI)') + ylab(' ')+
theme_bw(base_size = 12)+
scale_color_manual(values = c("gray", "steelblue", "red"))
image.png
再加一個形狀
ggplot(RAC3_mRNA_OS_pancan_unicox, aes(HR_log, cancer, col=Type,shape=Type))+
geom_point(aes(size=-log10(p.value)))+
geom_errorbarh(aes(xmax =upper_95_log, xmin = lower_95_log), height = 0.4)+
scale_x_continuous(limits= c(-2, 2), breaks= seq(-1, 1, 1))+
geom_vline(aes(xintercept = 0))+
xlab('HR(95%CI)') + ylab(' ')+
theme_bw(base_size = 12)+
scale_color_manual(values = c("gray", "steelblue", "red"))
image.png
#排個序可好
ggplot(RAC3_mRNA_OS_pancan_unicox, aes(HR_log, reorder(cancer,HR_log), col=Type,shape=Type))+
geom_point(aes(size=-log10(p.value)))+
geom_errorbarh(aes(xmax =upper_95_log, xmin = lower_95_log), height = 0.4)+
scale_x_continuous(limits= c(-2, 2), breaks= seq(-1, 1, 1))+
geom_vline(aes(xintercept = 0))+
xlab('HR(95%CI)') + ylab(' ')+
theme_bw(base_size = 12)+
scale_color_manual(values = c("gray", "steelblue", "red"))
image.png
##換個排序也行
ggplot(RAC3_mRNA_OS_pancan_unicox, aes(HR_log, reorder(cancer,-HR_log), col=Type,shape=Type))+
geom_point(aes(size=-log10(p.value)))+
geom_errorbarh(aes(xmax =upper_95_log, xmin = lower_95_log), height = 0.4)+
scale_x_continuous(limits= c(-2, 2), breaks= seq(-1, 1, 1))+
geom_vline(aes(xintercept = 0))+
xlab('HR(95%CI)') + ylab(' ')+
theme_bw(base_size = 12)+
scale_color_manual(values = c("gray", "steelblue", "red"))
image.png
更多定制,等你發(fā)現(xiàn)。。。