Skip to content

Commit

Permalink
Adding parameters for rel scale
Browse files Browse the repository at this point in the history
  • Loading branch information
gvegayon committed Oct 20, 2021
1 parent 41417d3 commit f208180
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 15 deletions.
14 changes: 9 additions & 5 deletions R/gexf.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@
#' @param encoding Encoding of the graph.
#' @param vers Character scalar. Version of the GEXF format to generate.
#' By default `"1.3"`.
#' @param relsize Numeric scalar. Relative size of the largest node in terms
#' of the layout.
#' @param radius Numeric scalar. Radius of the plotting area.
#' @param ... Passed to `gexf`.
#' @param rescale.node.size Logical scalar. When `TRUE` it rescales the
#' size of the vertices such that the largest one is about \%5 of the plotting
Expand Down Expand Up @@ -121,7 +124,7 @@ NULL

default_nodeVizAtt <- list(
size = function() 8.0,
position = function() structure(c(runif(2, -200, 200), 0), names = c("x", "y", "z")),
position = function() structure(c(runif(2, -500, 500), 0), names = c("x", "y", "z")),
color = function() "tomato"
)

Expand Down Expand Up @@ -175,7 +178,9 @@ gexf <- function(
keepFactors = FALSE,
encoding = "UTF-8",
vers = "1.3",
rescale.node.size = TRUE
rescale.node.size = TRUE,
relsize = max(0.01, 1.0/nrow(nodes)),
radius = 500
) {

##############################################################################
Expand Down Expand Up @@ -242,13 +247,12 @@ gexf <- function(
next

nodesVizAtt$position[, i] <- ((nodesVizAtt$position[, i] - pran[1])/
(pran[2] - pran[1]))*200 - 100
(pran[2] - pran[1]))*radius - radius/2

}

# Getting ranges
sscale <- 200*.05

sscale <- radius * relsize
nodesVizAtt$size <- nodesVizAtt$size/max(nodesVizAtt$size)*sscale

}
Expand Down
2 changes: 1 addition & 1 deletion R/plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ gexf_js_config <- function(
curvedEdges = TRUE,
edgeWidthFactor = 1,
minEdgeWidth = 1,
maxEdgeWidth = 2,
maxEdgeWidth = 50,
textDisplayThreshold = 9,
nodeSizeFactor = 1,
replaceUrls = TRUE,
Expand Down
17 changes: 11 additions & 6 deletions docker/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
FROM rocker/r-devel:latest
FROM rocker/rstudio:4.1.0

RUN apt-get update && \
apt-get install -y --no-install-recommends \
r-cran-ape r-cran-coda r-cran-mass r-cran-rmarkdown r-cran-knitr \
r-cran-xml2 r-cran-covr r-cran-tinytest && \
Rscript -e 'utils::install.packages("fmcmc")'
r-cran-rmarkdown r-cran-knitr && \
Rscript -e 'utils::install.packages(c("intergraph", "igraphdata"))'

RUN Rscript -e 'utils::install.packages("AUC")'
RUN apt-get install -y --no-install-recommends \
libharfbuzz-dev libfribidi-dev \
libssl-dev libxml2-dev libfontconfig1-dev libcurl4-openssl-dev \
libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev && \
Rscript -e 'utils::install.packages("pkgdown")'

CMD ["bash"]
RUN apt-get install -y --no-install-recommends r-cran-igraph
RUN apt-get install -y --no-install-recommends r-cran-covr r-cran-tinytest
RUN Rscript -e 'utils::install.packages(c("servr", "XML"))'

12 changes: 11 additions & 1 deletion docker/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
build:
docker build -t gvegayon/rgexf:latest -f Dockerfile .
docker build -t gvegayon/rgexf:latest -f Dockerfile . && \
docker build -t gvegayon/rgexf:dev -f Dockerfile.dev .

push: build
docker push gvegayon/rgexf:latest

run:
docker run --rm -d -p 3624:3624 --name rgexf-docker \
-e PASSWORD=1231 \
-v ${PWD}/..:/home/rstudio \
gvegayon/rgexf:dev
stop:
docker stop rgexf-docker
9 changes: 8 additions & 1 deletion man/gexf-class.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/plot.gexf.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f208180

Please sign in to comment.