tests/runitGenerateTimeSeriesNetStates.R

test.generateTimeSeriesGeneStates <- function() {
	
	n <- 10
	K <- 11
	T_ <- 6

	true_result <- array(NA, c(n,K,T_))
	
	true_result[ , , 1] <- matrix(c(0,0,0,0,0,0,0,0,0,0,0,
																	0,0,0,0,0,0,0,0,0,0,0,
																	0,0,0,0,0,0,0,0,0,0,0,
																	0,0,0,0,0,0,0,0,0,0,0,
																	0,0,0,0,0,0,0,0,0,0,0,
																	0,0,0,0,0,0,0,0,0,0,0,
																	0,0,0,0,0,0,0,0,0,0,0,
																	0,0,0,0,0,0,0,0,0,0,0,
																	0,0,0,0,0,0,0,0,0,0,0,
																	0,0,0,0,0,0,0,0,0,0,0), nrow=n, ncol=K, byrow=TRUE)
																	
	true_result[ , , 2] <- matrix(c(0,0,0,0,0,0,0,0,0,0,0,
																	0,0,0,0,0,0,0,0,0,0,0,
																	0,0,0,0,0,0,0,0,0,0,0,
																	1,1,1,0,1,1,1,1,1,1,1,
																	0,0,0,0,0,0,0,0,0,0,0,
																	0,0,0,0,0,0,0,0,0,0,0,
																	0,0,0,0,0,0,0,0,0,0,0,
																	1,1,1,1,1,1,1,0,1,1,1,
																	0,0,0,0,0,0,0,0,0,0,0,
																	0,0,0,0,0,0,0,0,0,0,0), nrow=n, ncol=K, byrow=TRUE)
																	
	true_result[ , , 3] <- matrix(c(0,1,1,0,1,1,1,1,1,1,1,
																	0,0,0,0,0,0,0,0,0,0,0,
																	0,0,0,0,0,0,0,0,0,0,0,
																	1,1,1,0,1,1,1,1,1,1,1,
																	1,1,1,0,0,1,1,1,1,1,1,
																	1,1,1,1,1,0,1,0,1,1,1,
																	0,0,0,0,0,0,0,0,0,0,0,
																	1,1,1,1,1,1,1,0,1,1,1,
																	0,0,0,0,0,0,0,0,0,0,0,
																	0,0,0,0,0,0,0,0,0,0,0), nrow=n, ncol=K, byrow=TRUE)
																	
	true_result[ , , 4] <- matrix(c(0,1,1,0,1,1,1,1,1,1,1,
																	1,0,1,1,1,1,1,1,1,1,1,
																	1,1,0,1,1,1,1,1,1,1,1,
																	1,1,1,0,1,1,1,1,1,1,1,
																	1,1,1,0,0,1,1,1,1,1,1,
																	1,1,1,1,1,0,1,0,1,1,1,
																	0,0,0,1,1,0,0,0,0,0,0,
																	1,1,1,1,1,1,1,0,1,1,1,
																	0,0,0,0,0,1,0,1,0,0,0,
																	0,0,0,0,0,0,0,0,0,0,0), nrow=n, ncol=K, byrow=TRUE)
																	
	true_result[ , , 5] <- matrix(c(0,1,1,0,1,1,1,1,1,1,1,
																	1,0,1,1,1,1,1,1,1,1,1,
																	1,1,0,1,1,1,1,1,1,1,1,
																	1,1,1,0,1,1,1,1,1,1,1,
																	1,1,1,1,0,1,1,1,1,1,1,
																	1,1,1,1,1,0,1,1,1,1,1,
																	0,0,0,1,1,0,0,0,0,0,0,
																	1,1,1,1,1,1,1,0,1,1,1,
																	0,0,0,0,0,1,0,1,0,0,0,
																	1,0,1,1,1,1,1,1,1,0,1), nrow=n, ncol=K, byrow=TRUE)
	
	true_result[ , , 6] <- matrix(c(0,1,1,0,1,1,1,1,1,1,1,
																	1,0,1,1,1,1,1,1,1,1,1,
																	1,1,0,1,1,1,1,1,1,1,1,
																	1,1,1,0,1,1,1,1,1,1,1,
																	1,1,1,1,0,1,1,1,1,1,1,
																	1,1,0,1,1,0,1,0,1,1,1,
																	0,0,0,0,1,0,0,0,0,0,0,
																	1,1,1,1,1,1,1,0,1,1,1,
																	0,0,0,0,0,1,0,0,0,0,0,
																	1,0,1,1,1,1,1,1,1,0,1), nrow=n, ncol=K, byrow=TRUE)

	T_nw <- matrix(c(0,0,1,0,0,0,0,0,0,0,
									 0,0,0,0,0,0,0,0,0,1,
									 0,1,0,0,1,1,0,0,0,0,
									 1,0,0,0,1,0,0,0,0,0,
									 0,1,0,0,0,0,-1,0,1,0,
									 0,1,1,0,0,0,1,0,-1,0,
									 0,1,0,0,1,0,0,0,0,0,
									 0,0,0,0,0,1,0,0,0,0,
									 0,0,0,0,0,0,0,0,0,0,
									 0,0,0,0,1,-1,0,0,0,0), nrow=n, ncol=n, byrow=T)

	b <- c(0,1,1,1,1,1,1,1,1,1,
				 1,0,1,1,1,1,1,1,1,1,
				 1,1,0,1,1,1,1,1,1,1,
				 1,1,1,0,1,1,1,1,1,1,
				 1,1,1,1,0,1,1,1,1,1,
				 1,1,1,1,1,0,1,1,1,1,
				 1,1,1,1,1,1,0,1,1,1,
				 1,1,1,1,1,1,1,0,1,1,
				 1,1,1,1,1,1,1,1,0,1,
				 1,1,1,1,1,1,1,1,1,0,
				 1,1,1,1,1,1,1,1,1,1)

	
	gene_states <- generateTimeSeriesNetStates(nw_und=T_nw, b=b, n=n, K=K, T_user=NULL)

	checkEquals(true_result, gene_states$node_state_vec)
}


test.generateTimeSeriesGeneStatesT10 <- function() {
	
	n <- 10
	K <- 11
	T_ <- 6

	T_nw <- matrix(c(0,0,1,0,0,0,0,0,0,0,
									 0,0,0,0,0,0,0,0,0,1,
									 0,1,0,0,1,1,0,0,0,0,
									 1,0,0,0,1,0,0,0,0,0,
									 0,1,0,0,0,0,-1,0,1,0,
									 0,1,1,0,0,0,1,0,-1,0,
									 0,1,0,0,1,0,0,0,0,0,
									 0,0,0,0,0,1,0,0,0,0,
									 0,0,0,0,0,0,0,0,0,0,
									 0,0,0,0,1,-1,0,0,0,0), nrow=n, ncol=n, byrow=T)

	b <- c(0,1,1,1,1,1,1,1,1,1,
				 1,0,1,1,1,1,1,1,1,1,
				 1,1,0,1,1,1,1,1,1,1,
				 1,1,1,0,1,1,1,1,1,1,
				 1,1,1,1,0,1,1,1,1,1,
				 1,1,1,1,1,0,1,1,1,1,
				 1,1,1,1,1,1,0,1,1,1,
				 1,1,1,1,1,1,1,0,1,1,
				 1,1,1,1,1,1,1,1,0,1,
				 1,1,1,1,1,1,1,1,1,0,
				 1,1,1,1,1,1,1,1,1,1)

	
	gene_states <- generateTimeSeriesNetStates(nw_und=T_nw, b=b, n=n, K=K, T_user=10)
	
	checkEquals(10, gene_states$T_)
}

Try the lpNet package in your browser

Any scripts or data that you put into this service are public.

lpNet documentation built on Nov. 8, 2020, 7:08 p.m.