Skip to content

Commit

Permalink
Merge pull request #101 from stocnet/develop
Browse files Browse the repository at this point in the history
v1.3.0
  • Loading branch information
jhollway authored Oct 23, 2024
2 parents be7c2bf + d13dce6 commit b1a5cf2
Show file tree
Hide file tree
Showing 109 changed files with 4,333 additions and 1,907 deletions.
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.2.6
Date: 2024-10-05
Version: 1.3.0
Date: 2024-10-16
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 @@ -39,7 +39,6 @@ Suggests:
knitr,
learnr,
methods,
multiplex,
netdiffuseR,
patchwork,
readxl,
Expand Down
31 changes: 30 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ S3method(as_network,network)
S3method(as_network,network.goldfish)
S3method(as_network,siena)
S3method(as_network,tbl_graph)
S3method(as_nodelist,tbl_graph)
S3method(as_siena,igraph)
S3method(as_siena,tbl_graph)
S3method(as_tidygraph,data.frame)
Expand Down Expand Up @@ -158,6 +159,8 @@ S3method(print,tie_measure)
S3method(summary,diff_model)
S3method(summary,diffs_model)
S3method(summary,learn_model)
S3method(summary,network_measure)
S3method(summary,network_motif)
S3method(summary,node_measure)
S3method(summary,node_member)
S3method(summary,node_motif)
Expand Down Expand Up @@ -244,6 +247,11 @@ S3method(to_redirected,igraph)
S3method(to_redirected,matrix)
S3method(to_redirected,network)
S3method(to_redirected,tbl_graph)
S3method(to_signed,data.frame)
S3method(to_signed,igraph)
S3method(to_signed,matrix)
S3method(to_signed,network)
S3method(to_signed,tbl_graph)
S3method(to_simplex,igraph)
S3method(to_simplex,matrix)
S3method(to_simplex,tbl_graph)
Expand Down Expand Up @@ -294,6 +302,9 @@ S3method(to_waves,data.frame)
S3method(to_waves,diff_model)
S3method(to_waves,igraph)
S3method(to_waves,tbl_graph)
S3method(to_weighted,igraph)
S3method(to_weighted,network)
S3method(to_weighted,tbl_graph)
export("%>%")
export(.E)
export(.G)
Expand All @@ -312,14 +323,17 @@ export(as_graphAM)
export(as_igraph)
export(as_matrix)
export(as_network)
export(as_nodelist)
export(as_siena)
export(as_tidygraph)
export(autographd)
export(autographr)
export(autographs)
export(bind_node_attributes)
export(bind_ties)
export(clear_glossary)
export(cluster_concor)
export(cluster_cosine)
export(cluster_hierarchical)
export(create_components)
export(create_core)
Expand Down Expand Up @@ -356,6 +370,7 @@ export(generate_utilities)
export(ggplot)
export(ggsave)
export(ggtitle)
export(gloss)
export(graphr)
export(graphs)
export(grapht)
Expand Down Expand Up @@ -391,12 +406,16 @@ export(labs)
export(layout_tbl_graph_alluvial)
export(layout_tbl_graph_concentric)
export(layout_tbl_graph_configuration)
export(layout_tbl_graph_dyad)
export(layout_tbl_graph_hexad)
export(layout_tbl_graph_hierarchy)
export(layout_tbl_graph_ladder)
export(layout_tbl_graph_lineage)
export(layout_tbl_graph_multilevel)
export(layout_tbl_graph_pentad)
export(layout_tbl_graph_quad)
export(layout_tbl_graph_railway)
export(layout_tbl_graph_tetrad)
export(layout_tbl_graph_triad)
export(many_palettes)
export(mutate)
Expand All @@ -412,6 +431,7 @@ export(net_by_brokerage)
export(net_by_dyad)
export(net_by_mixed)
export(net_by_quad)
export(net_by_tetrad)
export(net_by_triad)
export(net_change)
export(net_closeness)
Expand Down Expand Up @@ -528,6 +548,7 @@ export(node_by_dyad)
export(node_by_exposure)
export(node_by_path)
export(node_by_quad)
export(node_by_tetrad)
export(node_by_tie)
export(node_by_triad)
export(node_closeness)
Expand Down Expand Up @@ -558,6 +579,7 @@ export(node_in_adopter)
export(node_in_automorphic)
export(node_in_betweenness)
export(node_in_brokering)
export(node_in_community)
export(node_in_component)
export(node_in_eigen)
export(node_in_equivalence)
Expand Down Expand Up @@ -591,6 +613,8 @@ export(node_is_max)
export(node_is_mentor)
export(node_is_min)
export(node_is_mode)
export(node_is_neighbor)
export(node_is_pendant)
export(node_is_random)
export(node_is_recovered)
export(node_kernighanlin)
Expand Down Expand Up @@ -624,6 +648,7 @@ export(node_thresholds)
export(node_tie_census)
export(node_transitivity)
export(node_triad_census)
export(node_vitality)
export(node_walktrap)
export(node_weak_components)
export(over_time)
Expand All @@ -633,6 +658,7 @@ export(play_diffusion)
export(play_diffusions)
export(play_learning)
export(play_segregation)
export(print_glossary)
export(read_cran)
export(read_dynetml)
export(read_edgelist)
Expand Down Expand Up @@ -695,6 +721,7 @@ export(tie_is_bridge)
export(tie_is_cyclical)
export(tie_is_feedback)
export(tie_is_forbidden)
export(tie_is_imbalanced)
export(tie_is_loop)
export(tie_is_max)
export(tie_is_min)
Expand All @@ -713,12 +740,12 @@ export(to_anti)
export(to_blocks)
export(to_components)
export(to_correlation)
export(to_cosine)
export(to_directed)
export(to_dominating)
export(to_ego)
export(to_egos)
export(to_eulerian)
export(to_galois)
export(to_giant)
export(to_matching)
export(to_mentoring)
Expand All @@ -731,6 +758,7 @@ export(to_onemode)
export(to_permuted)
export(to_reciprocated)
export(to_redirected)
export(to_signed)
export(to_simplex)
export(to_slices)
export(to_subgraph)
Expand All @@ -744,6 +772,7 @@ export(to_unnamed)
export(to_unsigned)
export(to_unweighted)
export(to_waves)
export(to_weighted)
export(with_graph)
export(write_edgelist)
export(write_graphml)
Expand Down
91 changes: 91 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,94 @@
# manynet 1.3.0

## Package

- Improved user information in the console
- manynet cli functions now inherit parent frame
- Added manynet cli functions for success and progress along, seq, and nodes
- Improved testing architecture
- Moving to nested testthats
- Added custom testthat function for expecting values and ignoring dimension names

## Making

- Added some names to created networks (`create_ego()`, `create_empty()`,
`create_filled()`, `create_ring()`, `create_star()`, `create_lattice()`)

## Modifying

- Fixed how `as_matrix()` handles signed networks
- Added `as_nodelist()` for extracting nodelists from networks into tibbles
- Added `to_cosine()`
- Dropped `to_galois()` until it can be refactored
- Split reformatting documentation into format, reformat, and deformat groups of functions
- Added `to_signed()` for adding signs to networks
- Added `to_weighted()` for adding weights to networks

## Mapping

- Fixed default color ordering so that red is the highlight
- Fixed bug in `graphr()` where line types were inferred incorrectly
- Improved `graphr()` so that layouts can now be `snap`ped to a grid,
mileage may vary
- Improved theme handling so that it is set globally (WIP)
- Added highlight themes
- Added background themes
- Added categorical themes
- Improved configurational layouts
- Added dyad, pentad, and hexad layouts to configurational layouts
- Renamed quad layout to tetrad layout

## Marking

- Added `node_is_pendant()` for identifying pendant nodes
- Added `node_is_neighbor()` for identifying adjacent nodes
- Added `tie_is_imbalanced()` for identifying ties in imbalanced configurations

## Measuring

- Added `summary.network_measure()` to return z-scores and p-values for measures
- Added `node_vitality()` for measuring closeness vitality centrality
- Fixed #98 by dropping scale and normalization for `node_eigenvector()`

## Memberships

- Improved community detection options for new users
- Community detection algorithms now reformat networks as necessary or suggest that it be used on only the giant component
- Added `node_in_community()` which runs through most salient community detection algorithms to find and return the one with the highest modularity
- Updated documentation on resolution parameters
- Improved `node_in_regular()` to inform user which census is being used
- Renamed `node_by_quad()` to `node_by_tetrad()` to be more consistent with Greek origins
- Restored and updated documentation about the various configurations
- Added `summary.network_motif()` which returns the z-scores for the motif scores based on random or configurational networks, traces progress
- Fixed bug in `plot.network_motif()` where motif names were not identified correctly, internal make_network_motif now inherits call information

## Modelling

- Added `cluster_cosine()` for another equivalence option
- Added internal documentation for depth_first_recursive_search

## Practicing

- Improved how `run_tute()` fuzzy matched so that insertions are not as costly
- Improved tutorials with glossary architecture
- Added `gloss()`, `clear_glossary()`, and `print_glossary()` for adding glossaries to tutorials
- Updated tutorials
- Updated community, position, and topology tutorials with glossaries, free play sections, and gifs
- Fixed miscellaneous issues in these tutorials
- Added faction section to community tutorial

## Data

- Added `irps_wwi`, a dynamic, signed network
- Renamed `ison_blogs` to `irps_blogs`, added info
- Renamed `ison_books` to `irps_books`, added info
- Renamed `ison_usstates` to `irps_usgeo`, added info
- Renamed `ison_friends` to `fict_friends`, added info and fixed directed issue
- Renamed `ison_greys` to `fict_greys`, added info
- Renamed `ison_lotr` to `fict_lotr`, added info
- Renamed `ison_thrones` to `fict_thrones`, added info and some additional nodal attributes
- Renamed `ison_potter` to `fict_potter`, added info and combined waves into single object

# manynet 1.2.6

## Package
Expand Down
25 changes: 25 additions & 0 deletions R/class_measures.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ make_tie_measure <- function(out, .data) {
make_network_measure <- function(out, .data) {
class(out) <- c("network_measure", class(out))
attr(out, "mode") <- net_dims(.data)
attr(out, "call") <- deparse(sys.calls())
out
}

Expand Down Expand Up @@ -101,6 +102,30 @@ summary.node_measure <- function(object, ...,
out
}

#' @export
summary.network_measure <- function(object, ...,
null = c("random","configuration"),
times = 500) {
null <- paste0("generate_", match.arg(null))
callItems <- trimws(strsplit(unlist(attr(object, "call")),
split = "\\(|\\)|,")[[1]])
idFun <- which(grepl("^net_", callItems))[1]
fun <- callItems[idFun]
dat <- callItems[idFun+1]
nulls <- vapply(mnet_progress_seq(times), function(r){
suppressMessages(get(fun)(get(null)(get(dat))))
}, FUN.VALUE = numeric(1))
out <- (object - mean(nulls))/stats::sd(nulls)
out[is.nan(out)] <- 0
p <- 2 * stats::pnorm(out,
mean = mean(nulls), sd = stats::sd(nulls),
lower.tail = ifelse(out>0, FALSE, TRUE))
cli::cli_text(cli::style_bold(round(object,3)),
" (z = ", cli::style_italic(round(out,2)),
", p = ", cli::style_italic(round(p,3)),
")")
}

# Plotting ####
#' @export
plot.node_measure <- function(x, type = c("h", "d"), ...) {
Expand Down
23 changes: 22 additions & 1 deletion R/class_motifs.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ make_node_motif <- function(out, .data) {
make_network_motif <- function(out, .data) {
class(out) <- c("network_motif", class(out))
attr(out, "mode") <- net_dims(.data)
attr(out, "call") <- deparse(sys.calls())
out
}

Expand Down Expand Up @@ -50,7 +51,7 @@ plot.node_motif <- function(x, ...) {

#' @export
plot.network_motif <- function(x, ...) {
motifs <- dimnames(x)[[2]]
motifs <- attr(x, "names")
if("X4" %in% motifs){
graphs(create_motifs(4), waves = 1:11)
} else if("021D" %in% motifs){
Expand Down Expand Up @@ -87,3 +88,23 @@ print.network_motif <- function(x, ...) {
out <- as.data.frame(mat)
print(dplyr::tibble(out))
}

#' @export
summary.network_motif <- function(object, ...,
null = c("random","configuration"),
times = 500) {
null <- paste0("generate_", match.arg(null))
callItems <- trimws(strsplit(unlist(attr(object, "call")),
split = "\\(|\\)|,")[[1]])
idFun <- which(grepl("net_by_", callItems))[1]
fun <- callItems[idFun]
dat <- callItems[idFun+1]
nulls <- t(vapply(mnet_progress_seq(times), function(r){
suppressMessages(get(fun)(get(null)(get(dat))))
}, FUN.VALUE = numeric(length(object))))
out <- (object - colMeans(nulls))/apply(nulls, 2, stats::sd)
out[is.nan(out)] <- 0
out
}


Loading

0 comments on commit b1a5cf2

Please sign in to comment.