Skip to content

Commit

Permalink
Merge branch 'main' into layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
d-callan committed Feb 22, 2024
2 parents 108d566 + c4b40c4 commit c40ec2c
Show file tree
Hide file tree
Showing 26 changed files with 223 additions and 75 deletions.
12 changes: 9 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ export(KPartiteNetwork)
export(Link)
export(LinkList)
export(Network)
export(Node)
export(NodeId)
export(NodeIdList)
export(NodeList)
export(Partition)
export(Partitions)
export(TwoByTwoTable)
export(adjustToViewport)
Expand All @@ -45,6 +43,7 @@ export(findViewport)
export(fishersTest)
export(getDuplicateLinks)
export(getIsolatedNodes)
export(getPartitionIndex)
export(getQuadrantValues)
export(heatmap)
export(heatmap.dt)
Expand Down Expand Up @@ -76,8 +75,8 @@ export(sensitivity)
export(smoothedMean)
export(specificity)
export(writeJSON)
export(writeNetworkJSON)
exportClasses(ContingencyTable)
exportClasses(KPartiteNetwork)
exportClasses(Link)
exportClasses(LinkList)
exportClasses(Network)
Expand All @@ -87,6 +86,12 @@ exportClasses(NodeIdList)
exportClasses(NodeList)
exportClasses(Partitions)
exportClasses(TwoByTwoTable)
exportMethods(KPartiteNetwork)
exportMethods(Link)
exportMethods(LinkList)
exportMethods(Network)
exportMethods(NodeIdList)
exportMethods(NodeList)
exportMethods(allStats)
exportMethods(chiSqResults)
exportMethods(fishersTest)
Expand All @@ -106,6 +111,7 @@ exportMethods(relativeRisk)
exportMethods(sensitivity)
exportMethods(specificity)
exportMethods(toJSON)
exportMethods(writeNetworkJSON)
import(data.table)
import(veupathUtils)
importFrom(S4Vectors,SimpleList)
Expand Down
15 changes: 6 additions & 9 deletions R/constructors-Node.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,30 +100,27 @@ setMethod("NodeIdList", "Node", function(object, uniquifyIds = c(TRUE, FALSE)) {
#' @param y numeric value indicating the y coordinate of the node. Optional.
#' @param color string or numeric that determines the color of the node. Optional.
#' @param weight numeric value associated with the node, such as timestamp or other node-associated data. Optional.
#' @export
#' @param degree numeric value indicating the degree of the node. This only makes sense in the context of a network,
#' and should not be provided in other contexts like when working w an individual node.
setGeneric("Node", function(id, x = numeric(), y = numeric(), color = NULL, weight = NULL, degree = NULL) standardGeneric("Node"), signature = c("id"))

#' @export
setMethod("Node", "numeric", function(id, x = numeric(), y = numeric(), color = NULL, weight = NULL, degree = NULL) {
degree <- ifelse(is.null(degree), 0, degree)
degree <- ifelse(is.null(degree), NA_real_, degree)
new("Node", id = NodeId(as.character(id)), x = x, y = y, color = color, weight = weight, degree = degree)
})

#' @export
setMethod("Node", "character", function(id, x = numeric(), y = numeric(), color = NULL, weight = NULL, degree = NULL) {
degree <- ifelse(is.null(degree), 0, degree)
degree <- ifelse(is.null(degree), NA_real_, degree)
new("Node", id = NodeId(id), x = x, y = y, color = color, weight = weight, degree = degree)
})

#' @export
setMethod("Node", "NodeId", function(id, x = numeric(), y = numeric(), color = NULL, weight = NULL, degree = NULL) {
degree <- ifelse(is.null(degree), 0, degree)
degree <- ifelse(is.null(degree), NA_real_, degree)
new("Node", id = id, x = x, y = y, color = color, weight = weight, degree = degree)
})

#' @export
setMethod("Node", "missing", function(id, x = numeric(), y = numeric(), color = NULL, weight = NULL, degree = NULL) {
degree <- ifelse(is.null(degree), 0, degree)
degree <- ifelse(is.null(degree), NA_real_, degree)
new("Node", id = NodeId(generate_node_id(1)), x = x, y = y, color = color, weight = weight, degree = degree)
})

Expand Down
8 changes: 4 additions & 4 deletions R/methods-Network.R
Original file line number Diff line number Diff line change
Expand Up @@ -194,17 +194,17 @@ setMethod(toJSONGeneric, "Network", function(object, named = c(TRUE, FALSE)) {
return(tmp)
})

#' Write json to tmp file
#' Write network json to tmp file
#'
#' This function returns the name of a json file which it has
#' written an object out to.
#' @param x an object to convert to json and write to a tmp file
#' @param verbose boolean that declares if logging is desired
#' @return character name of a tmp file w ext *.json
#' @export
setGeneric("writeJSON", function(x, pattern = NULL, verbose = c(TRUE, FALSE)) standardGeneric("writeJSON"))
setGeneric("writeNetworkJSON", function(x, pattern = NULL, verbose = c(TRUE, FALSE)) standardGeneric("writeNetworkJSON"))

#' Write json to local tmp file
#' Write network json to local tmp file
#'
#' This function returns the name of a json file which it has
#' written a Network object out to.
Expand All @@ -214,7 +214,7 @@ setGeneric("writeJSON", function(x, pattern = NULL, verbose = c(TRUE, FALSE)) st
#' @return character name of a tmp file w ext *.json
#' @importFrom jsonlite toJSON
#' @export
setMethod("writeJSON", "Network", function(x, pattern=NULL, verbose = c(TRUE, FALSE)) {
setMethod("writeNetworkJSON", "Network", function(x, pattern=NULL, verbose = c(TRUE, FALSE)) {
net <- x
verbose <- veupathUtils::matchArg(verbose)

Expand Down
2 changes: 1 addition & 1 deletion R/methods-Nodes.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ setMethod(toJSONGeneric, "Node", function(object, named = c(FALSE, TRUE)) {
if (!!length(y(object)) && !is.na(y(object))) tmp <- paste0(tmp, ',"y":', jsonlite::toJSON(jsonlite::unbox(y(object))))
if (!!length(color(object))) tmp <- paste0(tmp, ',"color":', jsonlite::toJSON(jsonlite::unbox(color(object))))
if (!!length(weight(object))) tmp <- paste0(tmp, ',"weight":', jsonlite::toJSON(jsonlite::unbox(weight(object))))
if (!!length(degree(object))) tmp <- paste0(tmp, ',"degree":', jsonlite::toJSON(jsonlite::unbox(degree(object))))
if (!!length(degree(object)) && !is.na(degree(object))) tmp <- paste0(tmp, ',"degree":', jsonlite::toJSON(jsonlite::unbox(degree(object))))

tmp <- paste0('{', tmp, '}')
if (named) {
Expand Down
12 changes: 11 additions & 1 deletion man/KPartiteNetwork-class.Rd

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

1 change: 0 additions & 1 deletion man/Link-class.Rd

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

22 changes: 22 additions & 0 deletions man/Link.Rd

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

1 change: 0 additions & 1 deletion man/LinkList-class.Rd

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

23 changes: 23 additions & 0 deletions man/LinkList.Rd

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

8 changes: 4 additions & 4 deletions man/Network-class.Rd

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

3 changes: 2 additions & 1 deletion man/Node-class.Rd

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

32 changes: 32 additions & 0 deletions man/Node.Rd

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

15 changes: 0 additions & 15 deletions man/NodeId.Rd

This file was deleted.

8 changes: 5 additions & 3 deletions man/NodeIdList.Rd

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

1 change: 0 additions & 1 deletion man/NodeList-class.Rd

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

4 changes: 2 additions & 2 deletions man/Partition-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/Partitions-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/Partitions.Rd

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

17 changes: 17 additions & 0 deletions man/getPartitionIndex.Rd

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

16 changes: 16 additions & 0 deletions man/toJSON-KPartiteNetwork-method.Rd

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

Loading

0 comments on commit c40ec2c

Please sign in to comment.