# \donttest{
node_file <- system.file("extdata", "IL17.nodes.csv", package = "Rato")
edge_file <- system.file("extdata", "IL17.edges.csv", package = "Rato")
g <- Rato::graph.from.csv(node_file, edge_file, sep=",", header=TRUE)
initial_params = list('f' = 1, 'h'=2, 'B'=0.01)
removal_order = NULL
update_params = identity
reduction = identity
initial_parameter_function <- function(M) {
if (is.list(initial_params)) {
params <- initial_params
}
else if (is.function(initial_params)) {
params <- initial_params(M)
}
n <- nrow(M) # The number of nodes of the graph
if(is.null(removal_order)){
removal_order <- sample(1:n, n)
}
if(is.null(params$M)){
params$M = M
}
params$removal_order = removal_order
return(params)
}
perturbation <- function(params, iter) {
removal_order <- params$removal_order
M <- params$M
if(length(removal_order) > 0 ) {
index <- removal_order[1]
removal_order <- removal_order[-1]
M[index, ] <- 0 # Remove entries
M[, index] <- 0 # Remove entries
params$M = M
params$removal_order = removal_order
# Add the list of removed indices to the parameter list.
if(is.null(params$removed_indices)){
params$removed_indices <- c(index)
} else {
removed_indices <- c(params$removed_indices, index)
params$removed_indices <- removed_indices
}
output <- update_params(params)
return(output) # Return updated parameters
}
# If we removed every single entry, just STOP.
return(NULL)
}
Rato::perturbation.thread( Rato::Michaelis.Menten
, g$M
, g$initial_values
, initial_parameter_function = initial_parameter_function
, perturbation_function = perturbation)
# }
Run the code above in your browser using DataLab