admin管理员组文章数量:1660200
根据表达数据,ESTIMATE为研究人员提供了肿瘤纯度、存在的基质细胞水平和肿瘤组织中免疫细胞浸润水平的分数。https://bioinformatics.mdanderson/estimate/index.html
1. estimate安装
install.packages("estimate")
rforge <- "http://r-forge.r-project"
install.packages("estimate", repos=rforge, dependencies=TRUE)
library(estimate)
ls("package:estimate")
in.file <- system.file("extdata", "sample_input.txt", package="estimate")
out.file <- tempfile(pattern="estimate", fileext=".gct")
2. estimate分析
#进行estimate分析
setwd("/Users/test")
filterCommonGenes(in.file,
output.f=out.file,
id="GeneSymbol")
estimateScore(input.ds = out.file,
output.ds="OV_estimate_score.gct",
platform="affymetrix")
# platform = c("affymetrix", "agilent", "illumina"))
plotPurity(scores="OV_estimate_score.gct",
platform="affymetrix",
output.dir="estimated_purity_plots")
#生成plot文件
3. 累计分布曲线作图
scores=read.table("OV_estimate_score.gct",skip = 2,header = T)
rownames(scores)=scores[,1]
scores=t(scores[,3:ncol(scores)])
View(scores)
scores<- as.data.frame(scores)
scores$SampleID <- rownames(scores)
save(scores,file = 'BRCA_estimate_score.rdata')
# m_score <- get(load('BRCA_estimate_score.rdata'))
class(scores)
# median(scores[,'ImmuneScore'])
## 画单条累计分布曲线
library(ggplot2)
p1<-ggplot(scores,aes(x=ImmuneScore)) +
stat_ecdf(color = "green") +
labs(y="accumulative propotion")
p2<-ggplot(scores,aes(x=StromalScore)) +
stat_ecdf(color = "red") +
labs(y="accumulative propotion")
## 画多条累计分布曲线
# 要先把数据框转化成长数据格式
library(reshape2)
scores2 <- scores[,-4] # 去掉不需要的列
dim(scores2)
long = melt(scores2, id=c("SampleID"),
variable.name= 'Class', value.name = 'Value')
# 创建新的变量,含有分组信息
long$group <- rep(c(rep("g1",6),rep("g2",4)),3)
library(dplyr)
long<- mutate(long,group_score = paste(Class,group,sep="_"))
## 长格式转成宽格式数据框
#wide <- dcast(long,SampleID~Class,value.var='Value')
#作多条累计分布曲线,以不同颜色区分。
ggplot(long,aes(x=Value,color =Class,linetype=group)) +
stat_ecdf(size =1) + # 线粗细
labs(x="Score",
y="Accumulative propotion",
title="Accumulative Plotting") +
theme(legend.position = c(0.15,0.7), #图例位置 ("none", "left", "right", "bottom", "top", or two-element numeric vector)
legend.background =element_rect(fill = "white", colour = "grey50"),#图例背景
panel.background=element_rect(fill = "grey95", # grey90
colour = "black",
size = 1), #画布背景颜色
plot.title = element_text(hjust=0.5,size=16,vjust=0.5), #标题位置
legend.text=element_text(size=10,colour='black'), #图例文字
axis.text=element_text(size=8,colour="black"), #坐标轴文字
axis.title.y = element_text(size = rel(1.3), angle = 90),#y坐标轴名称文字
axis.title.x = element_text(size = rel(1.3)),#x坐标轴名称文字
)
版权声明:本文标题:R包estimate评估肿瘤组织中基质及免疫细胞浸润水平 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/xitong/1729849499a1215223.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论