n <- 3 # number of genes
K <- 4 # number of experiments
T_ <- 4 # number of time points
# perturbation vector, entry is 0 if gene is inactivated and 1 otherwise
b <- c(0,1,1, # perturbation exp1: gene 1 perturbed, gene 2,3 unperturbed
1,0,1, # perturbation exp2: gene 2 perturbed, gene 1,3 unperturbed
1,1,0, # perturbation exp3....
1,1,1)
# adjacency matrix
adja <- matrix(c(0,1,0,
0,0,1,
0,0,0), nrow=n, ncol=n, byrow=TRUE)
# define node baseline values
baseline <- c(0.75, 0, 0)
# define delta value
delta <- rep(0.75, n)
# define the parameters for the observation generated from the normal distributions
mu_type <- "single"
active_mu <- 0.9
inactive_mu <- 0.5
active_sd <- inactive_sd <- 0.01
#### kfoldCV
# generate random observation matrix
obs <- array(rnorm(n*K*T_), c(n,K,T_))
# define the observationd to be removed, whose values will be predicted
obs[2,4,2] <- NA
obs[3,4,3] <- NA
rem_entries <- which(is.na(obs), arr.ind=TRUE)
rem_entries_vec <- which(is.na(obs))
# compute the predicted observation matrix for the "kfoldCV"
calcPredictionKfoldCV(obs=obs, delta=delta, b=b, n=n, K=K, adja=adja, baseline=baseline,
rem_entries=rem_entries, rem_entries_vec=rem_entries_vec,
active_mu=active_mu, active_sd=active_sd, inactive_mu=inactive_mu,
inactive_sd=inactive_sd, mu_type=mu_type, flag_time_series=TRUE)
#### LOOCV
# generate random observation matrix
obs <- matrix(rnorm(n*K), nrow=n, ncol=K)
# define the observationd to be removed
rem_k <- 3
rem_gene <- 2
obs[rem_gene, rem_k] <- NA
# compute the predicted value
calcPredictionLOOCV(obs=obs, delta=delta,b=b, n=n ,K=K, adja=adja, baseline=baseline,
rem_gene=rem_gene, rem_k=rem_k, active_mu=active_mu, active_sd=active_sd,
inactive_mu=inactive_mu, inactive_sd=inactive_sd, mu_type=mu_type)
Run the code above in your browser using DataLab