The Gibbs sampling code of Brynildsen MP, Tran LM, JC Liao "A Gibbs Sampler for the Identification of Gene Expression and Network Connectivity Consistentcy." Bioinformatics, 2006 Dec 15;22(24):3040-6. Epub 2006 Oct 23
was written in the code of Matlab version 6.5.1

The command prompt for execution is:
function [consEvolve,Gene,TF] = gibbsSampling(conn,data,gc,Gene,TF,priors,bt,ConvThresh);

where:
conn: connectivity matrix (genes x tfs)
data: gene expression matrix (genes x experiments)
gc: the max number of iterations if gibbs algorithm has not converged
Gene: column vector of gene names corresponding to those in conn & data (genes x 1)
TF: column vector of TF names corresponding to those in conn (tfs x 1)
priors: value of 1 indicates  informative prior (main text), value of 0 indicates non-informative prior (.5)
bt: probability threshold for Bayesian statistic (default/main text = .9)
ConvThresh: convergence threshold (default/main text = .9)

must be variables in your current workspace.

The program will output the following:
consEvolve: consistency log for those iterations with at least 80% the maximum number of consistent genes (MAX)
Gene: gene identities for those represented in consEvolve
TF: transcription factors ChIP-chip bound to the promoters of genes in consEvolve

Notes:
1: Proportional likelihood for consistency of genes can be obtained by the following command line: likelihood = sum(consEvolve');
2: Note: genes deemed consistent were those with the top MAX likelihoods
3: Note: this algorithm has not been optimized for computation speed. We suggest a number of strategies to keep computation time down: 
	a) Analyze genes with significant expression change (2-fold change up/down in main text)
	b) Analyze expression sets that were obtained in similar environments
	c) To obtain rough estimates, you may decrease ConvThresh


For Questions of Comments on this code email: mbrynild@ucla.edu and liaoj@ucla.edu