### R代码从vignette源的流类型。Rnw ' ################################################### ### 代码块1号:loadlib ################################################### 库(flowType)数据(DLBCLExample ) ################################################### ### 代码块2号:PropMarkers ################################################### PropMarkers < - 3:5 MFIMarkers < - PropMarkers MarkerNames < - c(‘f’,‘学生’,‘CD3’,‘CD5’,‘CD19’)Res <——flowType (DLBCLExample、PropMarkers MFIMarkers, kmeans, MarkerNames);################################################### ### 代码块3号:SingleDPartitions ################################################### 情节(Res DLBCLExample);################################################### ### 代码块数量4:PlotPop ################################################### 情节(Res,“CD3 + CD5-CD19 +帧= DLBCLExample);################################################### ### 代码块5号:BarPlot ################################################### 小额信贷机构= Res@MFIs;比例= Res@CellFreqs;比例<-比例/ max(比例)names(比例)<- unlist(lapply(Res@PhenoCodes, function(x){return(decodePhenotype(x,Res@MarkerNames[PropMarkers], Res@PartitionsPerMarker)})) rownames(MFIs)=names(比例)index=order(比例,递减=TRUE)[1:20] bp=barplot(比例[指数],axes=FALSE, names.arg=FALSE) text(bp+0.2, par("usr")[3]+0.02, srt = 90, adj =0, labels =names(比例[指数]),xpd =TRUE, cex=0.8)坐标轴(2);轴(1,at=bp, labels=FALSE);标题(xlab =表型的名字,ylab = '细胞的比例 ') ################################################### ### 代码块6号:calcNumPops ################################################### calcNumPops(代表(2 34)10 ) ################################################### ### 代码块7号:calcNumPopsFig ################################################### 情节(log10(酸式焦磷酸钠(1:10,函数(x) {calcNumPops(代表(34),x)})), ylab =“细胞(log10)”,xlab = '截止 ') ################################################### ### 代码块8号:loadmetadata ################################################### 库(flowType)数据(HIVMetaData) HIVMetaData <——HIVMetaData[这(HIVMetaData(, '管']= = 2),); ################################################### ### code chunk number 9: readlabels ################################################### Labels=(HIVMetaData[,2]=='+')+1; ################################################### ### code chunk number 10: loadrawdata ################################################### library(sfsmisc); library(flowCore); data(HIVData) PropMarkers <- 5:10 MFIMarkers <- PropMarkers MarkerNames <- c('Time', 'FSC-A','FSC-H','SSC-A','IgG','CD38','CD19','CD3', 'CD27','CD20', 'NA', 'NA') ResList <- fsApply(HIVData, 'flowType', PropMarkers, MFIMarkers, 'kmeans', MarkerNames); ################################################### ### code chunk number 11: CalcProps ################################################### All.Proportions <- matrix(0,3^length(PropMarkers),length(HIVMetaData[,1])) rownames(All.Proportions) <- unlist(lapply(ResList[[1]]@PhenoCodes, function(x){return(decodePhenotype( x,ResList[[1]]@MarkerNames[PropMarkers], ResList[[1]]@PartitionsPerMarker))})) for (i in 1:length(ResList)){ All.Proportions[,i] = ResList[[i]]@CellFreqs / ResList[[i]]@CellFreqs[ which(rownames(All.Proportions)=='')] } ################################################### ### code chunk number 12: All.Proportions ################################################### Pvals <- vector(); EffectSize <- vector(); for (i in 1:dim(All.Proportions)[1]){ if (length(which(All.Proportions[i,]!=1))==0){ Pvals[i]=1; EffectSize[i]=0; next; } temp=t.test(All.Proportions[i, Labels==1], All.Proportions[i, Labels==2]) Pvals[i] <- temp$p.value EffectSize[i] <- abs(temp$statistic) } Selected <- which(Pvals<0.05); print(length(Selected)) ################################################### ### code chunk number 13: xtabout ################################################### Selected <- which(p.adjust(Pvals)<0.05); library(xtable) MyTable=cbind(rownames(All.Proportions)[Selected], format(Pvals[Selected], digits=2), format(p.adjust(Pvals)[Selected],digits=3), format(rowMeans(All.Proportions[Selected,]), digits=3)) colnames(MyTable)=c('Phenotype', 'p-value', 'adjusted p-value', 'cell frequency') print(xtable(MyTable, caption='The selected phenotypes, their p-values, adjusted p-values, and cell frequencies'), include.rownames=TRUE, caption.placement = "top");