Skip to content

Commit

Permalink
Merge pull request #90 from stocnet/develop
Browse files Browse the repository at this point in the history
v1.2.0
  • Loading branch information
jhollway authored Sep 29, 2024
2 parents b8b4732 + ffd2fd0 commit 511b96a
Show file tree
Hide file tree
Showing 67 changed files with 1,225 additions and 338 deletions.
30 changes: 12 additions & 18 deletions .github/workflows/pushrelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,20 @@ jobs:
path: build/

- name: Calculate code coverage
if: runner.os == 'macOS-latest'
run: Rscript -e "covr::codecov()"

release:
name: Bump version and release
if: ${{ always() }}
needs: build
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout one
uses: actions/checkout@master
uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: Bump version and push tag
Expand All @@ -84,24 +86,16 @@ jobs:
DEFAULT_BUMP: patch
RELEASE_BRANCHES: main
- name: Checkout two
uses: actions/checkout@v2
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.newtag.outputs.tag }}
release_name: Release ${{ steps.newtag.outputs.tag }}
draft: false
prerelease: false
uses: actions/checkout@v4

- name: Extract version
run: |
echo "PACKAGE_VERSION=$(grep '^Version' DESCRIPTION | sed 's/.*: *//')" >> $GITHUB_ENV
echo "PACKAGE_NAME=$(grep '^Package' DESCRIPTION | sed 's/.*: *//')" >> $GITHUB_ENV
- name: Download binaries
uses: actions/download-artifact@v4

- name: Display structure of downloaded files
run: ls -R

- name: Rename binaries release
shell: bash
run: |
Expand All @@ -111,9 +105,9 @@ jobs:
cp ./winOS/${{ env.PACKAGE_NAME }}_${{ env.PACKAGE_VERSION }}*.zip .
echo "Renamed files"
ls manynet_*
- name: Create Release and Upload Assets
id: upload_release
id: create_release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.newtag.outputs.tag }}
Expand All @@ -127,7 +121,7 @@ jobs:
manynet_*.tar.gz
manynet_*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

pkgdown:
name: Build and deploy website
Expand Down
5 changes: 2 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: manynet
Title: Many Ways to Make, Modify, Map, Mark, and Measure Myriad Networks
Version: 1.1.0
Date: 2024-09-12
Version: 1.2.0
Date: 2024-09-28
Description: Many tools for making, modifying, mapping, marking, measuring,
and motifs and memberships of many different types of networks.
All functions operate with matrices, edge lists, and 'igraph', 'network', and 'tidygraph' objects,
Expand Down Expand Up @@ -41,7 +41,6 @@ Suggests:
methods,
multiplex,
netdiffuseR,
oaqc,
patchwork,
readxl,
rmarkdown,
Expand Down
12 changes: 11 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,10 @@ S3method(plot,diffs_model)
S3method(plot,learn_model)
S3method(plot,matrix)
S3method(plot,network_measures)
S3method(plot,network_motif)
S3method(plot,node_measure)
S3method(plot,node_member)
S3method(plot,node_motif)
S3method(plot,tie_measure)
S3method(print,diff_model)
S3method(print,diffs_model)
Expand Down Expand Up @@ -296,6 +298,7 @@ export("%>%")
export(.E)
export(.G)
export(.N)
export(add_info)
export(add_node_attribute)
export(add_nodes)
export(add_tie_attribute)
Expand All @@ -321,10 +324,12 @@ export(cluster_hierarchical)
export(create_components)
export(create_core)
export(create_degree)
export(create_ego)
export(create_empty)
export(create_explicit)
export(create_filled)
export(create_lattice)
export(create_motifs)
export(create_ring)
export(create_star)
export(create_tree)
Expand Down Expand Up @@ -406,6 +411,7 @@ export(net_betweenness)
export(net_by_brokerage)
export(net_by_dyad)
export(net_by_mixed)
export(net_by_quad)
export(net_by_triad)
export(net_change)
export(net_closeness)
Expand Down Expand Up @@ -509,6 +515,7 @@ export(network_upperbound)
export(node_adoption_time)
export(node_alpha)
export(node_attribute)
export(node_authority)
export(node_automorphic_equivalence)
export(node_betweenness)
export(node_bridges)
Expand All @@ -517,6 +524,7 @@ export(node_brokering)
export(node_brokering_activity)
export(node_brokering_exclusivity)
export(node_by_brokerage)
export(node_by_dyad)
export(node_by_exposure)
export(node_by_path)
export(node_by_quad)
Expand All @@ -537,13 +545,15 @@ export(node_efficiency)
export(node_effsize)
export(node_eigenvector)
export(node_equivalence)
export(node_equivalency)
export(node_exposure)
export(node_fast_greedy)
export(node_flow)
export(node_fluid)
export(node_harmonic)
export(node_heterophily)
export(node_hierarchy)
export(node_hub)
export(node_in_adopter)
export(node_in_automorphic)
export(node_in_betweenness)
Expand Down Expand Up @@ -665,6 +675,7 @@ export(scale_fill_sdgs)
export(scale_fill_uzh)
export(scale_size)
export(select_ties)
export(set_manynet_theme)
export(summarise_ties)
export(table_data)
export(theme_ethz)
Expand Down Expand Up @@ -909,7 +920,6 @@ importFrom(stats,cor)
importFrom(stats,cutree)
importFrom(stats,hclust)
importFrom(stats,median)
importFrom(tidygraph,"%E>%")
importFrom(tidygraph,.E)
importFrom(tidygraph,.G)
importFrom(tidygraph,.N)
Expand Down
64 changes: 61 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,61 @@
# manynet 1.2.0

## Package

- Added progress updates, information, and unavailability errors to several functions
- These can be silenced by setting `options(manynet_verbosity ="quiet")`
- Where a feature is unavailable, users are directed to the Github issues page
- Added console theme to color the startup and various warning or info messages

## Making

- Added `create_ego()` for collecting ego networks through interviews, including arguments for:
- Indicating whether a roster should be used, otherwise follows a name generator approach
- Indicating whether nodes should be interpreted, i.e. nodal attributes collected
- Indicating whether ties between alters should be requested
- Added `create_motifs()` for creating networks that correspond to the isomorphic subgraphs of certain size and format

## Modifying

- Improved `print.mnet()`
- Prints multiplex types if available
- Prints both nodesets for two-mode networks
- Added `add_info()` for adding grand info to tidygraph objects
- This includes the name of the network, node sets and ties, DOI, year and mode of collection
- Fixed `to_unweighted()` so that it passes through unweighted networks correctly

## Mapping

- Added `set_manynet_theme()` to set theme (re #60), but not yet fully implemented

## Marking

- Improved `is_multiplex()` to ignore "name" tie attributes

## Measuring

- Added `node_authority()` and `node_hub()` centrality measures
- Added `node_equivalency()` for calculating four-cycle closure by node
- Extended `net_equivalency()` to one-mode networks

## Members

- Fixed `node_in_equivalence()` to use census directly

## Motifs

- Added plot methods for network_motif and node_motif classes that use `create_motifs()`
- Added `node_by_dyad()` for node level dyad census
- Added `net_by_quad()` for network level quad census
- Fixed `node_by_quad()` to avoid `{oaqc}` dependency (#89), more flexible but slower
- Fixed `print.node_motif()` to convert to tibble and add modes and names where available only upon print
- The underlying object is still a matrix, used for equivalence and blockmodelling

## Data

- Updated `ison_southern_women` with grand info
- Updated `ison_laterals` with reordered nodes

# manynet 1.1.0

## Package
Expand Down Expand Up @@ -98,7 +156,7 @@
- `table_data()` can now report on data from multiple packages
- `{manynet}` and `{migraph}` are included by default,
and if any are not installed they are just ignored
- `tabe_data()` can now filter by any reported formats,
- `table_data()` can now filter by any reported formats,
such as 'directed' or 'twomode'

## Website
Expand Down Expand Up @@ -198,7 +256,7 @@ including force-directed, layered, circular, spectral, and grid layouts
existing network was incorrect
- Added `generate_configuration()` for generating configuration models
(including for two-mode networks)
- `play_diffuson()` now includes an explicit contact argument to control the
- `play_diffusion()` now includes an explicit contact argument to control the
basis of exposure

## Marking
Expand Down Expand Up @@ -277,7 +335,7 @@ and `node_is_infected()` (closes #71)
`net_balance()`, `net_change()`, and `net_stability()`
- Updated properties from mapping to measuring
- Updated attributes from mapping to measuring
- Renamed `node_mode()` (deprecated) to node_is_mode() since it returns a
- Renamed `node_mode()` (deprecated) to `node_is_mode()` since it returns a
logical vector
- Updated `node_attribute()` and `tie_attribute()` to return measures
when the output is numeric
Expand Down
53 changes: 46 additions & 7 deletions R/class_motifs.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
make_node_motif <- function(out, .data) {
class(out) <- c("node_motif", class(out))
attr(out, "mode") <- node_is_mode(.data)
if(is_twomode(.data)) attr(out, "mode") <- node_is_mode(.data)
if(is_labelled(.data)) attr(out, "dimnames")[[1]] <- node_names(.data)
out
}

Expand All @@ -14,17 +15,55 @@ make_network_motif <- function(out, .data) {
print.node_motif <- function(x, ...,
n = 6,
digits = 3) {
if(!is.null(attr(x, "dimnames")[[1]])){
x <- data.frame(names = attr(x, "dimnames")[[1]], x)
}
if (any(attr(x, "mode"))) {
print(dplyr::tibble(as.data.frame(x)[!attr(x, "mode")]), n = n)
print(dplyr::tibble(as.data.frame(x)[attr(x, "mode")]), n = n)
y <- as.data.frame(x[!attr(x, "mode"),])
z <- as.data.frame(x[attr(x, "mode"),])
if(!is.null(attr(x, "dimnames")[[1]])){
y <- data.frame(names = attr(x, "dimnames")[[1]][!attr(x, "mode")], y)
z <- data.frame(names = attr(x, "dimnames")[[1]][attr(x, "mode")], z)
}
print(dplyr::tibble(y), n = n)
print(dplyr::tibble(z), n = n)
} else {
print(dplyr::tibble(as.data.frame(x)), n = n)
if(!is.null(attr(x, "dimnames")[[1]])){
x <- data.frame(names = attr(x, "dimnames")[[1]], x)
} else x <- as.data.frame(x)
print(dplyr::tibble(x), n = n)
}
}

#' @export
plot.node_motif <- function(x, ...) {
motifs <- dimnames(x)[[2]]
if("X4" %in% motifs){
graphs(create_motifs(4), waves = 1:11)
} else if("021D" %in% motifs){
graphs(create_motifs(3, directed = TRUE), waves = 1:16)
} else if("102" %in% motifs){
graphs(create_motifs(3), waves = 1:4)
} else if("Asymmetric" %in% motifs){
graphs(create_motifs(2, directed = TRUE), waves = 1:3)
} else if("Mutual" %in% motifs){
graphs(create_motifs(2), waves = 1:2)
} else mnet_unavailable("Cannot plot these motifs yet, sorry.")
}

#' @export
plot.network_motif <- function(x, ...) {
motifs <- dimnames(x)[[2]]
if("X4" %in% motifs){
graphs(create_motifs(4), waves = 1:11)
} else if("021D" %in% motifs){
graphs(create_motifs(3, directed = TRUE), waves = 1:16)
} else if("102" %in% motifs){
graphs(create_motifs(3), waves = 1:4)
} else if("Asymmetric" %in% motifs){
graphs(create_motifs(2, directed = TRUE), waves = 1:3)
} else if("Mutual" %in% motifs){
graphs(create_motifs(2), waves = 1:2)
} else mnet_unavailable("Cannot plot these motifs yet, sorry.")
}

# summary(node_by_triad(mpn_elite_mex),
# membership = node_regular_equivalence(mpn_elite_mex, "elbow"))
#' @export
Expand Down
40 changes: 32 additions & 8 deletions R/class_networks.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,23 @@
print.mnet <- function(x, ..., n = 6) {
arg_list <- list(...)
arg_list[['useS4']] <- NULL
if(is_grand(x) && !is.null(igraph::graph_attr(x, "grand")$name))
cli::cli_text("# {igraph::graph_attr(x, 'grand')$name}")
graph_desc <- describe_graph(x)
tie_desc <- describe_ties(x)
node_desc <- describe_nodes(x)
cli::cli_text("# {graph_desc} network of {node_desc} and {tie_desc}")
top <- dplyr::as_tibble(tidygraph::activate(x, "nodes"))
bottom <- dplyr::as_tibble(tidygraph::activate(x, "edges"))
if(is.null(igraph::graph_attr(x, "grand"))) node_name <- "nodes" else
node_name <- igraph::graph_attr(x, "grand")$vertex1
if(is.null(igraph::graph_attr(x, "grand")))
tie_name <- ifelse(is_directed(x), "arcs", "ties") else
tie_name <- paste(igraph::graph_attr(x, "grand")$edge.pos,
ifelse(is_directed(x), "arcs", "ties"))
cat('#', graph_desc, 'network of', igraph::gorder(x), node_name, 'and',
igraph::gsize(x), tie_name, '\n', sep = ' ')
if (ncol(top)>0) print(top, n = n)
if (ncol(bottom)>0) print(bottom, n = n, max_footer_lines = 1)
invisible(x)
}

is_grand <- function(.data){
!is.null(igraph::graph_attr(.data, "grand"))
}

describe_graph <- function(x) {
paste0("A ",
ifelse(is_dynamic(x), "dynamic, ", ""),
Expand All @@ -35,3 +36,26 @@ describe_graph <- function(x) {
ifelse(is_directed(x), "directed", "undirected"))
)
}

describe_nodes <- function(x){
nd <- net_dims(x)
if(!is.null(igraph::graph_attr(x, "grand")$vertex1)){
node_name <- paste(nd[1], igraph::graph_attr(x, "grand")$vertex1)
if(length(nd)==2 && !is.null(igraph::graph_attr(x, "grand")$vertex2))
node_name <- c(node_name, paste(nd[2], igraph::graph_attr(x, "grand")$vertex2))
} else node_name <- paste(sum(nd), "nodes")
node_name
}

describe_ties <- function(x){
nt <- net_ties(x)
tie_name <- ifelse(is_directed(x), "arcs", "ties")
if(!is.null(igraph::graph_attr(x, "grand")$edge.pos)){
tie_name <- paste(igraph::graph_attr(x, "grand")$edge.pos,
tie_name)
} else if(!is.null(tie_attribute(x, "type"))){
tie_name <- paste(cli::ansi_collapse(unique(tie_attribute(x, "type"))),
tie_name)
}
paste(nt, tie_name)
}
Loading

0 comments on commit 511b96a

Please sign in to comment.