#Example 1
#test data
data(YeastCellCycle)
data.y <- YeastCellCycle$normalizedData.sample
data.x <- YeastCellCycle$designMatrix
#fit the model
n.clst <- 6
fit1 <- fit.CLMM(data.y, data.x, data.x, n.clst)
fit1.u <- apply(fit1$u.hat, MARGIN=1, FUN=order, decreasing=TRUE)[1,]
zeta.fitted <- fit1$theta.hat$zeta.hat
profile <- data.x[1,,] %*% t(zeta.fitted)
#display the profile of each cluster
n.knots <- 7
plot.x <- n.knots*(1:dim(data.y)[3]-1)
par(mfrow=c(2, ceiling((n.clst)/2)),mai=c(0.5,0.5,0.5,0.1),mgp=c(1,0.3,0))
for(k in 1:n.clst){
# plot the fitted cluster-specific profiles
plot(plot.x,profile[,k],type="l",
ylim=c(-2,2), main=paste("Cluster",k),
xlab="time (min)", ylab=NA,xaxt="n",lwd=2)
axis(side=1, at=plot.x[(1:8)*2-1], labels=paste(plot.x[(1:8)*2-1]), cex.axis=0.8)
# plot the observed profiles for genes in this cluster
i.plot <- (1:dim(data.y)[1])[fit1.u==k]
for(j in i.plot) { lines(plot.x, data.y[j,1,], lty=3, lwd=1)}
text(84,-1.9, paste(length(which(fit1.u==k)),"genes"))
}
## Not run:
# #Example 2
# #test data
# data(YeastCellCycle2)
# data.y <- YeastCellCycle2$normalizedData.WT
# data.x <- YeastCellCycle2$designMatrix.WT
# #fit the model
# n.clst <- 8
# fit1 <- fit.CLMM(data.y,data.x[,,1:9],data.x[,,1:9],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,,1:9] %*% t(zeta.fitted)
# #display the profile of each cluster
# # remove bad time points for WTs
# n.time <- 25
# time.WT <- (1:n.time)[-22]
# n.rpl.WT<- length(time.WT)
# n.gene.short<- dim(data.y)[1]
# # gene-specific profile: observed profiles averaged over replicates
# data.WT.mean <- matrix(0, nrow=n.gene.short, ncol=n.rpl.WT)
# for(j in 1:n.gene.short){
# data.WT.mean[j,] <- (data.y[j,1,]+data.y[j,2,])/2
# }
# # plot observed profiles by cluster
# col.panel=rainbow(8)
# par(mfrow=c(3, 3),mai=c(0.3,0.25,0.2,0.05))
# 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"))
# }
# ## End(Not run)
Run the code above in your browser using DataLab