Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions R/cycles.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#' a specific cycle.
#'
#' @param graph The input graph.
#' @inheritParams rlang::args_dots_empty
#' @param mode Character constant specifying how to handle directed graphs.
#' `out` follows edge directions, `in` follows edges in the reverse direction,
#' and `all` ignores edge directions. Ignored in undirected graphs.
Expand Down
87 changes: 85 additions & 2 deletions R/glet.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ graphlets.candidate.basis <- function(graph, weights = NULL) {
#'
#' @param graph The input graph, edge directions are ignored. Only simple graph
#' (i.e. graphs without self-loops and multiple edges) are supported.
#' @inheritParams rlang::args_dots_empty
#' @param weights Edge weights. If the graph has a `weight` edge attribute
#' and this argument is `NULL` (the default), then the `weight` edge
#' attribute is used.
Expand Down Expand Up @@ -135,22 +136,76 @@ graphlets.candidate.basis <- function(graph, weights = NULL) {
#' }
#' @family glet
#' @export
graphlet_basis <- function(graph, weights = NULL) {
graphlet_basis <- function(
graph,
...,
weights = NULL
) {
# BEGIN GENERATED ARG_HANDLE: graphlet_basis, do not edit, see tools/generate-migrations.R
if (...length() > 0L) {
.arg_handle <- migrate_recover_args(
list(...),
current = list(weights = weights),
recover_new = c("weights"),
recover_old = c("weights"),
match_names = c("weights"),
match_to = c("weights"),
defaults = list(weights = NULL),
head_args = c("graph"),
fn_name = "graphlet_basis"
)
list2env(.arg_handle$values, environment())
lifecycle::deprecate_soft(
"3.0.0",
what = I(.arg_handle$what),
details = .arg_handle$details
)
}
# END GENERATED ARG_HANDLE

graphlets_candidate_basis_impl(
graph = graph,
weights = weights
)
}

#' @rdname graphlet_basis
#' @inheritParams rlang::args_dots_empty
#' @export
graphlet_proj <- function(
graph,
...,
weights = NULL,
cliques,
niter = 1000,
Mu = rep(1, length(cliques))
) {
# BEGIN GENERATED ARG_HANDLE: graphlet_proj, do not edit, see tools/generate-migrations.R
if (...length() > 0L) {
.arg_handle <- migrate_recover_args(
list(...),
current = list(weights = weights, niter = niter, Mu = Mu),
recover_new = c("weights", "cliques", "niter", "Mu"),
recover_old = c("weights", "cliques", "niter", "Mu"),
match_names = c("weights", "cliques", "niter", "Mu"),
match_to = c("weights", "cliques", "niter", "Mu"),
defaults = list(
weights = NULL,
niter = 1000,
Mu = rep(1, length(cliques))
),
head_args = c("graph"),
fn_name = "graphlet_proj"
)
list2env(.arg_handle$values, environment())
lifecycle::deprecate_soft(
"3.0.0",
what = I(.arg_handle$what),
details = .arg_handle$details
)
}
# END GENERATED ARG_HANDLE

# Argument checks
ensure_igraph(graph)
if (is.null(weights) && "weight" %in% edge_attr_names(graph)) {
Expand Down Expand Up @@ -228,8 +283,36 @@ function() {
}

#' @rdname graphlet_basis
#' @inheritParams rlang::args_dots_empty
#' @export
graphlets <- function(graph, weights = NULL, niter = 1000) {
graphlets <- function(
graph,
...,
weights = NULL,
niter = 1000
) {
# BEGIN GENERATED ARG_HANDLE: graphlets, do not edit, see tools/generate-migrations.R
if (...length() > 0L) {
.arg_handle <- migrate_recover_args(
list(...),
current = list(weights = weights, niter = niter),
recover_new = c("weights", "niter"),
recover_old = c("weights", "niter"),
match_names = c("weights", "niter"),
match_to = c("weights", "niter"),
defaults = list(weights = NULL, niter = 1000),
head_args = c("graph"),
fn_name = "graphlets"
)
list2env(.arg_handle$values, environment())
lifecycle::deprecate_soft(
"3.0.0",
what = I(.arg_handle$what),
details = .arg_handle$details
)
}
# END GENERATED ARG_HANDLE

graphlets_impl(
graph = graph,
weights = weights,
Expand Down
93 changes: 91 additions & 2 deletions R/motifs.R
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ dyad.census <- function(graph) {
#' @param graph Graph object, the input graph.
#' @param size The size of the motif, currently sizes 3 and 4 are supported in
#' directed graphs and sizes 3 to 6 in undirected graphs.
#' @inheritParams rlang::args_dots_empty
#' @param cut.prob Numeric vector giving the probabilities that the search
#' graph is cut at a certain level. Its length should be the same as the size
#' of the motif (the `size` argument).
Expand Down Expand Up @@ -171,7 +172,35 @@ dyad.census <- function(graph) {
#' count <<- count + 1
#' count < 5 # stop after 5 motifs
#' })
motifs <- function(graph, size = 3, cut.prob = NULL, callback = NULL) {
motifs <- function(
graph,
size = 3,
...,
cut.prob = NULL,
callback = NULL
) {
# BEGIN GENERATED ARG_HANDLE: motifs, do not edit, see tools/generate-migrations.R
if (...length() > 0L) {
.arg_handle <- migrate_recover_args(
list(...),
current = list(cut.prob = cut.prob, callback = callback),
recover_new = c("cut.prob", "callback"),
recover_old = c("cut.prob", "callback"),
match_names = c("cut.prob", "callback"),
match_to = c("cut.prob", "callback"),
defaults = list(cut.prob = NULL, callback = NULL),
head_args = c("graph", "size"),
fn_name = "motifs"
)
list2env(.arg_handle$values, environment())
lifecycle::deprecate_soft(
"3.0.0",
what = I(.arg_handle$what),
details = .arg_handle$details
)
}
# END GENERATED ARG_HANDLE

if (!is.null(cut.prob) && length(cut.prob) != size) {
cli::cli_abort("{.arg cut.prob} must be the same length as {.arg size}")
}
Expand Down Expand Up @@ -208,6 +237,7 @@ motifs <- function(graph, size = 3, cut.prob = NULL, callback = NULL) {
#'
#' @param graph Graph object, the input graph.
#' @param size The size of the motif.
#' @inheritParams rlang::args_dots_empty
#' @param cut.prob Numeric vector giving the probabilities that the search
#' graph is cut at a certain level. Its length should be the same as the size
#' of the motif (the `size` argument).
Expand All @@ -223,7 +253,34 @@ motifs <- function(graph, size = 3, cut.prob = NULL, callback = NULL) {
#' motifs(g, 3)
#' count_motifs(g, 3)
#' sample_motifs(g, 3)
count_motifs <- function(graph, size = 3, cut.prob = NULL) {
count_motifs <- function(
graph,
size = 3,
...,
cut.prob = NULL
) {
# BEGIN GENERATED ARG_HANDLE: count_motifs, do not edit, see tools/generate-migrations.R
if (...length() > 0L) {
.arg_handle <- migrate_recover_args(
list(...),
current = list(cut.prob = cut.prob),
recover_new = c("cut.prob"),
recover_old = c("cut.prob"),
match_names = c("cut.prob"),
match_to = c("cut.prob"),
defaults = list(cut.prob = NULL),
head_args = c("graph", "size"),
fn_name = "count_motifs"
)
list2env(.arg_handle$values, environment())
lifecycle::deprecate_soft(
"3.0.0",
what = I(.arg_handle$what),
details = .arg_handle$details
)
}
# END GENERATED ARG_HANDLE

ensure_igraph(graph)

if (!is.null(cut.prob) && length(cut.prob) != size) {
Expand All @@ -248,6 +305,7 @@ count_motifs <- function(graph, size = 3, cut.prob = NULL) {
#' @param graph Graph object, the input graph.
#' @param size The size of the motif, currently size 3 and 4 are supported
#' in directed graphs and sizes 3-6 in undirected graphs.
#' @inheritParams rlang::args_dots_empty
#' @param cut.prob Numeric vector giving the probabilities that the search
#' graph is cut at a certain level. Its length should be the same as the size
#' of the motif (the `size` argument).
Expand All @@ -272,10 +330,41 @@ count_motifs <- function(graph, size = 3, cut.prob = NULL) {
sample_motifs <- function(
graph,
size = 3,
...,
cut.prob = rep(0, size),
sample.size = NULL,
sample = NULL
) {
# BEGIN GENERATED ARG_HANDLE: sample_motifs, do not edit, see tools/generate-migrations.R
if (...length() > 0L) {
.arg_handle <- migrate_recover_args(
list(...),
current = list(
cut.prob = cut.prob,
sample.size = sample.size,
sample = sample
),
recover_new = c("cut.prob", "sample.size", "sample"),
recover_old = c("cut.prob", "sample.size", "sample"),
match_names = c("cut.prob", "sample.size", "sample"),
match_to = c("cut.prob", "sample.size", "sample"),
defaults = list(
cut.prob = rep(0, size),
sample.size = NULL,
sample = NULL
),
head_args = c("graph", "size"),
fn_name = "sample_motifs"
)
list2env(.arg_handle$values, environment())
lifecycle::deprecate_soft(
"3.0.0",
what = I(.arg_handle$what),
details = .arg_handle$details
)
}
# END GENERATED ARG_HANDLE

ensure_igraph(graph)

if (!is.null(cut.prob) && length(cut.prob) != size) {
Expand Down
4 changes: 3 additions & 1 deletion man/count_motifs.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions man/graphlet_basis.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/motifs.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/sample_motifs.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading