## Not run:
# #test data
# data(YeastCellCycle2)
# data.y1 <- YeastCellCycle2$normalizedData.WT
# data.x1 <- YeastCellCycle2$designMatrix.WT
# data.y2 <- YeastCellCycle2$normalizedData.SM
# data.x2 <- YeastCellCycle2$designMatrix.SM
# n.clst <- 8
# fit1 <- fit.CLMM.2(data.y1=data.y1,data.x1=data.x1,data.z1=data.x1,
# data.y2=data.y2,data.x2=data.x2,data.z2=data.x2,
# n.clst=n.clst)
# fit1.u <- apply(fit1$u.hat, MARGIN=1, FUN=order, decreasing=TRUE)[1,]
# zeta.fitted <- fit1$theta.hat$zeta.hat
# profile.WT <- YeastCellCycle2$designMatrix.WT[1,,] %*% t(zeta.fitted)
# profile.SM <- YeastCellCycle2$designMatrix.SM[1,,] %*% t(zeta.fitted)
# # remove bad time points for WTs and SMs
# n.time <- 25
# time.WT <- (1:n.time)[-22]
# time.SM <- (1:n.time)[-c(6,9,12)]
# n.rpl.WT<- length(time.WT)
# n.rpl.SM<- length(time.SM)
# n.gene.short<-dim(YeastCellCycle2$normalizedData.WT)[1]
# # gene-specific profile: observed profiles averaged over replicates
# data.WT.mean <- matrix(0, nrow=n.gene.short, ncol=n.rpl.WT)
# data.SM.mean <- matrix(0, nrow=n.gene.short, ncol=n.rpl.SM)
# for(j in 1:n.gene.short){
# data.WT.mean[j,] <- (YeastCellCycle2$normalizedData.WT[j,1,]+
# YeastCellCycle2$normalizedData.WT[j,2,])/2
# data.SM.mean[j,] <- (YeastCellCycle2$normalizedData.SM[j,1,]+
# YeastCellCycle2$normalizedData.SM[j,2,])/2
# }
# # plot observed profiles by cluster -- wild type
# col.panel=rainbow(8)
# par(mai=c(0.3,0.25,0.2,0.05),mfrow=c(3,3))
# for(k in 1:n.clst){
# plot(5*(time.WT-1), profile.WT[,k], type="l", col=col.panel[k], ylim=c(-2,2),
# xlab="Time", ylab="Expression Value", main=paste("WT: cluster",k))
# i.plot <- (1:n.gene.short)[fit1.u==k]
# for(j in i.plot) lines(5*(time.WT-1), data.WT.mean[j,], lty=1)
# lines(5*(time.WT-1), profile.WT[,k], col=col.panel[k], lwd=2)
# text(125, -1.9, pos=2, paste(length(i.plot)," genes"))
# }
# # plot observed profiles by cluster -- single mutant
# par(mai=c(0.3,0.25,0.2,0.05),mfrow=c(3,3))
# for(k in 1:n.clst){
# plot(5*(time.SM-1), profile.SM[,k], type="l", col=col.panel[k], ylim=c(-2,2),
# xlab="Time", ylab="Expression Value", main=paste("SM: cluster",k))
# i.plot <- (1:n.gene.short)[fit1.u==k]
# for(j in i.plot) lines(5*(time.SM-1), data.SM.mean[j,], lty=1)
# lines(5*(time.SM-1), profile.SM[,k], col=col.panel[k], lwd=2)
# text(125, -1.9, pos=2, paste(length(i.plot)," genes"))
# }
# # plot fitted profiles by cluster
# par(mai=c(0.3,0.25,0.2,0.05),mfrow=c(3,3))
# for(k in 1:n.clst){
# plot(5*(time.WT-1), profile.WT[,k], type="l", ylim=c(-2,2),
# xlab="Time", ylab="Expression Value", lwd=2)
# title(paste("Cluster", k))
# lines(5*(time.SM-1), profile.SM[,k], lty=3, lwd=2)
# if(k==1) legend(60, 2, c("WT", "SM"), lty=1:2, cex=0.8)
# }
# ## End(Not run)
Run the code above in your browser using DataLab