graphlayouts
graphlayouts: Layout algorithms for network visualizations in R - Published in JOSS (2023)
Science Score: 100.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 13 DOI reference(s) in README and JOSS metadata -
✓Academic publication links
Links to: arxiv.org, joss.theoj.org, zenodo.org -
✓Committers with academic emails
1 of 6 committers (16.7%) from academic institutions -
○Institutional organization owner
-
✓JOSS paper metadata
Published in Journal of Open Source Software
Keywords
ggraph
graph-algorithms
network-analysis
network-visualization
r
Keywords from Contributors
network-centrality
Last synced: 4 months ago
·
JSON representation
·
Repository
new layout algorithms for network visualizations in R
Basic Info
- Host: GitHub
- Owner: schochastics
- License: other
- Language: R
- Default Branch: main
- Homepage: https://schochastics.github.io/graphlayouts/
- Size: 22.7 MB
Statistics
- Stars: 280
- Watchers: 8
- Forks: 17
- Open Issues: 2
- Releases: 15
Topics
ggraph
graph-algorithms
network-analysis
network-visualization
r
Created over 7 years ago
· Last pushed 4 months ago
Metadata Files
Readme
Changelog
Contributing
License
Code of conduct
Citation
README.Rmd
---
output: github_document
---
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
fig.align = "center",
out.width = "80%",
comment = "#>",
fig.path = "man/figures/README-",
echo = TRUE,
warning = FALSE,
message = FALSE
)
```
# graphlayouts
[](https://github.com/schochastics/graphlayouts/actions)
[](https://cran.r-project.org/package=graphlayouts)
[](https://CRAN.R-project.org/package=graphlayouts)
[](https://CRAN.R-project.org/package=graphlayouts)
[](https://app.codecov.io/gh/schochastics/graphlayouts?branch=main)
[](https://doi.org/10.5281/zenodo.7870213)
[](https://doi.org/10.21105/joss.05238)
This package implements some graph layout algorithms that are not available
in `igraph`.
**A detailed introductory tutorial for graphlayouts and ggraph can be found [here](https://schochastics.github.io/netVizR/).**
The package implements the following algorithms:
- Stress majorization ([Paper](https://graphviz.gitlab.io/_pages/Documentation/GKN04.pdf))
- Quadrilateral backbone layout ([Paper](https://doi.org/10.7155/jgaa.00370))
- flexible radial layouts ([Paper](https://www.uni-konstanz.de/algo/publications/bp-mfrl-11.pdf))
- sparse stress ([Paper](https://arxiv.org/abs/1608.08909))
- pivot MDS ([Paper](https://doi.org/10.1007/978-3-540-70904-6_6))
- dynamic layout for longitudinal data ([Paper](https://doi.org/10.1016/j.socnet.2011.06.002))
- spectral layouts (adjacency/Laplacian)
- a simple multilevel layout
- a layout algorithm using UMAP
- group based centrality and focus layouts which keeps groups of nodes close in the same range on the concentric circle
## Install
```{r install,eval=FALSE}
# dev version
remotes::install_github("schochastics/graphlayouts")
# CRAN
install.packages("graphlayouts")
```
## Stress Majorization: Connected Network
*This example is a bit of a special case since it exploits some weird issues in igraph.*
```{r example}
library(igraph)
library(ggraph)
library(graphlayouts)
set.seed(666)
pa <- sample_pa(1000, 1, 1, directed = F)
ggraph(pa, layout = "nicely") +
geom_edge_link0(width = 0.2, colour = "grey") +
geom_node_point(col = "black", size = 0.3) +
theme_graph()
ggraph(pa, layout = "stress") +
geom_edge_link0(width = 0.2, colour = "grey") +
geom_node_point(col = "black", size = 0.3) +
theme_graph()
```
## Stress Majorization: Unconnected Network
Stress majorization also works for networks with several components. It relies
on a bin packing algorithm to efficiently put the components in a rectangle, rather than a circle.
```{r example_un}
set.seed(666)
g <- disjoint_union(
sample_pa(10, directed = FALSE),
sample_pa(20, directed = FALSE),
sample_pa(30, directed = FALSE),
sample_pa(40, directed = FALSE),
sample_pa(50, directed = FALSE),
sample_pa(60, directed = FALSE),
sample_pa(80, directed = FALSE)
)
ggraph(g, layout = "nicely") +
geom_edge_link0() +
geom_node_point() +
theme_graph()
ggraph(g, layout = "stress", bbox = 40) +
geom_edge_link0() +
geom_node_point() +
theme_graph()
```
## Backbone Layout
Backbone layouts are helpful for drawing hairballs.
```{r hairball,eval = FALSE}
set.seed(665)
# create network with a group structure
g <- sample_islands(9, 40, 0.4, 15)
g <- simplify(g)
V(g)$grp <- as.character(rep(1:9, each = 40))
ggraph(g, layout = "stress") +
geom_edge_link0(colour = rgb(0, 0, 0, 0.5), width = 0.1) +
geom_node_point(aes(col = grp)) +
scale_color_brewer(palette = "Set1") +
theme_graph() +
theme(legend.position = "none")
```
The backbone layout helps to uncover potential group structures based on edge
embeddedness and puts more emphasis on this structure in the layout.
```{r backbone,eval=FALSE}
bb <- layout_as_backbone(g, keep = 0.4)
E(g)$col <- FALSE
E(g)$col[bb$backbone] <- TRUE
ggraph(g, layout = "manual", x = bb$xy[, 1], y = bb$xy[, 2]) +
geom_edge_link0(aes(col = col), width = 0.1) +
geom_node_point(aes(col = grp)) +
scale_color_brewer(palette = "Set1") +
scale_edge_color_manual(values = c(rgb(0, 0, 0, 0.3), rgb(0, 0, 0, 1))) +
theme_graph() +
theme(legend.position = "none")
```
## Radial Layout with Focal Node
The function `layout_with_focus()` creates a radial layout around a focal node.
All nodes with the same distance from the focal node are on the same circle.
```{r flex_focus,eval=FALSE}
library(igraphdata)
library(patchwork)
data("karate")
p1 <- ggraph(karate, layout = "focus", focus = 1) +
draw_circle(use = "focus", max.circle = 3) +
geom_edge_link0(edge_color = "black", edge_width = 0.3) +
geom_node_point(aes(fill = as.factor(Faction)), size = 2, shape = 21) +
scale_fill_manual(values = c("#8B2323", "#EEAD0E")) +
theme_graph() +
theme(legend.position = "none") +
coord_fixed() +
labs(title = "Focus on Mr. Hi")
p2 <- ggraph(karate, layout = "focus", focus = 34) +
draw_circle(use = "focus", max.circle = 4) +
geom_edge_link0(edge_color = "black", edge_width = 0.3) +
geom_node_point(aes(fill = as.factor(Faction)), size = 2, shape = 21) +
scale_fill_manual(values = c("#8B2323", "#EEAD0E")) +
theme_graph() +
theme(legend.position = "none") +
coord_fixed() +
labs(title = "Focus on John A.")
p1 + p2
```
## Radial Centrality Layout
The function `layout_with_centrality` creates a radial layout around the node with the
highest centrality value. The further outside a node is, the more peripheral it is.
```{r flex_cent}
library(igraphdata)
library(patchwork)
data("karate")
bc <- betweenness(karate)
p1 <- ggraph(karate, layout = "centrality", centrality = bc, tseq = seq(0, 1, 0.15)) +
draw_circle(use = "cent") +
annotate_circle(bc, format = "", pos = "bottom") +
geom_edge_link0(edge_color = "black", edge_width = 0.3) +
geom_node_point(aes(fill = as.factor(Faction)), size = 2, shape = 21) +
scale_fill_manual(values = c("#8B2323", "#EEAD0E")) +
theme_graph() +
theme(legend.position = "none") +
coord_fixed() +
labs(title = "betweenness centrality")
cc <- closeness(karate)
p2 <- ggraph(karate, layout = "centrality", centrality = cc, tseq = seq(0, 1, 0.2)) +
draw_circle(use = "cent") +
annotate_circle(cc, format = "scientific", pos = "bottom") +
geom_edge_link0(edge_color = "black", edge_width = 0.3) +
geom_node_point(aes(fill = as.factor(Faction)), size = 2, shape = 21) +
scale_fill_manual(values = c("#8B2323", "#EEAD0E")) +
theme_graph() +
theme(legend.position = "none") +
coord_fixed() +
labs(title = "closeness centrality")
p1 + p2
```
## Large graphs
`graphlayouts` implements two algorithms for visualizing large networks (<100k nodes).
`layout_with_pmds()` is similar to `layout_with_mds()` but performs the multidimensional scaling
only with a small number of pivot nodes. Usually, 50-100 are enough to obtain similar results to the
full MDS.
`layout_with_sparse_stress()` performs stress majorization only with a small number of pivots (~50-100).
The runtime performance is inferior to pivotMDS but the quality is far superior.
A comparison of runtimes and layout quality can be found in the [wiki](https://github.com/schochastics/graphlayouts/wiki/)
**tl;dr**: both layout algorithms appear to be faster than the fastest igraph algorithm `layout_with_drl()`.
Below are two examples of layouts generated for large graphs using `layout_with_sparse_stress()`
A retweet network with 18k nodes and 61k edges
A network of football players with 165K nodes and 6M edges.
## dynamic layouts
`layout_as_dynamic()` allows you to visualize snapshots of longitudinal network data. Nodes are anchored
with a reference layout and only moved slightly in each wave depending on deleted/added edges.
In this way, it is easy to track down specific nodes throughout time. Use `patchwork` to put the
individual plots next to each other.
```{r dynamic,eval = FALSE}
# remotes::install_github("schochastics/networkdata")
library(networkdata)
# longitudinal dataset of friendships in a school class
data("s50")
xy <- layout_as_dynamic(s50, alpha = 0.2)
pList <- vector("list", length(s50))
for (i in seq_along(s50)) {
pList[[i]] <- ggraph(s50[[i]], layout = "manual", x = xy[[i]][, 1], y = xy[[i]][, 2]) +
geom_edge_link0(edge_width = 0.6, edge_colour = "grey66") +
geom_node_point(shape = 21, aes(fill = as.factor(smoke)), size = 3) +
geom_node_text(aes(label = 1:50), repel = T) +
scale_fill_manual(
values = c("forestgreen", "grey25", "firebrick"),
labels = c("no", "occasional", "regular"),
name = "smoking",
guide = ifelse(i != 2, "none", "legend")
) +
theme_graph() +
theme(legend.position = "bottom") +
labs(title = paste0("Wave ", i))
}
wrap_plots(pList)
```
## Layout manipulation
The functions `layout_mirror()` and `layout_rotate()` can be used to manipulate an existing layout
# How to reach out?
### Where do I report bugs?
Simply [open an issue](https://github.com/schochastics/graphlayouts/issues/new) on GitHub.
### How do I contribute to the package?
If you have an idea (but no code yet), [open an issue](https://github.com/schochastics/graphlayouts/issues/new) on GitHub. If you want to contribute with a specific feature and have the code ready, fork the repository, add your code, and create a pull request.
### Do you need support?
The easiest way is to [open an issue](https://github.com/schochastics/graphlayouts/issues/new) - this way, your question is also visible to others who may face similar problems.
### Code of Conduct
Please note that the graphlayouts project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/1/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.
Owner
- Name: David Schoch
- Login: schochastics
- Kind: user
- Location: Germany
- Company: cynkra
- Website: mr.schochastics.net
- Repositories: 131
- Profile: https://github.com/schochastics
Data Scientist/DevOps Engineer at cynkra and #RStats developer
JOSS Publication
graphlayouts: Layout algorithms for network visualizations in R
Published
April 29, 2023
Volume 8, Issue 84, Page 5238
Tags
network visualization graph drawing layout algorithmsCitation (CITATION.cff)
# --------------------------------------------
# CITATION file created with {cffr} R package
# See also: https://docs.ropensci.org/cffr/
# --------------------------------------------
cff-version: 1.2.0
message: 'To cite package "graphlayouts" in publications use:'
type: software
license: MIT
title: 'graphlayouts: Additional Layout Algorithms for Network Visualizations'
version: 1.2.1
doi: 10.21105/joss.05238
identifiers:
- type: doi
value: 10.32614/CRAN.package.graphlayouts
abstract: Several new layout algorithms to visualize networks are provided which are
not part of 'igraph'. Most are based on the concept of stress majorization by Gansner
et al. (2004) <https://doi.org/10.1007/978-3-540-31843-9_25>. Some more specific
algorithms allow the user to emphasize hidden group structures in networks or focus
on specific nodes.
authors:
- family-names: Schoch
given-names: David
email: david@schochastics.net
orcid: https://orcid.org/0000-0003-2952-4812
preferred-citation:
type: article
title: 'graphlayouts: Layout algorithms for network visualizations in R'
authors:
- name: David Schoch
year: '2023'
publisher:
name: The Open Journal
volume: '8'
issue: '84'
journal: Journal of Open Source Software
doi: 10.21105/joss.05238
url: https://doi.org/10.21105/joss.05238
start: '5238'
repository: https://CRAN.R-project.org/package=graphlayouts
repository-code: https://github.com/schochastics/graphlayouts
url: https://schochastics.github.io/graphlayouts/
contact:
- family-names: Schoch
given-names: David
email: david@schochastics.net
orcid: https://orcid.org/0000-0003-2952-4812
keywords:
- ggraph
- graph-algorithms
- network-analysis
- network-visualization
- r
references:
- type: software
title: 'R: A Language and Environment for Statistical Computing'
notes: Depends
url: https://www.R-project.org/
authors:
- name: R Core Team
institution:
name: R Foundation for Statistical Computing
address: Vienna, Austria
year: '2024'
version: '>= 3.6.0'
- type: software
title: igraph
abstract: 'igraph: Network Analysis and Visualization'
notes: Imports
url: https://r.igraph.org/
repository: https://CRAN.R-project.org/package=igraph
authors:
- family-names: Csárdi
given-names: Gábor
email: csardi.gabor@gmail.com
orcid: https://orcid.org/0000-0001-7098-9676
- family-names: Nepusz
given-names: Tamás
email: ntamas@gmail.com
orcid: https://orcid.org/0000-0002-1451-338X
- family-names: Traag
given-names: Vincent
orcid: https://orcid.org/0000-0003-3170-3879
- family-names: Horvát
given-names: Szabolcs
email: szhorvat@gmail.com
orcid: https://orcid.org/0000-0002-3100-523X
- family-names: Zanini
given-names: Fabio
email: fabio.zanini@unsw.edu.au
orcid: https://orcid.org/0000-0001-7097-8539
- family-names: Noom
given-names: Daniel
- family-names: Müller
given-names: Kirill
email: kirill@cynkra.com
orcid: https://orcid.org/0000-0002-1416-3412
year: '2024'
doi: 10.32614/CRAN.package.igraph
version: '>= 2.0.0'
- type: software
title: Rcpp
abstract: 'Rcpp: Seamless R and C++ Integration'
notes: Imports
url: https://www.rcpp.org
repository: https://CRAN.R-project.org/package=Rcpp
authors:
- family-names: Eddelbuettel
given-names: Dirk
email: edd@debian.org
orcid: https://orcid.org/0000-0001-6419-907X
- family-names: Francois
given-names: Romain
orcid: https://orcid.org/0000-0002-2444-4226
- family-names: Allaire
given-names: JJ
orcid: https://orcid.org/0000-0003-0174-9868
- family-names: Ushey
given-names: Kevin
orcid: https://orcid.org/0000-0003-2880-7407
- family-names: Kou
given-names: Qiang
orcid: https://orcid.org/0000-0001-6786-5453
- family-names: Russell
given-names: Nathan
- family-names: Ucar
given-names: Iñaki
orcid: https://orcid.org/0000-0001-6403-5550
- family-names: Bates
given-names: Doug
orcid: https://orcid.org/0000-0001-8316-9503
- family-names: Chambers
given-names: John
year: '2024'
doi: 10.32614/CRAN.package.Rcpp
- type: software
title: testthat
abstract: 'testthat: Unit Testing for R'
notes: Suggests
url: https://testthat.r-lib.org
repository: https://CRAN.R-project.org/package=testthat
authors:
- family-names: Wickham
given-names: Hadley
email: hadley@posit.co
year: '2024'
doi: 10.32614/CRAN.package.testthat
- type: software
title: ggplot2
abstract: 'ggplot2: Create Elegant Data Visualisations Using the Grammar of Graphics'
notes: Suggests
url: https://ggplot2.tidyverse.org
repository: https://CRAN.R-project.org/package=ggplot2
authors:
- family-names: Wickham
given-names: Hadley
email: hadley@posit.co
orcid: https://orcid.org/0000-0003-4757-117X
- family-names: Chang
given-names: Winston
orcid: https://orcid.org/0000-0002-1576-2126
- family-names: Henry
given-names: Lionel
- family-names: Pedersen
given-names: Thomas Lin
email: thomas.pedersen@posit.co
orcid: https://orcid.org/0000-0002-5147-4711
- family-names: Takahashi
given-names: Kohske
- family-names: Wilke
given-names: Claus
orcid: https://orcid.org/0000-0002-7470-9261
- family-names: Woo
given-names: Kara
orcid: https://orcid.org/0000-0002-5125-4188
- family-names: Yutani
given-names: Hiroaki
orcid: https://orcid.org/0000-0002-3385-7233
- family-names: Dunnington
given-names: Dewey
orcid: https://orcid.org/0000-0002-9415-4582
- family-names: Brand
given-names: Teun
name-particle: van den
orcid: https://orcid.org/0000-0002-9335-7468
year: '2024'
doi: 10.32614/CRAN.package.ggplot2
- type: software
title: RcppArmadillo
abstract: 'RcppArmadillo: ''Rcpp'' Integration for the ''Armadillo'' Templated Linear
Algebra Library'
notes: LinkingTo
url: https://dirk.eddelbuettel.com/code/rcpp.armadillo.html
repository: https://CRAN.R-project.org/package=RcppArmadillo
authors:
- family-names: Eddelbuettel
given-names: Dirk
email: edd@debian.org
orcid: https://orcid.org/0000-0001-6419-907X
- family-names: Francois
given-names: Romain
orcid: https://orcid.org/0000-0002-2444-4226
- family-names: Bates
given-names: Doug
orcid: https://orcid.org/0000-0001-8316-9503
- family-names: Ni
given-names: Binxiang
- family-names: Sanderson
given-names: Conrad
orcid: https://orcid.org/0000-0002-0049-4501
year: '2024'
doi: 10.32614/CRAN.package.RcppArmadillo
Papers & Mentions
Total mentions: 2
Predicting Functions of Uncharacterized Human Proteins: From Canonical to Proteoforms
- DOI: 10.3390/genes11060677
- OpenAlex ID: https://openalex.org/W3036223541
- Published: June 2020
Last synced: 2 months ago
PathwayMatcher: proteoform-centric network construction enables fine-granularity multiomics pathway mapping
- DOI: 10.1093/gigascience/giz088
- OpenAlex ID: https://openalex.org/W2965155676
- Published: July 2019
- Total mentions: 2
Last synced: 2 months ago
GitHub Events
Total
- Issues event: 6
- Watch event: 8
- Issue comment event: 3
- Push event: 27
- Pull request event: 3
Last Year
- Issues event: 6
- Watch event: 8
- Issue comment event: 3
- Push event: 27
- Pull request event: 3
Committers
Last synced: 5 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| schochastics | d****d@s****t | 247 |
| d-mathlete | d****a@g****m | 13 |
| Michal Bojanowski | m****2@g****m | 6 |
| Arthur Mühl | a****l@g****g | 2 |
| Giona Casiraghi | g****a@e****h | 1 |
| Arfon Smith | a****n | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 4 months ago
All Time
- Total issues: 78
- Total pull requests: 14
- Average time to close issues: 4 months
- Average time to close pull requests: 1 day
- Total issue authors: 23
- Total pull request authors: 5
- Average comments per issue: 1.71
- Average comments per pull request: 0.36
- Merged pull requests: 11
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 6
- Pull requests: 5
- Average time to close issues: 14 days
- Average time to close pull requests: 3 minutes
- Issue authors: 2
- Pull request authors: 2
- Average comments per issue: 1.17
- Average comments per pull request: 0.0
- Merged pull requests: 2
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- schochastics (31)
- bpbond (9)
- thomasp85 (8)
- ndjackso (7)
- mbojan (5)
- wydty (1)
- timonelmer (1)
- avladimirova (1)
- conorotompkins (1)
- arcresu (1)
- jwijffels (1)
- alopezespino (1)
- matthieu-bruneaux (1)
- tusharmajhi9 (1)
- grasshoppermouse (1)
Pull Request Authors
- schochastics (10)
- mbojan (3)
- ArthurMuehl (2)
- gi0na (1)
- arfon (1)
Top Labels
Issue Labels
enhancement (10)
new layout (5)
bug (4)
question (3)
1.1.0 (1)
Pull Request Labels
Packages
- Total packages: 3
-
Total downloads:
- cran 45,219 last-month
- Total docker downloads: 59,427
-
Total dependent packages: 7
(may contain duplicates) -
Total dependent repositories: 18
(may contain duplicates) - Total versions: 38
- Total maintainers: 1
proxy.golang.org: github.com/schochastics/graphlayouts
- Documentation: https://pkg.go.dev/github.com/schochastics/graphlayouts#section-documentation
- License: other
-
Latest release: v1.2.2
published 11 months ago
Rankings
Dependent packages count: 5.4%
Average: 5.6%
Dependent repos count: 5.8%
Last synced:
4 months ago
cran.r-project.org: graphlayouts
Additional Layout Algorithms for Network Visualizations
- Homepage: https://github.com/schochastics/graphlayouts
- Documentation: http://cran.r-project.org/web/packages/graphlayouts/graphlayouts.pdf
- License: MIT + file LICENSE
-
Latest release: 1.2.2
published 11 months ago
Rankings
Downloads: 1.6%
Stargazers count: 1.7%
Forks count: 4.7%
Average: 6.8%
Dependent packages count: 7.1%
Dependent repos count: 8.3%
Docker downloads count: 17.3%
Maintainers (1)
Last synced:
4 months ago
conda-forge.org: r-graphlayouts
- Homepage: https://github.com/schochastics/graphlayouts
- License: MIT
-
Latest release: 0.8.3
published about 3 years ago
Rankings
Dependent repos count: 13.9%
Stargazers count: 24.6%
Average: 27.6%
Dependent packages count: 29.0%
Forks count: 42.7%
Last synced:
4 months ago
Dependencies
DESCRIPTION
cran
- R >= 3.2.0 depends
- Rcpp * imports
- igraph * imports
- ggplot2 * suggests
- ggraph * suggests
- knitr * suggests
- oaqc * suggests
- rmarkdown * suggests
- testthat * suggests
- uwot * suggests
.github/workflows/R-CMD-check.yaml
actions
- actions/checkout v3 composite
- r-lib/actions/check-r-package v2 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/test-coverage.yaml
actions
- actions/checkout v3 composite
- actions/upload-artifact v3 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
