This function predict drug response scores based on disease weights using multiple methods. It takes a vector of disease weights and a sparse matrix representing a drug-disease interaction model, and calculates the predicted drug scores using one of three methods: random walk with restart (`rwr`), original spreading activation (`sa`), or Spread-gram (`sg`).
Usage
predict_drug(
disease_weights,
model,
method = c("rwr", "wrwr", "sg", "sa"),
restart_prob = 0.7,
threshold = 1e-06,
max_iter = 1e+06,
loose = 1,
print_weight_only = FALSE
)
Arguments
- disease_weights
A
named vector
of disease weights. The names of the vector should correspond to the disease IDs in the `disease_ids` dataset.- model
- method
A character string specifying the prediction method to use. The drug scores can be predicted using one of these three methods: random walk with restart (either `rwr` or `wrwr`), original spreading activation (`sa`), or Spread-gram (`sg`). The `rwr` method provides a quick calculation for estimating drug scores. If the criterion for using the quick calculation is not met, it falls back to the `wrwr` method.
Default option is `rwr`.
- restart_prob
The restart probability for the random walk with restart method. Default is 0.7.
- threshold
The convergence threshold for the iteration. Recommended value is 1e-6 in `rwr` and 1 in `sg`.
- max_iter
The maximum number of iterations. Default value is 1e6.
- loose
The loose parameter for the original spreading activation method. Default is 1.0.
- print_weight_only
A logical value indicating whether to print only the predicted drug weights. If TRUE, only one numeric vector with all drug weights is returned. If FALSE, a data frame with drug IDs, drug names, and drug weights is returned. Default value is FALSE.
Value
The return value is based on `print_weight_only`. If TRUE, only one numeric vector with all drug weights is returned. If FALSE, a data frame with drug IDs, drug names, and drug weights is returned.
See also
[random_walk()] for technical details of random walk with restart method. [spread_gram()] for technical details of Spread-gram method. [activation_rate()] for technical details of the original spreading activation method.
Examples
# Load example data to the environment
data("drug_annot", package = "labyrinth")
data("disease_ids", package = "labyrinth")
# \donttest{
# Load models to the environment
model <- load_data("model")
# Construct disease weights
disease_weights <- sample(c(rep(0, 50), rep(1, 2)), 1098, replace = TRUE)
names(disease_weights) <- disease_ids
# Predict drug scores based on disease weights
drug_weights <- predict_drug(disease_weights, model, method = "rwr")
#> normalizing column vectors!
#> normalizing column vectors!
#>
#> Attaching package: 'diffusr'
#> The following objects are masked from 'package:labyrinth':
#>
#> assert_dgCMatrix, is.dgCMatrix
# }