Skip to contents

Creates a heatmap from output of integrated_gradients function. The first row contains the column-wise absolute sums of IG scores and the second row the sums. Rows 3 to 6 contain the IG scores for each position and each nucleotide. The last row contains nucleotide information.

Usage

heatmaps_integrated_grad(integrated_grads, input_seq)

Arguments

integrated_grads

Matrix of integrated gradient scores (output of integrated_gradients function).

input_seq

Input sequence for model. Should be the same as input_seq input for corresponding integrated_gradients call that computed input for integrated_grads argument.

Value

A list of heatmaps.

Examples

if (FALSE) { # reticulate::py_module_available("tensorflow") && requireNamespace("ComplexHeatmap", quietly = TRUE)
library(reticulate)
model <- create_model_lstm_cnn(layer_lstm = 8, layer_dense = 3, maxlen = 20, verbose = FALSE)
random_seq <- sample(0:3, 20, replace = TRUE)
input_seq <- array(keras::to_categorical(random_seq), dim = c(1, 20, 4))
ig <- integrated_gradients(
  input_seq = input_seq,
  target_class_idx = 3,
  model = model)
heatmaps_integrated_grad(integrated_grads = ig,
                         input_seq = input_seq)
 
}