### R code from vignette source 'vignettes/MIMOSA/inst/doc/MIMOSA.Rnw' ################################################### ### code chunk number 1: sims ################################################### suppressPackageStartupMessages(require(MIMOSA)) require(data.table) set.seed(100) effect.sizes.fold<-c(3,3,3) NN<-c(80000,50000,40000) Nobs<-rep(NN,3) Nobs<-100000 pu<-rep(1e-4,3) ps<-pu*effect.sizes.fold As<-ps*Nobs Bs<-(Nobs-As) A0<-pu*Nobs B0<-(Nobs-A0) ANTIGEN.STIM<-c("ENV","GAG","POL") ANTIGEN.UNSTIM<-c("negctrl","negctrl","negctrl") CYTOKINE=c("IFNg","IFNg","IFNg") Ncells<-NN TCELLSUB=c("CD4") obs<-100 Nobs<-NN j<-1 ICS<-do.call(rbind,lapply(seq_along(Nobs),function(i){ sim<-MIMOSA:::simulate2(obs=obs,As=As[j],Bs=Bs[j],A0=A0[j],B0=B0[j],NS=NN[i],N0=NN[i],w2=0.5,alternative="greater") stim<-sim[,c("Ns","ns")] unstim<-sim[,c("Nu","nu")] colnames(stim)<-c("NSUB","CYTNUM") colnames(unstim)<-c("NSUB","CYTNUM") df<-rbind(stim,unstim) data.frame(df,ANTIGEN=gl(2,obs,labels=c(ANTIGEN.STIM[i],ANTIGEN.UNSTIM[i])),CYTOKINE=CYTOKINE[i],TCELLSUBSET=TCELLSUB[1],UID=rep(gl(obs,1),2)) })) ICS<-cbind(ICS,Ntot=factor(ICS$NSUB+ICS$CYTNUM)) ICS$Stim<-factor(ICS$Ntot,labels=c("ENV","GAG","POL")) ggplot(ICS)+geom_histogram(aes(x=CYTNUM,fill=(ANTIGEN%in%"negctrl")),alpha=0.5,position="identity")+facet_wrap(~Stim)+scale_fill_discrete("stimulation",labels=c("negctrl","Stim")) ################################################### ### code chunk number 2: loaddata ################################################### require(MIMOSA) head(ICS) ################################################### ### code chunk number 3: Eset ################################################### E<-ConstructMIMOSAExpressionSet(ICS, reference=ANTIGEN%in%"negctrl", measure.columns=c("CYTNUM","NSUB"), other.annotations=c("CYTOKINE","TCELLSUBSET","ANTIGEN","UID","Ntot"), default.cast.formula=component~UID+ANTIGEN+CYTOKINE+TCELLSUBSET+Ntot, .variables=.(TCELLSUBSET,CYTOKINE,UID,Ntot), featureCols=1,ref.append.replace="_REF")