Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.2.0 #90

Merged
merged 47 commits into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
a014059
Added some progress updates on lengthier functions
jhollway Sep 16, 2024
d8805e4
Fixed spelling errors
jhollway Sep 16, 2024
70440c6
Removed size for loops in `graphr()` to avoid issues with plotting co…
henriquesposito Sep 17, 2024
56b21ac
Merge branch 'develop' of https://github.com/stocnet/manynet into dev…
jhollway Sep 17, 2024
221704b
Added add_info() for adding grand info to tidygraph objects
jhollway Sep 17, 2024
ee2316a
print.mnet() now prints multiplex types if available
jhollway Sep 17, 2024
fb42f43
Added extra link to learning R
jhollway Sep 17, 2024
ae59963
Updated doc with better printing
jhollway Sep 17, 2024
d723bfe
Re #60 added ability to set theme options
jhollway Sep 17, 2024
e357796
Using internal progress step to allow for quieting messages
jhollway Sep 18, 2024
c0f1408
"name" now included in reserved tie attributes
jhollway Sep 18, 2024
d3a7343
Added manynet_console_theme internally as a cli theme which is used a…
jhollway Sep 18, 2024
d902071
printing describes the number of nodes better, including spelling out…
jhollway Sep 19, 2024
8f9d05c
add_info() now collects mode/collection too
jhollway Sep 19, 2024
134fa16
Fixed cli dependency in console theme
jhollway Sep 19, 2024
1b4145d
Added create_ego()
jhollway Sep 19, 2024
9c6c6c5
Added info to create_ego output
jhollway Sep 19, 2024
d40d2bd
Added interpreter functionality
jhollway Sep 19, 2024
7cc2c8d
create_ego() now has an easier to manage interpreter section
jhollway Sep 20, 2024
26f1dbc
Added interrelater functionality to create_ego(), collecting informat…
jhollway Sep 20, 2024
b39c9a4
Added roster functionality to create_ego() so that it can take a list…
jhollway Sep 20, 2024
b4b3ff7
create_ego() now retains unconnected names from the roster as isolates
jhollway Sep 20, 2024
1996128
Fixed bug in describe_nodes
jhollway Sep 20, 2024
6a06242
At least a #patch update
jhollway Sep 20, 2024
f219b33
Fixed testing issues with console theming
jhollway Sep 20, 2024
0d88adb
Updated ison_southern_women with grand data
jhollway Sep 20, 2024
4eb0819
Added documentation for add_info()
jhollway Sep 20, 2024
5127226
Added free play to data tutorial
jhollway Sep 20, 2024
b42bceb
to_unweighted() now passes through unweighted networks
jhollway Sep 25, 2024
dbf9203
Reordered nodes in ison_laterals data
jhollway Sep 25, 2024
5bd89b0
net_equivalency() now works with one-mode networks
jhollway Sep 25, 2024
be44617
Added node_equivalency() for calculating four-cycle closure by node
jhollway Sep 25, 2024
fae75a3
make_node_motif now adds modes and names only where available
jhollway Sep 26, 2024
03bec14
print.node_motif converts to tibble and adds names just for printing …
jhollway Sep 26, 2024
b399f1f
Added net_by_quad() for network level quad motifs
jhollway Sep 26, 2024
0102e84
Using own implementation for node_by_quad() now, slower than oaqc c++…
jhollway Sep 26, 2024
30a2362
node_in_equivalence() now uses census directly
jhollway Sep 26, 2024
f0299c7
Added node_hub() and node_authority() centrality measures
jhollway Sep 26, 2024
4af77ae
Added mnet_info internal function
jhollway Sep 26, 2024
322b95b
Faster version of combn possible, but only choose 2 at the moment
jhollway Sep 26, 2024
f9d5770
Added node_by_dyad()
jhollway Sep 27, 2024
f284a5d
Added internal mnet_unavailable() to direct users to the issues page
jhollway Sep 27, 2024
a49cf6a
Added create_motifs()
jhollway Sep 27, 2024
92f7970
Added plot methods for network_motif and node_motif classes
jhollway Sep 27, 2024
2e457d4
#minor bump and filled in the NEWS
jhollway Sep 27, 2024
0fcc65e
Attempt to fix pushrelease.yaml
jhollway Sep 28, 2024
ffd2fd0
Updated CRAN comments
jhollway Sep 29, 2024
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
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
Loading