Skip to content

Commit

Permalink
Merge pull request #184 from deleip/master
Browse files Browse the repository at this point in the history
improved visualizeDependencies
  • Loading branch information
deleip authored Oct 12, 2023
2 parents 4d7fcc6 + f752c05 commit 9de5e21
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '7183116'
ValidationKey: '7208614'
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
- 'Warning: namespace ''.*'' is not available and has been replaced'
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ repos:
- id: mixed-line-ending

- repo: https://github.com/lorenzwalthert/precommit
rev: v0.3.2.9019
rev: v0.3.2.9021
hooks:
- id: parsable-R
- id: deps-in-desc
Expand Down
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ cff-version: 1.2.0
message: If you use this software, please cite it using the metadata from this file.
type: software
title: 'madrat: May All Data be Reproducible and Transparent (MADRaT) *'
version: 3.6.6
date-released: '2023-09-26'
version: 3.6.7
date-released: '2023-10-12'
abstract: Provides a framework which should improve reproducibility and transparency
in data processing. It provides functionality such as automatic meta data creation
and management, rudimentary quality management, data caching, work-flow management
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Type: Package
Package: madrat
Title: May All Data be Reproducible and Transparent (MADRaT) *
Version: 3.6.6
Date: 2023-09-26
Version: 3.6.7
Date: 2023-10-12
Authors@R: c(
person("Jan Philipp", "Dietrich", , "dietrich@pik-potsdam.de", role = c("aut", "cre")),
person("Lavinia", "Baumstark", , "lavinia@pik-potsdam.de", role = "aut"),
Expand Down
30 changes: 19 additions & 11 deletions R/visualizeDependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -132,37 +132,45 @@ visualizeDependencies <- function(..., direction = "both", order = 2, filter = N
V(fullGraph)$shape <- "circle"
}

# make central vertices circles
V(fullGraph)$shape[V(fullGraph)$name %in% functions] <- "circle"

# add corresponding mr package to each vertex of graph
for (i in seq_along(V(fullGraph))) {
V(fullGraph)$color[i] <- ifelse(V(fullGraph)$name[i] %in% dfGraphMadrat$from,
dfGraphMadrat$from_package[which(dfGraphMadrat$from == V(fullGraph)$name[i])[1]],
dfGraphMadrat$to_package[which(dfGraphMadrat$to == V(fullGraph)$name[i])[1]])
V(fullGraph)$frame.color[i] <- V(fullGraph)$color[i]
V(fullGraph)$frame.width[i] <- 1
}

# all packages that are relevant
pkg <- unique(V(fullGraph)$color)

# set default colors
colorsIn <- c("deepskyblue", "gold", "mediumpurple", "#33cbb9", "#219421")
colorsVertices <- c("deepskyblue", "gold", "mediumpurple", "#33cba8", "#219421",
"#ff7700", "#d52580", "#3b3bab", "#237791", "#a61818", "#8cdb7d")

# set vertex colors according to package (different shades for incoming/outgoing)
# set vertex colors according to packages
for (i in seq_along(pkg)) {
V(fullGraph)$color[which(V(fullGraph)$color == pkg[i])] <- colorsIn[i]
V(fullGraph)$color[which(V(fullGraph)$color == pkg[i])] <- colorsVertices[i]
V(fullGraph)$frame.color[which(V(fullGraph)$frame.color == pkg[i])] <- colorsVertices[i]
}

# make central vertices red
V(fullGraph)$color[V(fullGraph)$name %in% functions] <- "#f84141"
V(fullGraph)$shape[V(fullGraph)$name %in% functions] <- "sphere"
# for non-central vetices only frame colored
V(fullGraph)$color[!(V(fullGraph)$name %in% functions)] <- "white"
V(fullGraph)$frame.width[!(V(fullGraph)$name %in% functions)] <- 3

# plot graph
if (!is.null(filename)) grDevices::png(filename, 800, 800)
plot(fullGraph)
graphics::legend("topright", legend = c(pkg, "Central functions"), pch = 16,
col = c(colorsIn[seq_along(pkg)], "#c93535"), bty = "n")
if (direction == "both") graphics::legend("bottomright", legend = c("In", "Out"), pch = c(22, 21), bty = "n")
if (direction == "in") graphics::legend("bottomright", legend = c("In"), pch = 22, bty = "n")
if (direction == "out") graphics::legend("bottomright", legend = c("Out"), pch = 21, bty = "n")
graphics::legend("topright", legend = pkg, pch = 16, col = colorsVertices[seq_along(pkg)], bty = "n")
if (direction == "both") graphics::legend("bottomright", legend = c("Central functions", "In", "Out"),
pch = c(16, 22, 21), bty = "n")
if (direction == "in") graphics::legend("bottomright", legend = c("Central functions", "In"),
pch = c(16, 22), bty = "n")
if (direction == "out") graphics::legend("bottomright", legend = c("Central functions", "Out"),
pch = c(16, 21), bty = "n")
if (!is.null(filename)) grDevices::dev.off()

# return graph and list of relevant packages
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# May All Data be Reproducible and Transparent (MADRaT) *

R package **madrat**, version **3.6.6**
R package **madrat**, version **3.6.7**

[![CRAN status](https://www.r-pkg.org/badges/version/madrat)](https://cran.r-project.org/package=madrat) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1115490.svg)](https://doi.org/10.5281/zenodo.1115490) [![R build status](https://github.com/pik-piam/madrat/workflows/check/badge.svg)](https://github.com/pik-piam/madrat/actions) [![codecov](https://codecov.io/gh/pik-piam/madrat/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/madrat) [![r-universe](https://pik-piam.r-universe.dev/badges/madrat)](https://pik-piam.r-universe.dev/builds)

Expand Down Expand Up @@ -55,7 +55,7 @@ In case of questions / problems please contact Jan Philipp Dietrich <dietrich@pi

To cite package **madrat** in publications use:

Dietrich J, Baumstark L, Wirth S, Giannousakis A, Rodrigues R, Bodirsky B, Leip D, Kreidenweis U, Klein D, Führlich P (2023). _madrat: May All Data be Reproducible and Transparent (MADRaT)_. doi:10.5281/zenodo.1115490 <https://doi.org/10.5281/zenodo.1115490>, R package version 3.6.6, <https://github.com/pik-piam/madrat>.
Dietrich J, Baumstark L, Wirth S, Giannousakis A, Rodrigues R, Bodirsky B, Leip D, Kreidenweis U, Klein D, Führlich P (2023). _madrat: May All Data be Reproducible and Transparent (MADRaT)_. doi: 10.5281/zenodo.1115490 (URL: https://doi.org/10.5281/zenodo.1115490), R package version 3.6.7, <URL: https://github.com/pik-piam/madrat>.

A BibTeX entry for LaTeX users is

Expand All @@ -64,7 +64,7 @@ A BibTeX entry for LaTeX users is
title = {madrat: May All Data be Reproducible and Transparent (MADRaT)},
author = {Jan Philipp Dietrich and Lavinia Baumstark and Stephen Wirth and Anastasis Giannousakis and Renato Rodrigues and Benjamin Leon Bodirsky and Debbora Leip and Ulrich Kreidenweis and David Klein and Pascal Führlich},
year = {2023},
note = {R package version 3.6.6},
note = {R package version 3.6.7},
doi = {10.5281/zenodo.1115490},
url = {https://github.com/pik-piam/madrat},
}
Expand Down

0 comments on commit 9de5e21

Please sign in to comment.