Skip to content

Commit

Permalink
Merge pull request #296 from stocnet/develop
Browse files Browse the repository at this point in the history
v1.4.1
  • Loading branch information
jhollway committed Jul 19, 2024
2 parents 74b8590 + 0b013c6 commit 88dfd15
Show file tree
Hide file tree
Showing 15 changed files with 89 additions and 128 deletions.
24 changes: 7 additions & 17 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: migraph
Title: Univariate and multivariate tests for multimodal and other networks
Version: 1.4.0
Date: 2024-07-18
Title: Univariate and Multivariate Tests for Multimodal and Other Networks
Version: 1.4.1
Date: 2024-07-19
Description: A set of tools for testing networks.
It includes functions for univariate and multivariate
conditional uniform graph and quadratic assignment procedure testing,
Expand All @@ -24,25 +24,15 @@ Depends:
manynet
Imports:
dplyr (>= 1.1.0),
generics,
ggplot2,
igraph (>= 1.5.0),
network,
future,
furrr,
purrr,
tidygraph,
tidyr
generics,
ggplot2,
purrr
Suggests:
concaveman,
covr,
ggdendro,
minMSE,
oaqc,
roxygen2,
rsconnect,
testthat,
xml2
testthat
Authors@R:
c(person(given = "James",
family = "Hollway",
Expand Down
23 changes: 1 addition & 22 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,22 @@ S3method(print,network_test)
S3method(tidy,netlm)
S3method(tidy,netlogit)
export("%>%")
export(.E)
export(.G)
export(.N)
export(aes)
export(as.network)
export(bind_edges)
export(ggplot)
export(ggsave)
export(ggtitle)
export(glance)
export(guides)
export(is.network)
export(is.tbl_graph)
export(is_igraph)
export(labs)
export(mutate)
export(net_regression)
export(network_reg)
export(rename)
export(scale_y_discrete)
export(test_distribution)
export(test_fit)
export(test_gof)
export(test_permutation)
export(test_random)
export(tidy)
export(with_graph)
export(xlab)
export(ylab)
importFrom(dplyr,"%>%")
Expand All @@ -54,25 +44,14 @@ importFrom(ggplot2,labs)
importFrom(ggplot2,scale_y_discrete)
importFrom(ggplot2,xlab)
importFrom(ggplot2,ylab)
importFrom(igraph,is_igraph)
importFrom(manynet,bind_node_attributes)
importFrom(manynet,generate_random)
importFrom(manynet,is_complex)
importFrom(manynet,is_directed)
importFrom(network,as.network)
importFrom(network,is.network)
importFrom(purrr,flatten)
importFrom(stats,as.formula)
importFrom(stats,binomial)
importFrom(stats,df.residual)
importFrom(stats,glm.fit)
importFrom(stats,pchisq)
importFrom(stats,quantile)
importFrom(tidygraph,.E)
importFrom(tidygraph,.G)
importFrom(tidygraph,.N)
importFrom(tidygraph,bind_edges)
importFrom(tidygraph,is.tbl_graph)
importFrom(tidygraph,mutate)
importFrom(tidygraph,rename)
importFrom(tidygraph,with_graph)
18 changes: 18 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
# migraph 1.4.1

2024-07-19

## Package

- Made package title Title Case in DESCRIPTION
- Added alttext to icons used in pkgdown site
- Added CRAN link in pkgdown site
- Removed unnecessary reexports
- Dropped 6 Suggests dependencies
- Dropped 4 Imports dependencies (including `{tidyr}`, see below)

## Models

- `network_reg()` renamed to `net_regression()` for consistency
- Refactored several functions to avoid `{tidyr}` dependency for pivoting longer and wider

# migraph 1.4.0

2024-07-18
Expand Down
22 changes: 18 additions & 4 deletions R/class_models.R
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,15 @@ plot.netlm <- function(x, ...){
distrib <- as.data.frame(distrib)
names(distrib) <- x$names
distrib$obs <- seq_len(nrow(distrib))
distrib <- tidyr::pivot_longer(distrib,
cols = 1:(ncol(distrib)-1))
distrib <- stats::reshape(data = distrib, # tidyr::pivot_longer replacement
direction = "long",
varying = colnames(distrib)[-ncol(distrib)],
v.names = "value",
times = colnames(distrib)[-ncol(distrib)],
timevar = "name")
rownames(distrib) <- NULL
distrib$id <- NULL
distrib <- dplyr::arrange(distrib, obs)
distrib$coef <- rep(unname(x$coefficients), nrow(x$dist))
distrib$tstat <- rep(unname(x$tstat), nrow(x$dist))
distrib$name <- factor(distrib$name, x$names)
Expand All @@ -158,8 +165,15 @@ plot.netlogit <- function(x, ...){
distrib <- as.data.frame(distrib)
names(distrib) <- x$names
distrib$obs <- seq_len(nrow(distrib))
distrib <- tidyr::pivot_longer(distrib,
cols = 1:(ncol(distrib)-1))
distrib <- stats::reshape(data = distrib, # tidyr::pivot_longer replacement
direction = "long",
varying = colnames(distrib)[-ncol(distrib)],
v.names = "value",
times = colnames(distrib)[-ncol(distrib)],
timevar = "name")
rownames(distrib) <- NULL
distrib$id <- NULL
distrib <- dplyr::arrange(distrib, obs)
distrib$coef <- rep(unname(x$coefficients), nrow(x$dist))
distrib$tstat <- rep(unname(x$tstat), nrow(x$dist))
distrib$name <- factor(distrib$name, x$names)
Expand Down
13 changes: 13 additions & 0 deletions R/migraph-defunct.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,16 @@ test_gof <- function(diff_model, diff_models) {
old = "test_gof")
test_fit(diff_model, diff_models)
}

#' @describeIn defunct Deprecated on 2024-07-19.
#' @export
network_reg <- function(formula, .data,
method = c("qap","qapy"),
times = 1000,
strategy = "sequential",
verbose = FALSE) {
.Deprecated("net_regression", package = "migraph",
old = "network_reg")
net_regression(formula, .data, method, times,
strategy, verbose)
}
2 changes: 1 addition & 1 deletion R/migraph-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ thisRequires <- function(pkgname){
}

# defining global variables more centrally
utils::globalVariables(c(".data", ".graph_context"))
utils::globalVariables(c(".data", "obs"))
4 changes: 2 additions & 2 deletions R/model_regression.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@
#'
#' @examples
#' networkers <- ison_networkers %>% to_subgraph(Discipline == "Sociology")
#' model1 <- network_reg(weight ~ alter(Citations) + sim(Citations),
#' model1 <- net_regression(weight ~ ego(Citations) + alter(Citations) + sim(Citations),
#' networkers, times = 20)
#' # Should be run many more `times` for publication-ready results
#' tidy(model1)
#' glance(model1)
#' plot(model1)
#' @export
network_reg <- function(formula, .data,
net_regression <- function(formula, .data,
method = c("qap","qapy"),
times = 1000,
strategy = "sequential",
Expand Down
9 changes: 4 additions & 5 deletions R/model_tests.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ test_random <- function(.data, FUN, ...,
times = 1000,
strategy = "sequential",
verbose = FALSE){
if(missing(.data)) {expect_nodes(); .data <- .G()}
args <- unlist(list(...))
if (!is.null(args)) {
obsd <- FUN(.data, args)
Expand Down Expand Up @@ -71,6 +70,7 @@ test_random <- function(.data, FUN, ...,
class(out) <- "network_test"
out
}

#' @rdname tests
#' @examples
#' # (qaptest <- test_permutation(marvel_friends,
Expand All @@ -82,7 +82,6 @@ test_permutation <- function(.data, FUN, ...,
times = 1000,
strategy = "sequential",
verbose = FALSE){
if(missing(.data)) {expect_nodes(); .data <- .G()}
args <- unlist(list(...))
if (!is.null(args)) {
obsd <- FUN(.data, args)
Expand Down Expand Up @@ -231,13 +230,13 @@ test_fit <- function(diff_model, diff_models){ # make into method?
x <- diff_model
y <- diff_models
sim <- `0` <- NULL
sims <- y |> dplyr::select(sim, t, I) |>
tidyr::pivot_wider(names_from = t, values_from = I) |>
dplyr::select(-c(sim, `0`))
sims <- y |> dplyr::select(sim, t, I)
sims <- as.data.frame.matrix(stats::xtabs(I ~ sim + t, sims)) # tidyr::pivot_wider replacement
sims <- sims[,colSums(stats::cov(sims))!=0]
mah <- stats::mahalanobis(x$I[-1], colMeans(sims), stats::cov(sims))
pval <- pchisq(mah, df=length(x$I[-1]), lower.tail=FALSE)
dplyr::tibble(statistic = mah, p.value = pval,
df = length(x$I[-1]), nobs = nrow(sims))
}


56 changes: 0 additions & 56 deletions R/reexports_classes.R
Original file line number Diff line number Diff line change
@@ -1,61 +1,5 @@
#' @importFrom igraph is_igraph
#' @export
igraph::is_igraph

#' @importFrom network is.network
#' @export
network::is.network

#' @importFrom network as.network
#' @export
network::as.network

#' @importFrom dplyr %>%
#' @export
dplyr::`%>%`

#' @importFrom tidygraph with_graph
#' @export
tidygraph::with_graph

#' @importFrom tidygraph is.tbl_graph
#' @export
tidygraph::is.tbl_graph

#' @importFrom tidygraph .G
#' @export
tidygraph::.G

#' @importFrom tidygraph .N
#' @export
tidygraph::.N

#' @importFrom tidygraph .E
#' @export
tidygraph::.E

#' @importFrom tidygraph mutate
#' @export
tidygraph::mutate

#' @importFrom tidygraph rename
#' @export
tidygraph::rename

#' @importFrom tidygraph bind_edges
#' @export
tidygraph::bind_edges

expect_nodes <- function() {
if (!.graph_context$free() && .graph_context$active() != "nodes") {
stop("This call requires nodes to be active", call. = FALSE)
}
}

expect_edges <- function() {
if (!.graph_context$free() && .graph_context$active() != "edges") {
stop("This call requires edges to be active", call. = FALSE)
}
}

# #' @importFrom rlang `%||%`
2 changes: 2 additions & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@

* This release is expected to create errors with older versions of manynet,
but should create no errors with the latest version
* Currently binaries of manynet have been built for most flavors, with the exception of r-release-windows-x86_66
* There is expected to be test errors for this flavor until a manynet binary for v1.0.1 has been built
* Since manynet is a Depends for migraph, this should not pose a problem for users
upgrading
12 changes: 12 additions & 0 deletions man/defunct.Rd

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

2 changes: 1 addition & 1 deletion man/migraph-package.Rd

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

17 changes: 0 additions & 17 deletions man/reexports.Rd

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

Loading

0 comments on commit 88dfd15

Please sign in to comment.