Skip to content
This repository has been archived by the owner on Aug 1, 2023. It is now read-only.

Commit

Permalink
added venn plot
Browse files Browse the repository at this point in the history
changed namespace
  • Loading branch information
sbalci committed Feb 16, 2021
1 parent 6d40ad3 commit 8be6cae
Show file tree
Hide file tree
Showing 18 changed files with 589 additions and 30 deletions.
11 changes: 6 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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/
Expand All @@ -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)
Expand Down
9 changes: 8 additions & 1 deletion R/00jmv.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
4 changes: 2 additions & 2 deletions R/agepyramid.h.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ agepyramidOptions <- if (requireNamespace('jmvcore')) R6::R6Class(
female = NULL, ...) {

super$initialize(
package='ClinicoPathDescriptives',
package='ClinicoPathLinuxDescriptives',
name='agepyramid',
requiresData=TRUE,
...)
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 5 additions & 3 deletions R/benford.h.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ benfordOptions <- if (requireNamespace('jmvcore')) R6::R6Class(
var = NULL, ...) {

super$initialize(
package='ClinicoPathDescriptives',
package='ClinicoPathLinuxDescriptives',
name='benford',
requiresData=TRUE,
...)
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions R/crosstable.h.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ crosstableOptions <- if (requireNamespace('jmvcore')) R6::R6Class(
pcat = "chisq", ...) {

super$initialize(
package='ClinicoPathDescriptives',
package='ClinicoPathLinuxDescriptives',
name='crosstable',
requiresData=TRUE,
...)
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions R/reportcat.h.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ reportcatOptions <- if (requireNamespace('jmvcore')) R6::R6Class(
vars = NULL, ...) {

super$initialize(
package='ClinicoPathDescriptives',
package='ClinicoPathLinuxDescriptives',
name='reportcat',
requiresData=TRUE,
...)
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions R/summarydata.h.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ summarydataOptions <- if (requireNamespace('jmvcore')) R6::R6Class(
vars = NULL, ...) {

super$initialize(
package='ClinicoPathDescriptives',
package='ClinicoPathLinuxDescriptives',
name='summarydata',
requiresData=TRUE,
...)
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions R/tableone.h.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ tableoneOptions <- if (requireNamespace('jmvcore')) R6::R6Class(
excl = TRUE, ...) {

super$initialize(
package='ClinicoPathDescriptives',
package='ClinicoPathLinuxDescriptives',
name='tableone',
requiresData=TRUE,
...)
Expand Down Expand Up @@ -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,
Expand Down
155 changes: 155 additions & 0 deletions R/venn.b.R
Original file line number Diff line number Diff line change
@@ -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 <- "
<br>Welcome to ClinicoPath
<br><br>
This tool will help you form Venn Diagrams.
<hr><br>
"

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
}
)
)
Loading

0 comments on commit 8be6cae

Please sign in to comment.