##----安装,评估=错误------------------------------------------------------# #if(!requireNamespace(“BiocManager”,悄悄地=TRUE))#install.packages(“BiocManager”)# #BiocManager::install(“POWSC”)##----设置,eval=TRUE,message=FALSE,results='hide'--------------------------suppressMessages(库(POWSC))数据(“es_mef_sce”)sce=es_mef_sce[,colData(es_mef _sce)$cellTypes=“fibro”]设定种子(12)rix=样本(1:nrow(sce),500)sce=sce[里克斯,]est_Paras=估计2阶段(sce)sim_size=c(100200)#数字向量pow_rslt=运行POWSC(sim_size=sim_sze,est_Paras=est_Para,per_DE=0.05,DE_Method=“MAST”,Cell_Type=“PW”)##----两组,eval=TRUE,message=FALSE,results='hide'--------------------#用户可以自定义更改n的数量所需的单元格数量。simData=模拟2SCE(n=100,estParas1=测试参数,estParas 2=测试参数)de=运行de(simData$sce,de_Method=“MAST”)estPower1=Power_Disc(de,simData=simData)estPower2=Power_Cont(de,simData=simData)##----多组,eval=TRUE,message=FALSE,results='hide'---------------数据(“GSE67835_AB_S7_sce”)sim_size=200#最好使用大样本cell_per=c(0.2、0.3、0.5)col=colData(sce)exprs=分析(sce)$计数(tb=表格(colData(sce)$Patients,colData(sce)$cellTypes)#以AB_S7患者为例,取三种细胞类型:星形胶质细胞杂交细胞和神经元estParas_set=空细胞类型=c(“少突胶质细胞”、“杂交”、“神经元”)for(单元类型中的cp){打印(cp)ix=交叉(grep(cp,col$cellTypes),grep(“AB_S7”,col$Patients))tmp_mat=表达式[,ix]tmp_paras=Est2阶段(tmp_mat)estParas_set[[cp]]=tmp_paras}######### #########模拟部分######### sim=模拟多SCE(n=sim_size,estParas_set=estParas_set,multiProb=cell_per)######### #########DE分析部分######### DE_rslt=空for(comp-in-names(sim)){tmp=运行DE(sim[[comp]]$sce,DE_Method=“MAST”)数据元素_ rslt[[组件]]=tmp}######### #########总结功率结果######### pow_rslt=pow1=pow2=pow1_marg=pow2_marg=NULLTD=CD=空for(comp-in-names(sim)){tmp1=电源磁盘(数据元素[[组件]],模拟[[组件])tmp2=电源控制(数据元素[[组件]],模拟[[组件])TD=c(TD,tmp2$TD);CD=c(CD,tmp2$CD)pow1_marg=c(pow1_merg,tmp1$power.marginal)pow2_marg=c(pow2_merg,tmp2$power.marginal)pow_rslt[[comp]]=列表(pow1=tmp1,pow2=tmp2)pow1=rbind(pow1,tmp1$功率)pow2=rbind(pow2,tmp2$power)}######### #########通过热图演示结果######### 图书馆(RColorBrewer);图书馆(照片)breaksList=序列(0,1,by=0.01)colors=colorRampPalette(rev(brewer.pal(n=7,name=“RdYlBu”))(长度(breaksList))dimnames(pow1)=列表(名称(sim),名称(tmp1$CD))dimnames(pow2)=列表(名称(sim),名称(tmp2$CD))现象图(pow2,display_numbers=TRUE,color=colors,show_rownames=TRU,单元格宽度=30,单元格高度=40,图例=真,border_color=“grey96”,na_col=“grey”,cluster_row=FALSE,cluster_cols=FALSE,断裂=seq(0,1,0.01),main=“”)## -----------------------------------------------------------------------------sessionInfo()