#' Custom 2-D convolution wrapper for fixed IGMs or PWMs
#'
#' Custom 2-D convolution wrapper for fixed motifs, such as those coming from a database.
#'
#' @param object Keras model object.
#' @param filters Number of convolutional filters.
#' @param motif_maxlen Maximum length of the motifs.
#' @param fixed.motifs List of motifs to be used as filters.
#' @param fixed.offsets Vector of offset values.
#' @param input_shape Dimensionality of the input (integer) not including the samples axis. This argument is required when using this layer as the first layer in a model.
#' @param strides An integer or list of 2 integers, specifying the strides of the convolution along the width and height. Can be a single integer to specify the same value for all spatial dimensions. Specifying any stride value != 1 is incompatible with specifying any \code{dilation_rate} value != 1.
#' @param padding one of "valid" (default) or "same" (case-insensitive).
#' @param activation Activation function to use. Default is the sigmoid activation.
#' @param use_bias Boolean, whether the layer uses a bias vector. Default is to include a bias.
#' @param name An optional name string for the layer. Should be unique in a model (do not reuse the same name twice). It will be autogenerated if it isn't provided. Default is \code{'fixedMotif_conv'}.
#' @param trainable Whether the layer weights will be updated during training. Default is \code{FALSE}.
#'
#' @return A Keras model with the added layer.
#'
#' @author Matthew Ploenzke, \email{ploenzke@@g.harvard.edu}
#' @keywords conv convolution layer fixedMotif
#'
#' @export
layer_fixedMotif <- function (object,
filters,
motif_maxlen,
fixed.motifs,
fixed.offsets,
input_shape = NULL,
strides = c(1L, 1L),
padding = "valid",
activation = 'sigmoid',
use_bias = TRUE,
name = 'fixedMotif_conv', trainable = FALSE) {
keras::create_layer(keras:::keras$layers$Conv2D, object, list(filters = as.integer(filters),
kernel_size = keras:::as_integer_tuple(c(4,motif_maxlen)), strides = keras:::as_integer_tuple(strides),
padding = padding, data_format = NULL, dilation_rate = c(1L, 1L),
activation = activation, use_bias = use_bias, kernel_initializer = keras::initializer_constant(fixed.motifs),
bias_initializer = keras::initializer_constant(-fixed.offsets), kernel_regularizer = NULL,
bias_regularizer = NULL, activity_regularizer = NULL,
kernel_constraint = NULL, bias_constraint = NULL,
input_shape = keras:::normalize_shape(input_shape), batch_input_shape = keras:::normalize_shape(NULL),
batch_size = keras:::as_nullable_integer(NULL), dtype = NULL,
name = name, trainable = trainable, weights = NULL))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.