# R macros for performing mixture # modelling of genes and samples with # microarray data # Note: these macros require the mclust and mva libraries; # both can be downloaded from the following URL: # # http://cran.r-project.org/ ClusterGenes <- function(data,covstruct1="VI",ngroups = 40,covstruct2="VI",K=1000) { # data should be in the form of a n x m matrix, # where n is the number of genes and m is the number # of experimental conditions (i.e. number of genechips) # # K = number of groups to cluster into using k-means clustering # # covstruct1 is the covariance structure to use in the # hierarchical agglomeration step # # covstruct2 is the covariance structure to use in the # expectation-maximization (EM) algorithm estimation procedure kmg1 <- kmeans(data,K) mht1 <- mhtree(data,modelid=covstruct1,partition=kmg1$cluster) mhc1 <- mhclass(mht1,ngroups) tmp <- me(data,modelid=covstruct2,ctoz(mhc1[,1])) list(out=tmp) } clustersamps <- function(data,covstruct="VI",nprincomp=2) { # data should be in the form of a n x m matrix, # where n is the number of genes and m is the number # of experimental conditions (i.e. number of genechips) # pcx <- prcomp(t(data))$x bic1 <- emclust(pcx[,1:nprincomp],nclus=1:6,modelid=covstruct) tmp <- summary(bic1,cmm.pcx[,1:nprincomp]) list(out=tmp) }