From 61cd24057054169a67a29377b1848004c7fc7ba5 Mon Sep 17 00:00:00 2001 From: leifeld Date: Sun, 8 Jan 2023 21:45:03 +0000 Subject: [PATCH] Deactivated backbone UI in DNA and rDNA for 3.0.9 release. Needs more work before it can be released. --- dna/src/main/java/gui/MenuBar.java | 3 +- rDNA/NAMESPACE | 4 - rDNA/R/rDNA.R | 8 +- rDNA/man/dna_backbone.Rd | 297 ----------------------------- 4 files changed, 6 insertions(+), 306 deletions(-) delete mode 100644 rDNA/man/dna_backbone.Rd diff --git a/dna/src/main/java/gui/MenuBar.java b/dna/src/main/java/gui/MenuBar.java index 0938f219..ad855dfc 100644 --- a/dna/src/main/java/gui/MenuBar.java +++ b/dna/src/main/java/gui/MenuBar.java @@ -203,7 +203,8 @@ public MenuBar(ActionOpenDatabase actionOpenDatabase, // export menu: open backbone exporter JMenuItem backboneExporterItem = new JMenuItem(actionBackboneExporter); - exportMenu.add(backboneExporterItem); + // exportMenu.add(backboneExporterItem); + // TODO: add back in once finalized // settings menu JMenu settingsMenu = new JMenu("Settings"); diff --git a/rDNA/NAMESPACE b/rDNA/NAMESPACE index 1acbad5f..132bf686 100644 --- a/rDNA/NAMESPACE +++ b/rDNA/NAMESPACE @@ -2,14 +2,10 @@ S3method(as.matrix,dna_network_onemode) S3method(as.matrix,dna_network_twomode) -S3method(autoplot,dna_backbone) S3method(autoplot,dna_barplot) -S3method(plot,dna_backbone) -S3method(print,dna_backbone) S3method(print,dna_barplot) S3method(print,dna_network_onemode) S3method(print,dna_network_twomode) -export(dna_backbone) export(dna_barplot) export(dna_closeDatabase) export(dna_getAttributes) diff --git a/rDNA/R/rDNA.R b/rDNA/R/rDNA.R index 81a5aedf..9c572c6b 100644 --- a/rDNA/R/rDNA.R +++ b/rDNA/R/rDNA.R @@ -1327,7 +1327,7 @@ as.matrix.dna_network_twomode <- as.matrix.dna_network_onemode #' @importFrom rJava .jcall #' @importFrom rJava .jnull #' @importFrom rJava J -#' @export +#' @noRd dna_backbone <- function(penalty = 3.5, iterations = 10000, statementType = "DNA Statement", @@ -1499,7 +1499,7 @@ dna_backbone <- function(penalty = 3.5, #' @rdname dna_backbone #' @importFrom graphics lines #' @importFrom stats filter -#' @export +#' @noRd plot.dna_backbone <- function(x, ma = 500, ...) { # temperature and acceptance probability plot(x = x$diagnostics$iteration, @@ -1556,7 +1556,7 @@ plot.dna_backbone <- function(x, ma = 500, ...) { #' @rdname dna_backbone #' @param x A \code{"dna_backbone"} object. -#' @export +#' @noRd print.dna_backbone <- function(x, ...) { cat(paste0("Penalty: ", x$penalty, ". Iterations: ", x$iterations, ".\n\n")) cat(paste0("Backbone set (loss: ", round(x$unpenalized_backbone_loss, 4), "):\n")) @@ -1577,7 +1577,7 @@ print.dna_backbone <- function(x, ...) { #' @importFrom ggplot2 ggtitle #' @importFrom ggplot2 theme_bw #' @importFrom ggplot2 theme -#' @export +#' @noRd autoplot.dna_backbone <- function(object, ..., ma = 500) { bd <- object$diagnostics bd$bb_loss <- stats::filter(bd$penalized_backbone_loss, rep(1 / ma, ma), sides = 1) diff --git a/rDNA/man/dna_backbone.Rd b/rDNA/man/dna_backbone.Rd deleted file mode 100644 index 21a5f162..00000000 --- a/rDNA/man/dna_backbone.Rd +++ /dev/null @@ -1,297 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/rDNA.R -\name{dna_backbone} -\alias{dna_backbone} -\alias{plot.dna_backbone} -\alias{print.dna_backbone} -\alias{autoplot.dna_backbone} -\title{Compute and retrieve the backbone and redundant set} -\usage{ -dna_backbone( - penalty = 3.5, - iterations = 10000, - statementType = "DNA Statement", - variable1 = "organization", - variable1Document = FALSE, - variable2 = "concept", - variable2Document = FALSE, - qualifier = "agreement", - qualifierDocument = FALSE, - qualifierAggregation = "subtract", - normalization = "average", - duplicates = "document", - start.date = "01.01.1900", - stop.date = "31.12.2099", - start.time = "00:00:00", - stop.time = "23:59:59", - excludeValues = list(), - excludeAuthors = character(), - excludeSources = character(), - excludeSections = character(), - excludeTypes = character(), - invertValues = FALSE, - invertAuthors = FALSE, - invertSources = FALSE, - invertSections = FALSE, - invertTypes = FALSE, - fileFormat = NULL, - outfile = NULL -) - -\method{plot}{dna_backbone}(x, ma = 500, ...) - -\method{print}{dna_backbone}(x, ...) - -\method{autoplot}{dna_backbone}(object, ..., ma = 500) -} -\arguments{ -\item{penalty}{The penalty parameter for large backbone sets. The larger the -value, the more strongly larger backbone sets are punished and the smaller -the resulting backbone is. Try out different values to find the right size -of the backbone set. Reasonable values could be \code{2.5}, \code{5}, -\code{7.5}, or \code{12}, for example. The minimum is \code{0.0}, which -imposes no penalty on the size of the backbone set and produces a redundant -set with only one element. Start with \code{0.0} if you want to weed out a -single concept and subsequently increase the penalty to include more items -in the redundant set and shrink the backbone further.} - -\item{iterations}{The number of iterations of the simulated annealing -algorithm. More iterations take more time but may lead to better -optimization results.} - -\item{statementType}{The name of the statement type in which the variable -of interest is nested. For example, \code{"DNA Statement"}.} - -\item{variable1}{The first variable for network construction. In a one-mode -network, this is the variable for both the rows and columns. In a -two-mode network, this is the variable for the rows only. In an event -list, this variable is only used to check for duplicates (depending on -the setting of the \code{duplicates} argument).} - -\item{variable1Document}{A boolean value indicating whether the first -variable is at the document level (i.e., \code{"author"}, -\code{"source"}, \code{"section"}, \code{"type"}, \code{"id"}, or -\code{"title"}).} - -\item{variable2}{The second variable for network construction. In a one-mode -network, this is the variable over which the ties are created. For -example, if an organization x organization network is created, and ties -in this network indicate co-reference to a concept, then the second -variable is the \code{"concept"}. In a two-mode network, this is the -variable used for the columns of the network matrix. In an event list, -this variable is only used to check for duplicates (depending on the -setting of the \code{duplicates} argument).} - -\item{variable2Document}{A boolean value indicating whether the second -variable is at the document level (i.e., \code{"author"}, -\code{"source"}, \code{"section"}, \code{"type"}, \code{"id"}, or -\code{"title"}} - -\item{qualifier}{The qualifier variable. In a one-mode network, this - variable can be used to count only congruence or conflict ties. For - example, in an organization x organization network via common concepts, - a binary \code{"agreement"} qualifier could be used to record only ties - where both organizations have a positive stance on the concept or where - both organizations have a negative stance on the concept. With an - integer qualifier, the tie weight between the organizations would be - proportional to the similarity or distance between the two organizations - on the scale of the integer variable. With a short text variable as a - qualifier, agreement on common categorical values of the qualifier is - required, for example a tie is established (or a tie weight increased) if - two actors both refer to the same value on the second variable AND match on - the categorical qualifier, for example the type of referral. - - In a two-mode network, the qualifier variable can be used to retain only - positive or only negative statements or subtract negative from positive - mentions. All of this depends on the setting of the - \code{qualifierAggregation} argument. For event lists, the qualifier - variable is only used for filtering out duplicates (depending on the - setting of the \code{duplicates} argument. - - The qualifier can also be \code{NULL}, in which case it is ignored, meaning - that values in \code{variable1} and \code{variable2} are unconditionally - associated with each other in the network when they co-occur. This is - identical to selecting a qualifier variable and setting - \code{qualifierAggregation = "ignore"}.} - -\item{qualifierDocument}{A boolean value indicating whether the qualifier -variable is at the document level (i.e., \code{"author"}, -\code{"source"}, \code{"section"}, \code{"type"}, \code{"id"}, or -\code{"title"}} - -\item{qualifierAggregation}{The aggregation rule for the \code{qualifier} -variable. This must be \code{"ignore"} (for ignoring the qualifier -variable), \code{"congruence"} (for recording a network tie only if both -nodes have the same qualifier value in the binary case or for recording the -similarity between the two nodes on the qualifier variable in the integer -case), \code{"conflict"} (for recording a network tie only if both nodes -have a different qualifier value in the binary case or for recording the -distance between the two nodes on the qualifier variable in the integer -case), or \code{"subtract"} (for subtracting the conflict tie value from -the congruence tie value in each dyad; note that negative values will be -replaced by \code{0} in the backbone calculation).} - -\item{normalization}{Normalization of edge weights. Valid settings are -\code{"no"} (for switching off normalization), \code{"average"} (for -average activity normalization), \code{"jaccard"} (for Jaccard coefficient -normalization), and \code{"cosine"} (for cosine similarity normalization).} - -\item{duplicates}{Setting for excluding duplicate statements before network -construction. Valid settings are \code{"include"} (for including all -statements in network construction), \code{"document"} (for counting -only one identical statement per document), \code{"week"} (for counting -only one identical statement per calendar week), \code{"month"} (for -counting only one identical statement per calendar month), \code{"year"} -(for counting only one identical statement per calendar year), and -\code{"acrossrange"} (for counting only one identical statement across -the whole time range).} - -\item{start.date}{The start date for network construction in the format -\code{"dd.mm.yyyy"}. All statements before this date will be excluded.} - -\item{stop.date}{The stop date for network construction in the format -\code{"dd.mm.yyyy"}. All statements after this date will be excluded.} - -\item{start.time}{The start time for network construction on the specified -\code{start.date}. All statements before this time on the specified date -will be excluded.} - -\item{stop.time}{The stop time for network construction on the specified -\code{stop.date}. All statements after this time on the specified date -will be excluded.} - -\item{excludeValues}{A list of named character vectors that contains entries -which should be excluded during network construction. For example, -\code{list(concept = c("A", "B"), organization = c("org A", "org B"))} -would exclude all statements containing concepts "A" or "B" or -organizations "org A" or "org B" when the network is constructed. This -is irrespective of whether these values appear in \code{variable1}, -\code{variable2}, or the \code{qualifier}. Note that only variables at -the statement level can be used here. There are separate arguments for -excluding statements nested in documents with certain meta-data.} - -\item{excludeAuthors}{A character vector of authors. If a statement is -nested in a document where one of these authors is set in the "Author" -meta-data field, the statement is excluded from network construction.} - -\item{excludeSources}{A character vector of sources. If a statement is -nested in a document where one of these sources is set in the "Source" -meta-data field, the statement is excluded from network construction.} - -\item{excludeSections}{A character vector of sections. If a statement is -nested in a document where one of these sections is set in the "Section" -meta-data field, the statement is excluded from network construction.} - -\item{excludeTypes}{A character vector of types. If a statement is -nested in a document where one of these types is set in the "Type" -meta-data field, the statement is excluded from network construction.} - -\item{invertValues}{A boolean value indicating whether the entries provided -by the \code{excludeValues} argument should be excluded from network -construction (\code{invertValues = FALSE}) or if they should be the only -values that should be included during network construction -(\code{invertValues = TRUE}).} - -\item{invertAuthors}{A boolean value indicating whether the entries provided -by the \code{excludeAuthors} argument should be excluded from network -construction (\code{invertAuthors = FALSE}) or if they should be the -only values that should be included during network construction -(\code{invertAuthors = TRUE}).} - -\item{invertSources}{A boolean value indicating whether the entries provided -by the \code{excludeSources} argument should be excluded from network -construction (\code{invertSources = FALSE}) or if they should be the -only values that should be included during network construction -(\code{invertSources = TRUE}).} - -\item{invertSections}{A boolean value indicating whether the entries -provided by the \code{excludeSections} argument should be excluded from -network construction (\code{invertSections = FALSE}) or if they should -be the only values that should be included during network construction -(\code{invertSections = TRUE}).} - -\item{invertTypes}{A boolean value indicating whether the entries provided -by the \code{excludeTypes} argument should be excluded from network -construction (\code{invertTypes = FALSE}) or if they should be the -only values that should be included during network construction -(\code{invertTypes = TRUE}).} - -\item{fileFormat}{An optional file format specification for saving the -backbone results to a file instead of returning an object. Valid values -are \code{"json"}, \code{"xml"}, and \code{NULL} (for returning the results -instead of writing them to a file).} - -\item{outfile}{An optional output file name for saving the resulting -network(s) to a file instead of returning an object.} - -\item{x}{A \code{"dna_backbone"} object.} - -\item{ma}{Number of iterations to compute moving average.} - -\item{...}{Additional arguments.} - -\item{object}{A \code{"dna_backbone"} object.} -} -\description{ -Compute and retrieve the backbone and redundant set of a discourse network. -} -\details{ -This function applies a simulated annealing algorithm to the discourse -network to partition the set of second-mode entities (e.g., concepts) into a -backbone set and a complementary redundant set. -} -\examples{ -\dontrun{ -dna_init() -dna_sample() -dna_openDatabase("sample.dna", coderId = 1, coderPassword = "sample") - -# compute backbone and redundant set -b <- dna_backbone(penalty = 3.5, - iterations = 10000, - variable1 = "organization", - variable2 = "concept", - qualifier = "agreement", - qualifierAggregation = "subtract", - normalization = "average") - -b # display main results - -# extract results from the object -b$backbone # show the set of backbone concepts -b$redundant # show the set of redundant concepts -b$unpenalized_backbone_loss # spectral loss between full and backbone network -b$unpenalized_redundant_loss # spectral loss of redundant network -b$backbone_network # show the backbone network -b$redundant_network # show the redundant network -b$full_network # show the full network - -# plot diagnostics with base R -plot(b, ma = 500) - -# arrange plots in a 2 x 2 view -par(mfrow = c(2, 2)) -plot(b) - -# plot diagnostics with ggplot2 -library("ggplot2") -p <- autoplot(b) -p - -# pick a specific diagnostic -p[[3]] - -# use the patchwork package to arrange the diagnostics in a single plot -library("patchwork") -new_plot <- p[[1]] + p[[2]] + p[[3]] + p[[4]] -new_plot & theme_grey() + theme(legend.position = "bottom") - -# use the gridExtra package to arrange the diagnostics in a single plot -library("gridExtra") -grid.arrange(p[[1]], p[[2]], p[[3]], p[[4]]) -} - -} -\author{ -Philip Leifeld, Tim Henrichsen -}