Source

sicb2013 / functions.r

Full commit
test_cov_matrix <- function() {
	# Builds a simple character covariance matrix for simulating data
	
	G <- 100
	
	trueCovariance = matrix(0,G,G)
	trueCovariance[1:10,1:10] = 0.95
	trueCovariance[11:80,11:80] = 0.3
	trueCovariance[81:100,81:100] = 0.7
	diag(trueCovariance) = 1

	return( trueCovariance ) 
}


Array2List <- function(A) {
	s <- dim(A)
	R <- vector("list", s[3])

	for (j in 1:s[3]) {
		R[[j]] <- A[,,j]
	}
	return(R)
}


plot_matrix <- function(m, ... ) {
	
	nr <- nrow(m)
	nc <- ncol(m)
	image(1:nc, 1:nr, t(m[nr:1, ]), axes=F,xlab="", ylab="", ... )
}