diff --git a/DESCRIPTION b/DESCRIPTION index 3d91420..fc63dae 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package -Package: ClinicoPathDescriptives +Package: ClinicoPathLinuxDescriptives Title: Descriptives Functions for Clinicopathological Research -Version: 0.0.2.0041 -Date: 2020-08-31 +Version: 0.0.2.0065 +Date: 2021-02-16 Authors@R: person(given = "Serdar", family = "Balci", @@ -17,7 +17,7 @@ Description: Descriptives Functions for Clinicopathological Research survival analysis with survival tables, survival plots, and natural language summaries. URL: https://github.com/sbalci/ClinicoPathJamoviModule/, - https://github.com/sbalci/ClinicoPathDescriptives/, + https://github.com/sbalci/ClinicoPathLinuxDescriptives/, https://sbalci.github.io/ClinicoPathJamoviModule/ BugReports: https://github.com/sbalci/ClinicoPathJamoviModule/issues/ @@ -43,7 +43,8 @@ Imports: Remotes: spgarbet/tangram, mayoverse/arsenal, - carloscinelli/benford.analysis + carloscinelli/benford.analysis, + yanlinlin82/ggvenn Encoding: UTF-8 LazyData: true Roxygen: list(markdown = TRUE) diff --git a/R/00jmv.R b/R/00jmv.R index 7d3ab36..b549021 100644 --- a/R/00jmv.R +++ b/R/00jmv.R @@ -416,4 +416,11 @@ `volume`=25, `pages`="127-141", `doi`="10.1002/sim.2331", - `url`="https://onlinelibrary.wiley.com/doi/abs/10.1002/sim.2331")) + `url`="https://onlinelibrary.wiley.com/doi/abs/10.1002/sim.2331"), + `venn`=list( + `type`="software", + `author`="Linlin Yan", + `year`=2020, + `title`=" Venn Diagram by ggplot2, with really easy-to-use API", + `publisher`="[R package]. Retrieved from https://github.com/yanlinlin82/ggvenn", + `url`="https://github.com/yanlinlin82/ggvenn")) diff --git a/R/agepyramid.h.R b/R/agepyramid.h.R index 8bf2d5f..05ee828 100644 --- a/R/agepyramid.h.R +++ b/R/agepyramid.h.R @@ -11,7 +11,7 @@ agepyramidOptions <- if (requireNamespace('jmvcore')) R6::R6Class( female = NULL, ...) { super$initialize( - package='ClinicoPathDescriptives', + package='ClinicoPathLinuxDescriptives', name='agepyramid', requiresData=TRUE, ...) @@ -103,7 +103,7 @@ agepyramidBase <- if (requireNamespace('jmvcore')) R6::R6Class( public = list( initialize = function(options, data=NULL, datasetId="", analysisId="", revision=0) { super$initialize( - package = 'ClinicoPathDescriptives', + package = 'ClinicoPathLinuxDescriptives', name = 'agepyramid', version = c(1,0,0), options = options, diff --git a/R/benford.h.R b/R/benford.h.R index 55a1847..4c72bed 100644 --- a/R/benford.h.R +++ b/R/benford.h.R @@ -9,7 +9,7 @@ benfordOptions <- if (requireNamespace('jmvcore')) R6::R6Class( var = NULL, ...) { super$initialize( - package='ClinicoPathDescriptives', + package='ClinicoPathLinuxDescriptives', name='benford', requiresData=TRUE, ...) @@ -43,7 +43,9 @@ benfordResults <- if (requireNamespace('jmvcore')) R6::R6Class( super$initialize( options=options, name="", - title="Benford Analysis") + title="Benford Analysis", + refs=list( + "benford.analysis")) self$add(jmvcore::Html$new( options=options, name="todo", @@ -71,7 +73,7 @@ benfordBase <- if (requireNamespace('jmvcore')) R6::R6Class( public = list( initialize = function(options, data=NULL, datasetId="", analysisId="", revision=0) { super$initialize( - package = 'ClinicoPathDescriptives', + package = 'ClinicoPathLinuxDescriptives', name = 'benford', version = c(1,0,0), options = options, diff --git a/R/crosstable.h.R b/R/crosstable.h.R index 54146fa..343aa0d 100644 --- a/R/crosstable.h.R +++ b/R/crosstable.h.R @@ -14,7 +14,7 @@ crosstableOptions <- if (requireNamespace('jmvcore')) R6::R6Class( pcat = "chisq", ...) { super$initialize( - package='ClinicoPathDescriptives', + package='ClinicoPathLinuxDescriptives', name='crosstable', requiresData=TRUE, ...) @@ -152,7 +152,7 @@ crosstableBase <- if (requireNamespace('jmvcore')) R6::R6Class( public = list( initialize = function(options, data=NULL, datasetId="", analysisId="", revision=0) { super$initialize( - package = 'ClinicoPathDescriptives', + package = 'ClinicoPathLinuxDescriptives', name = 'crosstable', version = c(1,0,0), options = options, diff --git a/R/reportcat.h.R b/R/reportcat.h.R index 2c277e7..08b3e0b 100644 --- a/R/reportcat.h.R +++ b/R/reportcat.h.R @@ -9,7 +9,7 @@ reportcatOptions <- if (requireNamespace('jmvcore')) R6::R6Class( vars = NULL, ...) { super$initialize( - package='ClinicoPathDescriptives', + package='ClinicoPathLinuxDescriptives', name='reportcat', requiresData=TRUE, ...) @@ -61,7 +61,7 @@ reportcatBase <- if (requireNamespace('jmvcore')) R6::R6Class( public = list( initialize = function(options, data=NULL, datasetId="", analysisId="", revision=0) { super$initialize( - package = 'ClinicoPathDescriptives', + package = 'ClinicoPathLinuxDescriptives', name = 'reportcat', version = c(1,0,0), options = options, diff --git a/R/summarydata.h.R b/R/summarydata.h.R index 5c91fac..16d6034 100644 --- a/R/summarydata.h.R +++ b/R/summarydata.h.R @@ -9,7 +9,7 @@ summarydataOptions <- if (requireNamespace('jmvcore')) R6::R6Class( vars = NULL, ...) { super$initialize( - package='ClinicoPathDescriptives', + package='ClinicoPathLinuxDescriptives', name='summarydata', requiresData=TRUE, ...) @@ -57,7 +57,7 @@ summarydataBase <- if (requireNamespace('jmvcore')) R6::R6Class( public = list( initialize = function(options, data=NULL, datasetId="", analysisId="", revision=0) { super$initialize( - package = 'ClinicoPathDescriptives', + package = 'ClinicoPathLinuxDescriptives', name = 'summarydata', version = c(1,0,0), options = options, diff --git a/R/tableone.h.R b/R/tableone.h.R index 9ee993e..5652630 100644 --- a/R/tableone.h.R +++ b/R/tableone.h.R @@ -11,7 +11,7 @@ tableoneOptions <- if (requireNamespace('jmvcore')) R6::R6Class( excl = TRUE, ...) { super$initialize( - package='ClinicoPathDescriptives', + package='ClinicoPathLinuxDescriptives', name='tableone', requiresData=TRUE, ...) @@ -109,7 +109,7 @@ tableoneBase <- if (requireNamespace('jmvcore')) R6::R6Class( public = list( initialize = function(options, data=NULL, datasetId="", analysisId="", revision=0) { super$initialize( - package = 'ClinicoPathDescriptives', + package = 'ClinicoPathLinuxDescriptives', name = 'tableone', version = c(0,0,1), options = options, diff --git a/R/venn.b.R b/R/venn.b.R new file mode 100644 index 0000000..71859a9 --- /dev/null +++ b/R/venn.b.R @@ -0,0 +1,155 @@ +#' @title Venn Diagram +#' +#' +#' +#' +#' @importFrom R6 R6Class +#' @import jmvcore +#' @import ggvenn + + +vennClass <- if (requireNamespace('jmvcore')) + R6::R6Class( + "vennClass", + inherit = vennBase, + private = list( + .run = function() { + # Error Message ---- + + + if (is.null(self$options$var1) || is.null(self$options$var2)) { + # ToDo Message ---- + todo <- " +
Welcome to ClinicoPath +

+ This tool will help you form Venn Diagrams. +

+ " + + html <- self$results$todo + html$setContent(todo) + + } else { + todo <- "" + html <- self$results$todo + html$setContent(todo) + + + + if (nrow(self$data) == 0) + stop("Data contains no (complete) rows") + + + # Read data ---- + + mydata <- self$data + + var1 <- self$options$var1 + var1true <- self$options$var1true + + var2 <- self$options$var2 + var2true <- self$options$var2true + + var3 <- self$options$var3 + var3true <- self$options$var3true + + var4 <- self$options$var4 + var4true <- self$options$var4true + + # mydata <- jmvcore::select(df = mydata, + # columnNames = c(var1, var2, var3, var4)) + + mydata <- jmvcore::naOmit(mydata) + + + if (!is.null(self$options$var1)) { + mydata[[var1]] <- + ifelse(test = mydata[[var1]] == var1true, TRUE, FALSE) + } + + if (!is.null(self$options$var2)) { + mydata[[var2]] <- + ifelse(test = mydata[[var2]] == var2true, TRUE, FALSE) + } + + if (!is.null(self$options$var3)) { + mydata[[var3]] <- + ifelse(test = mydata[[var3]] == var3true, TRUE, FALSE) + } + + if (!is.null(self$options$var4)) { + mydata[[var4]] <- + ifelse(test = mydata[[var4]] == var4true, TRUE, FALSE) + } + + # myoutput1 <- list( + # "mydata" = head(mydata), + # "names" = names(mydata) + # ) + + + # self$results$output1$setContent(myoutput1) + + + plotData <- list("mydata" = mydata, + "names" = names(mydata) + ) + + image <- self$results$plot + image$setState(plotData) + + + } + + } + + , + + .plot = function(image, ggtheme, theme, ...) { + # the plot function ---- + + + #Errors ---- + + if (is.null(self$options$var1) || is.null(self$options$var2)) + return() + + if (nrow(self$data) == 0) + stop('Data contains no (complete) rows') + + + # Prepare Data ---- + + results <- image$state + + mydata2 <- results$mydata + + namescolumn2 <- results$names + + # Venn Diagram by ggplot2, with really easy-to-use API. + # https://github.com/yanlinlin82/ggvenn + + plot <- + ggvenn::ggvenn(data = mydata2, + columns = namescolumn2) + + + plot <- + plot + + ggtheme + + ggplot2::theme(axis.line.x = ggplot2::element_blank(), + axis.text.x = ggplot2::element_blank(), + axis.ticks.x = ggplot2::element_blank(), + axis.title.x = ggplot2::element_blank(), + axis.line.y = ggplot2::element_blank(), + axis.text.y = ggplot2::element_blank(), + axis.ticks.y = ggplot2::element_blank(), + axis.title.y = ggplot2::element_blank() + ) + + # Print Plot ---- + print(plot) + TRUE + } + ) + ) diff --git a/R/venn.h.R b/R/venn.h.R new file mode 100644 index 0000000..980b397 --- /dev/null +++ b/R/venn.h.R @@ -0,0 +1,225 @@ + +# This file is automatically generated, you probably don't want to edit this + +vennOptions <- if (requireNamespace('jmvcore')) R6::R6Class( + "vennOptions", + inherit = jmvcore::Options, + public = list( + initialize = function( + var1 = NULL, + var1true = NULL, + var2 = NULL, + var2true = NULL, + var3 = NULL, + var3true = NULL, + var4 = NULL, + var4true = NULL, ...) { + + super$initialize( + package='ClinicoPathLinuxDescriptives', + name='venn', + requiresData=TRUE, + ...) + + private$..var1 <- jmvcore::OptionVariable$new( + "var1", + var1, + suggested=list( + "ordinal", + "nominal"), + permitted=list( + "factor")) + private$..var1true <- jmvcore::OptionLevel$new( + "var1true", + var1true, + variable="(var1)") + private$..var2 <- jmvcore::OptionVariable$new( + "var2", + var2, + suggested=list( + "ordinal", + "nominal"), + permitted=list( + "factor")) + private$..var2true <- jmvcore::OptionLevel$new( + "var2true", + var2true, + variable="(var2)") + private$..var3 <- jmvcore::OptionVariable$new( + "var3", + var3, + suggested=list( + "ordinal", + "nominal"), + permitted=list( + "factor")) + private$..var3true <- jmvcore::OptionLevel$new( + "var3true", + var3true, + variable="(var3)") + private$..var4 <- jmvcore::OptionVariable$new( + "var4", + var4, + suggested=list( + "ordinal", + "nominal"), + permitted=list( + "factor")) + private$..var4true <- jmvcore::OptionLevel$new( + "var4true", + var4true, + variable="(var4)") + + self$.addOption(private$..var1) + self$.addOption(private$..var1true) + self$.addOption(private$..var2) + self$.addOption(private$..var2true) + self$.addOption(private$..var3) + self$.addOption(private$..var3true) + self$.addOption(private$..var4) + self$.addOption(private$..var4true) + }), + active = list( + var1 = function() private$..var1$value, + var1true = function() private$..var1true$value, + var2 = function() private$..var2$value, + var2true = function() private$..var2true$value, + var3 = function() private$..var3$value, + var3true = function() private$..var3true$value, + var4 = function() private$..var4$value, + var4true = function() private$..var4true$value), + private = list( + ..var1 = NA, + ..var1true = NA, + ..var2 = NA, + ..var2true = NA, + ..var3 = NA, + ..var3true = NA, + ..var4 = NA, + ..var4true = NA) +) + +vennResults <- if (requireNamespace('jmvcore')) R6::R6Class( + inherit = jmvcore::Group, + active = list( + todo = function() private$.items[["todo"]], + plot = function() private$.items[["plot"]]), + private = list(), + public=list( + initialize=function(options) { + super$initialize( + options=options, + name="", + title="Venn Diagram", + refs=list( + "venn"), + clearWith=list( + "var1", + "var2", + "var3", + "var4", + "var1true", + "var2true", + "var3true", + "var4true")) + self$add(jmvcore::Html$new( + options=options, + name="todo", + title="To Do")) + self$add(jmvcore::Image$new( + options=options, + title="Venn Diagram", + name="plot", + width=600, + height=450, + renderFun=".plot", + requiresData=TRUE))})) + +vennBase <- if (requireNamespace('jmvcore')) R6::R6Class( + "vennBase", + inherit = jmvcore::Analysis, + public = list( + initialize = function(options, data=NULL, datasetId="", analysisId="", revision=0) { + super$initialize( + package = 'ClinicoPathLinuxDescriptives', + name = 'venn', + version = c(1,0,0), + options = options, + results = vennResults$new(options=options), + data = data, + datasetId = datasetId, + analysisId = analysisId, + revision = revision, + pause = NULL, + completeWhenFilled = FALSE, + requiresMissings = FALSE) + })) + +#' Venn Diagram +#' +#' +#' @param data The data as a data frame. +#' @param var1 . +#' @param var1true . +#' @param var2 . +#' @param var2true . +#' @param var3 . +#' @param var3true . +#' @param var4 . +#' @param var4true . +#' @return A results object containing: +#' \tabular{llllll}{ +#' \code{results$todo} \tab \tab \tab \tab \tab a html \cr +#' \code{results$plot} \tab \tab \tab \tab \tab an image \cr +#' } +#' +#' @export +venn <- function( + data, + var1, + var1true, + var2, + var2true, + var3, + var3true, + var4, + var4true) { + + if ( ! requireNamespace('jmvcore')) + stop('venn requires jmvcore to be installed (restart may be required)') + + if ( ! missing(var1)) var1 <- jmvcore::resolveQuo(jmvcore::enquo(var1)) + if ( ! missing(var2)) var2 <- jmvcore::resolveQuo(jmvcore::enquo(var2)) + if ( ! missing(var3)) var3 <- jmvcore::resolveQuo(jmvcore::enquo(var3)) + if ( ! missing(var4)) var4 <- jmvcore::resolveQuo(jmvcore::enquo(var4)) + if (missing(data)) + data <- jmvcore::marshalData( + parent.frame(), + `if`( ! missing(var1), var1, NULL), + `if`( ! missing(var2), var2, NULL), + `if`( ! missing(var3), var3, NULL), + `if`( ! missing(var4), var4, NULL)) + + for (v in var1) if (v %in% names(data)) data[[v]] <- as.factor(data[[v]]) + for (v in var2) if (v %in% names(data)) data[[v]] <- as.factor(data[[v]]) + for (v in var3) if (v %in% names(data)) data[[v]] <- as.factor(data[[v]]) + for (v in var4) if (v %in% names(data)) data[[v]] <- as.factor(data[[v]]) + + options <- vennOptions$new( + var1 = var1, + var1true = var1true, + var2 = var2, + var2true = var2true, + var3 = var3, + var3true = var3true, + var4 = var4, + var4true = var4true) + + analysis <- vennClass$new( + options = options, + data = data) + + analysis$run() + + analysis$results +} diff --git a/README.md b/README.md index 1688db4..3c8ef31 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ ClinicoPath jamovi module Descriptives functions working in Linux +(not all packages work with Linux) + See https://sbalci.github.io/ClinicoPathJamoviModule/ diff --git a/data/histopathologyDescriptives.omv b/data/histopathologyDescriptives.omv index 66f1bd5..98e7694 100644 Binary files a/data/histopathologyDescriptives.omv and b/data/histopathologyDescriptives.omv differ diff --git a/jamovi/0000.yaml b/jamovi/0000.yaml index 44bc08a..aa746d6 100644 --- a/jamovi/0000.yaml +++ b/jamovi/0000.yaml @@ -1,12 +1,12 @@ --- title: Descriptives Functions for Clinicopathological Research -name: ClinicoPathDescriptives -version: 0.0.2.0041 +name: ClinicoPathLinuxDescriptives +version: 0.0.2.0065 jms: '1.0' authors: - Serdar Balci maintainer: Serdar Balci -date: '2020-08-31' +date: '2021-02-16' type: R description: >- Descriptives Functions for Clinicopathological Research Descriptive functions @@ -17,44 +17,50 @@ description: >- analyses: - title: Table One name: tableone - ns: ClinicoPathDescriptives + ns: ClinicoPathLinuxDescriptives menuGroup: Exploration menuSubgroup: ClinicoPath Descriptives menuTitle: Table One description: Function for making Table One. - title: Summary of Continuous Variables name: summarydata - ns: ClinicoPathDescriptives + ns: ClinicoPathLinuxDescriptives menuGroup: Exploration menuSubgroup: ClinicoPath Descriptives menuTitle: Summary of Continuous Variables description: Function for Generating Summaries for Continuous Variables. - title: Summary of Categorical Variables name: reportcat - ns: ClinicoPathDescriptives + ns: ClinicoPathLinuxDescriptives menuGroup: Exploration menuSubgroup: ClinicoPath Descriptives menuTitle: Summary of Categorical Variables description: Function for Generating Summaries for Categorical Variables. - title: Cross Tables name: crosstable - ns: ClinicoPathDescriptives + ns: ClinicoPathLinuxDescriptives menuGroup: Exploration menuSubgroup: ClinicoPath Comparisons menuTitle: Cross Tables description: Function for making Cross Tables. - title: Age Pyramid name: agepyramid - ns: ClinicoPathDescriptives + ns: ClinicoPathLinuxDescriptives menuGroup: Exploration menuSubgroup: ClinicoPath Descriptive Plots menuTitle: Age Pyramid - title: Benford Analysis name: benford - ns: ClinicoPathDescriptives + ns: ClinicoPathLinuxDescriptives menuGroup: Exploration menuSubgroup: ClinicoPath Descriptives menuTitle: Benford Analysis + - title: Venn Diagram + name: venn + ns: ClinicoPathLinuxDescriptives + menuGroup: Exploration + menuSubgroup: ClinicoPath Descriptive Plots + menuTitle: Venn Diagram datasets: - name: histopathology including analysis path: histopathologyDescriptives.omv diff --git a/jamovi/00refs.yaml b/jamovi/00refs.yaml index 09698b3..13fbede 100644 --- a/jamovi/00refs.yaml +++ b/jamovi/00refs.yaml @@ -502,7 +502,13 @@ refs: doi: 10.1002/sim.2331 url: https://onlinelibrary.wiley.com/doi/abs/10.1002/sim.2331 - + venn: + type: 'software' + author: Linlin Yan + year: 2020 + title: " Venn Diagram by ggplot2, with really easy-to-use API" + publisher: '[R package]. Retrieved from https://github.com/yanlinlin82/ggvenn' + url: https://github.com/yanlinlin82/ggvenn diff --git a/jamovi/benford.r.yaml b/jamovi/benford.r.yaml index c1a91ac..84e7344 100644 --- a/jamovi/benford.r.yaml +++ b/jamovi/benford.r.yaml @@ -27,5 +27,6 @@ items: renderFun: .plot requiresData: true - +refs: + - benford.analysis ... diff --git a/jamovi/venn.a.yaml b/jamovi/venn.a.yaml new file mode 100644 index 0000000..8591c9b --- /dev/null +++ b/jamovi/venn.a.yaml @@ -0,0 +1,64 @@ +--- +name: venn +title: Venn Diagram +menuGroup: Exploration +menuSubgroup: ClinicoPath Descriptive Plots +version: '1.0.0' +jas: '1.2' + +options: + + - name: data + type: Data + description: + R: > + The data as a data frame. + + - name: var1 + title: 'Variable 1' + type: Variable + suggested: [ ordinal, nominal ] + permitted: [ factor ] + + - name: var1true + title: 'Select True Level' + type: Level + variable: (var1) + + + - name: var2 + title: 'Variable 2' + type: Variable + suggested: [ ordinal, nominal ] + permitted: [ factor ] + + - name: var2true + title: 'Select True Level' + type: Level + variable: (var2) + + + - name: var3 + title: 'Variable 3' + type: Variable + suggested: [ ordinal, nominal ] + permitted: [ factor ] + + - name: var3true + title: 'Select True Level' + type: Level + variable: (var3) + + - name: var4 + title: 'Variable 4' + type: Variable + suggested: [ ordinal, nominal ] + permitted: [ factor ] + + - name: var4true + title: 'Select True Level' + type: Level + variable: (var4) + + +... diff --git a/jamovi/venn.r.yaml b/jamovi/venn.r.yaml new file mode 100644 index 0000000..ad15bad --- /dev/null +++ b/jamovi/venn.r.yaml @@ -0,0 +1,37 @@ +--- +name: venn +title: Venn Diagram +jrs: '1.1' + +clearWith: + - var1 + - var2 + - var3 + - var4 + - var1true + - var2true + - var3true + - var4true + +items: + + - name: todo + title: To Do + type: Html + + # - name: output1 + # title: To Do + # type: Preformatted + + - title: Venn Diagram + name: plot + type: Image + width: 600 + height: 450 + renderFun: .plot + requiresData: true + +refs: + - venn + +... diff --git a/jamovi/venn.u.yaml b/jamovi/venn.u.yaml new file mode 100644 index 0000000..a9c6d55 --- /dev/null +++ b/jamovi/venn.u.yaml @@ -0,0 +1,53 @@ +title: Venn Diagram +name: venn +jus: '3.0' +stage: 0 +compilerMode: tame +children: + - type: VariableSupplier + persistentItems: false + stretchFactor: 1 + children: + - type: TargetLayoutBox + label: Variable 1 + children: + - type: VariablesListBox + name: var1 + isTarget: true + maxItemCount: 1 + - type: LevelSelector + name: var1true + enable: (var1) + - type: TargetLayoutBox + label: Variable 2 + children: + - type: VariablesListBox + name: var2 + isTarget: true + maxItemCount: 1 + enable: (var1) + - type: LevelSelector + name: var2true + enable: (var2) + - type: TargetLayoutBox + label: Variable 3 + children: + - type: VariablesListBox + name: var3 + isTarget: true + maxItemCount: 1 + enable: (var2) + - type: LevelSelector + name: var3true + enable: (var3) + - type: TargetLayoutBox + label: Variable 4 + children: + - type: VariablesListBox + name: var4 + isTarget: true + maxItemCount: 1 + enable: (var3) + - type: LevelSelector + name: var4true + enable: (var4)