diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml new file mode 100644 index 0000000..2420e65 --- /dev/null +++ b/.github/workflows/R-CMD-check.yaml @@ -0,0 +1,103 @@ +# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag. +# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions +on: + push: + branches: + - dev + - master + pull_request: + branches: + - dev + - master + +name: R-CMD-check + +jobs: + R-CMD-check: + runs-on: ${{ matrix.config.os }} + + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) + + strategy: + fail-fast: false + matrix: + config: + - {os: windows-latest, r: 'release'} + - {os: macOS-latest, r: 'release'} + - {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} + # - {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} + + env: + R_REMOTES_NO_ERRORS_FROM_WARNINGS: true + RSPM: ${{ matrix.config.rspm }} + + steps: + - uses: actions/checkout@v2 + + - uses: r-lib/actions/setup-r@v1 + with: + r-version: ${{ matrix.config.r }} + + - uses: r-lib/actions/setup-pandoc@v1 + + - name: Query dependencies + run: | + install.packages('remotes') + saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) + writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") + shell: Rscript {0} + + - name: Cache R packages + if: runner.os != 'Windows' + uses: actions/cache@v2 + with: + path: ${{ env.R_LIBS_USER }} + key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} + restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- + + - name: Install system dependencies + if: runner.os == 'Linux' + run: | + while read -r cmd + do + eval sudo $cmd + done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))') + + - name: Install dependencies + run: | + remotes::install_deps(dependencies = TRUE) + remotes::install_cran("rcmdcheck") + shell: Rscript {0} + + - name: Check + env: + _R_CHECK_CRAN_INCOMING_REMOTE_: false + _R_CHECK_FORCE_SUGGESTS_ : false + run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), build_args = "--no-manual", error_on = "warning", check_dir = "check") + shell: Rscript {0} + + - name: Install pkgdown + if: github.ref == 'refs/heads/master' && runner.os == 'Linux' + run: | + remotes::install_deps(dependencies = TRUE) + install.packages("pkgdown") + shell: Rscript {0} + + - name: Install package + if: github.ref == 'refs/heads/master' && runner.os == 'Linux' + run: R CMD INSTALL . + + - name: Deploy package + if: github.ref == 'refs/heads/master' && runner.os == 'Linux' + run: | + git config --local user.email "actions@github.com" + git config --local user.name "GitHub Actions" + Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)' + shell: bash {0} + + - name: Upload check results + if: failure() + uses: actions/upload-artifact@main + with: + name: ${{ runner.os }}-r${{ matrix.config.r }}-results + path: check diff --git a/.github/workflows/R-CMD-check.yml b/.github/workflows/R-CMD-check.yml deleted file mode 100644 index 04f5b14..0000000 --- a/.github/workflows/R-CMD-check.yml +++ /dev/null @@ -1,80 +0,0 @@ -on: - push: - branches: - - master - - dev - pull_request: - branches: - - master - - dev - -name: R-CMD-check - -jobs: - R-CMD-check: - runs-on: ${{ matrix.config.os }} - - name: ${{ matrix.config.os }} (${{ matrix.config.r }}) - - strategy: - fail-fast: false - matrix: - config: - - {os: windows-latest, r: 'release'} - - {os: macOS-latest, r: 'release'} - - {os: ubuntu-16.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} - - env: - R_REMOTES_NO_ERRORS_FROM_WARNINGS: true - RSPM: ${{ matrix.config.rspm }} - - steps: - - uses: actions/checkout@v2 - - - uses: r-lib/actions/setup-r@master - with: - r-version: ${{ matrix.config.r }} - - - uses: r-lib/actions/setup-pandoc@master - - - name: Query dependencies - run: | - install.packages('remotes') - saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) - shell: Rscript {0} - - - name: Cache R packages - if: runner.os != 'Windows' - uses: actions/cache@v1 - with: - path: ${{ env.R_LIBS_USER }} - key: ${{ runner.os }}-r-${{ matrix.config.r }}-1-${{ hashFiles('.github/depends.Rds') }} - restore-keys: ${{ runner.os }}-r-${{ matrix.config.r }}-1- - - - name: Install system dependencies - if: runner.os == 'Linux' - env: - RHUB_PLATFORM: linux-x86_64-ubuntu-gcc - run: | - Rscript -e "remotes::install_github('r-hub/sysreqs')" - sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))") - sudo -s eval "$sysreqs" - - - name: Install dependencies - run: | - remotes::install_deps(dependencies = TRUE) - remotes::install_cran("rcmdcheck") - shell: Rscript {0} - - - name: Check - env: - _R_CHECK_CRAN_INCOMING_REMOTE_: false - run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check") - shell: Rscript {0} - - - name: Upload check results - if: failure() - uses: actions/upload-artifact@master - with: - name: ${{ runner.os }}-r${{ matrix.config.r }}-results - path: check diff --git a/DESCRIPTION b/DESCRIPTION index 4ef64b2..14e39cc 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: tidygate Type: Package Title: Add Gate Information to Your Tibble -Version: 0.4.9 +Version: 0.5.3 Authors@R: c(person(given = "Stefano", family = "Mangiola", @@ -20,7 +20,7 @@ Depends: R (>= 3.6.0) Encoding: UTF-8 LazyData: true -RoxygenNote: 7.1.2 +RoxygenNote: 7.3.1 Imports: utils, graphics, @@ -35,7 +35,10 @@ Imports: viridis, grDevices, RColorBrewer, - stringr + stringr, + shiny, + plotly, + ggplot2 RdMacros: lifecycle Suggests: testthat, diff --git a/NAMESPACE b/NAMESPACE index fc5eadd..d4d71d1 100755 --- a/NAMESPACE +++ b/NAMESPACE @@ -7,11 +7,23 @@ S3method(gate_int,numeric) export(fhs) export(gate) export(gate_chr) +export(gate_custom) export(gate_int) +export(gate_simple) +export(server) +export(ui) import(dplyr) import(tibble) import(tidyr) importFrom(RColorBrewer,brewer.pal) +importFrom(dplyr,mutate) +importFrom(dplyr,rename) +importFrom(dplyr,select) +importFrom(ggplot2,aes) +importFrom(ggplot2,geom_point) +importFrom(ggplot2,ggplot) +importFrom(ggplot2,ggplot_build) +importFrom(ggplot2,theme_bw) importFrom(grDevices,colorRampPalette) importFrom(graphics,axis) importFrom(graphics,legend) @@ -24,12 +36,19 @@ importFrom(lifecycle,deprecate_warn) importFrom(magrittr,"%>%") importFrom(magrittr,equals) importFrom(magrittr,set_rownames) +importFrom(plotly,event_data) +importFrom(plotly,ggplotly) +importFrom(plotly,plotlyOutput) +importFrom(plotly,renderPlotly) importFrom(purrr,imap) importFrom(purrr,map) +importFrom(purrr,map_lgl) +importFrom(purrr,pluck) importFrom(purrr,reduce) importFrom(purrr,when) importFrom(rlang,":=") importFrom(rlang,enquo) +importFrom(rlang,env) importFrom(rlang,quo_is_null) importFrom(rlang,quo_is_symbol) importFrom(rlang,quo_is_symbolic) @@ -37,6 +56,14 @@ importFrom(rlang,quo_name) importFrom(rlang,quo_squash) importFrom(scales,alpha) importFrom(scales,rescale) +importFrom(shiny,actionButton) +importFrom(shiny,fluidPage) +importFrom(shiny,observe) +importFrom(shiny,runApp) +importFrom(shiny,shinyApp) +importFrom(shiny,stopApp) importFrom(stringr,str_pad) +importFrom(tibble,as_tibble) +importFrom(tibble,tibble) importFrom(utils,head) importFrom(viridis,viridis) diff --git a/R/functions_OLD.R b/R/functions_OLD.R index b3970c6..8bd7ba4 100644 --- a/R/functions_OLD.R +++ b/R/functions_OLD.R @@ -356,7 +356,8 @@ gate_programmatic <- .dim1, .dim2, gate_list, - name = "gate") { + name = "gate", + ...) { # Comply with CRAN NOTES . = NULL diff --git a/R/functions_chr_int.R b/R/functions_chr_int.R index 4c8942b..ccf515f 100644 --- a/R/functions_chr_int.R +++ b/R/functions_chr_int.R @@ -265,7 +265,6 @@ pretty_plot_chr_int = function(.data, #' @param .size A column symbol. Size of points #' @param opacity A number between 0 and 1. The opacity level of the data points #' @param how_many_gates An integer. The number of gates to label -#' @param gate_list A list of gates. It is returned by gate function as attribute \"gate\". If you want to create this list yourself, each element of the list is a data frame with x and y columns. Each row is a coordinate. The order matter. #' @param ... Further parameters passed to the function gatepoints::fhs #' #' @return A tibble with additional columns @@ -379,7 +378,8 @@ gate_programmatic_chr_int <- function(.data, .dim1, .dim2, - gate_list + gate_list, + ... ) { # Comply with CRAN NOTES . = NULL @@ -456,12 +456,14 @@ gate_programmatic_chr_int <- tibble( .dim1 = .dim1, .dim2 = .dim2 - ) %>% - when(!is.null(.color) ~ mutate(., .color = .color), ~ mutate(., .color = NA)) %>% - when(!is.null(.shape) ~ mutate(., .shape = .shape), ~ mutate(., .shape = NA)) %>% - when(!is.null(.size) ~ mutate(., .size = .size), ~ mutate(., .size = NA)) %>% - - when(!is.null(.group_by) ~ mutate(., .group_by = .group_by), ~ (.)) + ) |> + mutate(.color = NA, .shape = NA, .size = NA) + + if(!is.null(.color)) input_df = input_df |> mutate(., .color = !!.color) + if(!is.null(.shape)) input_df = input_df |> mutate(., .shape = !!.shape) + if(!is.null(.size)) input_df = input_df |> mutate(., .size = !!.size) + if(!is.null(.group_by)) input_df = input_df |> mutate(., .group_by = !!.group_by) + unique_df = input_df %>% @@ -472,57 +474,53 @@ gate_programmatic_chr_int <- distinct() - + # Interactive + if(is.null(gate_list)) result_vector = - unique_df %>% - - # Interactive or programmatic - when( - # Interactive - is.null(gate_list) ~ (.) %>% - gate_interactive_chr_int( - .dim1 = .dim1, - .dim2 = .dim2, - .color = .color, - .shape = .shape, - - # size can be number of column - .size = .size, - - opacity = opacity, - how_many_gates = how_many_gates, - is_size_fixed = - class(.size) %in% c("numeric", "integer", "double") & - length(.size) < length(.dim1) & - length(.size) == 1, - ... - ), + unique_df |> + gate_interactive_chr_int( + .dim1 = .dim1, + .dim2 = .dim2, + .color = .color, + .shape = .shape, - # Programmatic - is.list(gate_list) ~ (.) %>% - gate_programmatic_chr_int( - .dim1 = .dim1, - .dim2 = .dim2, - gate_list = gate_list - ), + # size can be number of column + .size = .size, - # Else error - ~ stop( - "tidygate says: the parameter gate_list has to be NULL or a list of data frames" - ) - ) %>% - - # Convert - when(output_type == "chr" ~ as.character(.), - output_type == "int" ~ as.integer(.)) + opacity = opacity, + how_many_gates = how_many_gates, + is_size_fixed = + class(.size) %in% c("numeric", "integer", "double") & + length(.size) < length(.dim1) & + length(.size) == 1, + ... + ) + # Programmatic + else if(is.list(gate_list)) + result_vector = + unique_df |> + gate_programmatic_chr_int( + .dim1 = .dim1, + .dim2 = .dim2, + gate_list = gate_list + ) + + else + stop( + "tidygate says: the parameter gate_list has to be NULL or a list of data frames" + ) + # Convert + if(output_type == "chr") result_vector = result_vector |> as.character() + else if(output_type == "int") result_vector = result_vector |> as.integer() + # Integrate maintaining order in case of nesting input_df %>% left_join( unique_df %>% - mutate(gate = result_vector), - by = c(".dim1", ".dim2") - ) %>% + mutate(gate = result_vector) + ) |> + suppressMessages() |> pull(gate) } \ No newline at end of file diff --git a/R/gate_app.R b/R/gate_app.R new file mode 100644 index 0000000..772310a --- /dev/null +++ b/R/gate_app.R @@ -0,0 +1,87 @@ +#' Create Shiny App UI +#' +#' @importFrom shiny fluidPage +#' @importFrom shiny actionButton +#' @importFrom plotly plotlyOutput +#' @return Fluid UI container +#' @export +ui <- + shiny::fluidPage( + shiny::actionButton("continue_button", "Continue"), + # shiny::actionButton("deselect_button", "Deselect all"), + plotly::plotlyOutput("plot") + ) + +#' Run Shiny App for interactive gating +#' +#' @importFrom plotly renderPlotly +#' @importFrom plotly event_data +#' @importFrom plotly ggplotly +#' @importFrom ggplot2 ggplot +#' @importFrom ggplot2 aes +#' @importFrom ggplot2 geom_point +#' @importFrom ggplot2 theme_bw +#' @importFrom purrr map_lgl +#' @importFrom shiny observe +#' @importFrom shiny stopApp +#' @param input Server input parameter +#' @param output Server output parameter +#' @param session Server session parameter +#' @return NA +#' @export +server <- + function(input, output, session) { + + output$plot <- plotly::renderPlotly({ + + # Fix CRAN NOTES + .key <- NULL + .selected <- NULL + dimension_x <- NULL + dimension_y <- NULL + + # Begin recording selection and brush information + select_data <- plotly::event_data("plotly_selected") + brush_data <- plotly::event_data("plotly_brushed") + + # Save selection and brush information + assign("select_data", tidygate_env$input_data, envir = tidygate_env) + assign("brush_data", brush_data, envir = tidygate_env) + + # Set selected points to TRUE + if (!is.null(select_data)) { + tidygate_env$input_data <- + tidygate_env$input_data |> + mutate(.selected = ifelse(.key %in% as.numeric(select_data$key), TRUE, .selected)) + } + + # Create plot + if (is.null(tidygate_env$custom_plot)) { + plot <- + tidygate_env$input_data |> + ggplot2::ggplot(ggplot2::aes(x = dimension_x, y = dimension_y, colour = .selected, key = .key)) + + ggplot2::geom_point(alpha = tidygate_env$input_data$.alpha[[1]], size = tidygate_env$input_data$.size[[1]]) + + ggplot2::theme_bw() + + # Or load supplied plot + } else { + plot <- + tidygate_env$custom_plot + } + + # Draw plot + plot |> + plotly::ggplotly() |> + plotly::layout(dragmode = "lasso") + }) + + # Close Shiny App with button press + shiny::observe({ + if(input$continue_button > 0){ + shiny::stopApp() + } + # if(input$deselect_button > 0){ + # tidygate_env$input_data$.selected <- FALSE + # } + }) + } diff --git a/R/methods.R b/R/methods.R index 48ad11c..24b03f7 100755 --- a/R/methods.R +++ b/R/methods.R @@ -180,9 +180,124 @@ gate_int.numeric = function( .dim1, } +#' Interactively gate data with a simple scatter plot +#' +#' Launch an interactive scatter plot, based on the input X and Y coordinates. Points on this plot +#' can then be gated. +#' +#' @importFrom tibble tibble +#' @importFrom dplyr mutate +#' @importFrom rlang env +#' @importFrom shiny shinyApp +#' @importFrom shiny runApp +#' @param dimension_x A column symbol representing the X dimension. +#' @param dimension_y A column symbol representing the Y dimension. +#' @param alpha The opacity of points, with 1 being completely opaque and 0 being completely +#' transparent. +#' @param size The size of points. +#' @return A vector with TRUE for elements inside gate points and FALSE for elements outside gate +#' points. A record of the selected points is stored in `tidygate_env$select_data` and a record of +#' the gates is stored in `tidygate_env$brush_data`. +#' @examples +#' \dontrun{ +#' library(dplyr) +#' library(ggplot2) +#' +#' mtcars |> +#' dplyr::mutate(selected = gate_simple(dimension_x = mpg, dimension_y = wt)) |> +#' print() +#'} +#' @export +gate_simple <- + + function(dimension_x, dimension_y, alpha = 1, size = 1) { + + message("tidygate says: this feature is in early development and may undergo changes or contain bugs.") + + # Add needed columns to input data + data <- + tibble::tibble(dimension_x, dimension_y) |> + dplyr::mutate(.key = dplyr::row_number()) |> + dplyr::mutate(.selected = FALSE) |> + dplyr::mutate(.alpha = alpha) |> + dplyr::mutate(.size = size) + + # Create environment and save input variables + tidygate_env <<- rlang::env() + tidygate_env$input_data <- data + tidygate_env$custom_plot <- NULL + + # Launch Shiny App + app <- shiny::shinyApp(ui, server) + shiny::runApp(app, port = 1234) # Specify a port if needed + + return(tidygate_env$input_data$.selected) + } - - - - +#' Interactively gate data with a custom plot +#' +#' Launch an interactive scatter plot, based on a user-defined `ggplot2`. Points on this plot can +#' then be gated. +#' +#' @importFrom tibble as_tibble +#' @importFrom dplyr mutate +#' @importFrom dplyr select +#' @importFrom dplyr rename +#' @importFrom rlang env +#' @importFrom purrr pluck +#' @importFrom ggplot2 ggplot_build +#' @importFrom shiny shinyApp +#' @importFrom shiny runApp +#' @param custom_plot A ggplot object. Must contain a row index in the `.key` column set as key. +#' @return A vector with TRUE for elements inside gate points and FALSE for elements outside gate +#' points. A record of the selected points is stored in `tidygate_env$select_data` and a +#' record of the gates is stored in `tidygate_env$brush_data`. +#' @examples +#' \dontrun{ +#' library(dplyr) +#' library(ggplot2) +#' +#' scaled_plot <- +#' mtcars |> +#' mutate(.key = row_number()) |> +#' ggplot(aes(x = mpg, y = wt, key = .key)) + +#' scale_y_log10() + +#' geom_point() + +#' theme_dark() +#' +#' mtcars |> +#' mutate(selected = gate_custom(custom_plot = scaled_plot)) |> +#' print() +#' } +#' @export +gate_custom <- + + function(custom_plot) { + + message("tidygate says: this feature is in early development and may undergo changes or contain bugs.") + + # Fix CRAN NOTES + key <- NULL + + # Create tibble with .key column + data <- + custom_plot |> + ggplot2::ggplot_build() |> + purrr::pluck(1, 1) |> + tibble::as_tibble() |> + dplyr::select(key) |> + dplyr::rename(.key = "key") |> + dplyr::mutate(.selected = FALSE) + + # Create environment and save input variables + tidygate_env <<- rlang::env() + tidygate_env$input_data <- data + tidygate_env$custom_plot <- custom_plot + + # Launch Shiny App + app <- shiny::shinyApp(ui, server) + shiny::runApp(app, port = 1234) + + return(tidygate_env$input_data$.selected) + } diff --git a/man/figures/lifecycle-archived.svg b/man/figures/lifecycle-archived.svg deleted file mode 100644 index 48f72a6..0000000 --- a/man/figures/lifecycle-archived.svg +++ /dev/null @@ -1 +0,0 @@ - lifecyclelifecyclearchivedarchived \ No newline at end of file diff --git a/man/figures/lifecycle-defunct.svg b/man/figures/lifecycle-defunct.svg deleted file mode 100644 index 01452e5..0000000 --- a/man/figures/lifecycle-defunct.svg +++ /dev/null @@ -1 +0,0 @@ -lifecyclelifecycledefunctdefunct \ No newline at end of file diff --git a/man/figures/lifecycle-deprecated.svg b/man/figures/lifecycle-deprecated.svg deleted file mode 100644 index 4baaee0..0000000 --- a/man/figures/lifecycle-deprecated.svg +++ /dev/null @@ -1 +0,0 @@ -lifecyclelifecycledeprecateddeprecated \ No newline at end of file diff --git a/man/figures/lifecycle-experimental.svg b/man/figures/lifecycle-experimental.svg deleted file mode 100644 index d1d060e..0000000 --- a/man/figures/lifecycle-experimental.svg +++ /dev/null @@ -1 +0,0 @@ -lifecyclelifecycleexperimentalexperimental \ No newline at end of file diff --git a/man/figures/lifecycle-maturing.svg b/man/figures/lifecycle-maturing.svg deleted file mode 100644 index df71310..0000000 --- a/man/figures/lifecycle-maturing.svg +++ /dev/null @@ -1 +0,0 @@ -lifecyclelifecyclematuringmaturing \ No newline at end of file diff --git a/man/figures/lifecycle-questioning.svg b/man/figures/lifecycle-questioning.svg deleted file mode 100644 index 08ee0c9..0000000 --- a/man/figures/lifecycle-questioning.svg +++ /dev/null @@ -1 +0,0 @@ -lifecyclelifecyclequestioningquestioning \ No newline at end of file diff --git a/man/figures/lifecycle-soft-deprecated.svg b/man/figures/lifecycle-soft-deprecated.svg deleted file mode 100644 index 9f014fd..0000000 --- a/man/figures/lifecycle-soft-deprecated.svg +++ /dev/null @@ -1 +0,0 @@ -lifecyclelifecyclesoft-deprecatedsoft-deprecated \ No newline at end of file diff --git a/man/figures/lifecycle-stable.svg b/man/figures/lifecycle-stable.svg deleted file mode 100644 index e015dc8..0000000 --- a/man/figures/lifecycle-stable.svg +++ /dev/null @@ -1 +0,0 @@ -lifecyclelifecyclestablestable \ No newline at end of file diff --git a/man/figures/lifecycle-superseded.svg b/man/figures/lifecycle-superseded.svg deleted file mode 100644 index 75f24f5..0000000 --- a/man/figures/lifecycle-superseded.svg +++ /dev/null @@ -1 +0,0 @@ - lifecyclelifecyclesupersededsuperseded \ No newline at end of file diff --git a/man/gate-methods.Rd b/man/gate-methods.Rd old mode 100755 new mode 100644 diff --git a/man/gate_custom.Rd b/man/gate_custom.Rd new file mode 100644 index 0000000..b97d7f9 --- /dev/null +++ b/man/gate_custom.Rd @@ -0,0 +1,38 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/methods.R +\name{gate_custom} +\alias{gate_custom} +\title{Interactively gate data with a custom plot} +\usage{ +gate_custom(custom_plot) +} +\arguments{ +\item{custom_plot}{A ggplot object. Must contain a row index in the `.key` column set as key.} +} +\value{ +A vector with TRUE for elements inside gate points and FALSE for elements outside gate +points. A record of the selected points is stored in `tidygate_env$select_data` and a +record of the gates is stored in `tidygate_env$brush_data`. +} +\description{ +Launch an interactive scatter plot, based on a user-defined `ggplot2`. Points on this plot can +then be gated. +} +\examples{ +\dontrun{ +library(dplyr) +library(ggplot2) + +scaled_plot <- + mtcars |> + mutate(.key = row_number()) |> + ggplot(aes(x = mpg, y = wt, key = .key)) + + scale_y_log10() + + geom_point() + + theme_dark() + +mtcars |> + mutate(selected = gate_custom(custom_plot = scaled_plot)) |> + print() +} +} diff --git a/man/gate_interactive_chr_int.Rd b/man/gate_interactive_chr_int.Rd index 23c828e..930f4a4 100644 --- a/man/gate_interactive_chr_int.Rd +++ b/man/gate_interactive_chr_int.Rd @@ -35,8 +35,6 @@ gate_interactive_chr_int( \item{how_many_gates}{An integer. The number of gates to label} \item{...}{Further parameters passed to the function gatepoints::fhs} - -\item{gate_list}{A list of gates. It is returned by gate function as attribute \"gate\". If you want to create this list yourself, each element of the list is a data frame with x and y columns. Each row is a coordinate. The order matter.} } \value{ A tibble with additional columns diff --git a/man/gate_programmatic.Rd b/man/gate_programmatic.Rd index 59999f4..5afaf56 100644 --- a/man/gate_programmatic.Rd +++ b/man/gate_programmatic.Rd @@ -4,7 +4,7 @@ \alias{gate_programmatic} \title{Get points within a user drawn gate} \usage{ -gate_programmatic(.data, .element, .dim1, .dim2, gate_list, name = "gate") +gate_programmatic(.data, .element, .dim1, .dim2, gate_list, name = "gate", ...) } \arguments{ \item{.data}{A tibble} diff --git a/man/gate_programmatic_chr_int.Rd b/man/gate_programmatic_chr_int.Rd index 91537de..f2a808d 100644 --- a/man/gate_programmatic_chr_int.Rd +++ b/man/gate_programmatic_chr_int.Rd @@ -4,7 +4,7 @@ \alias{gate_programmatic_chr_int} \title{Get points within a user drawn gate} \usage{ -gate_programmatic_chr_int(.data, .dim1, .dim2, gate_list) +gate_programmatic_chr_int(.data, .dim1, .dim2, gate_list, ...) } \arguments{ \item{.data}{A tibble} diff --git a/man/gate_simple.Rd b/man/gate_simple.Rd new file mode 100644 index 0000000..b96d11f --- /dev/null +++ b/man/gate_simple.Rd @@ -0,0 +1,37 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/methods.R +\name{gate_simple} +\alias{gate_simple} +\title{Interactively gate data with a simple scatter plot} +\usage{ +gate_simple(dimension_x, dimension_y, alpha = 1, size = 1) +} +\arguments{ +\item{dimension_x}{A column symbol representing the X dimension.} + +\item{dimension_y}{A column symbol representing the Y dimension.} + +\item{alpha}{The opacity of points, with 1 being completely opaque and 0 being completely +transparent.} + +\item{size}{The size of points.} +} +\value{ +A vector with TRUE for elements inside gate points and FALSE for elements outside gate +points. A record of the selected points is stored in `tidygate_env$select_data` and a record of +the gates is stored in `tidygate_env$brush_data`. +} +\description{ +Launch an interactive scatter plot, based on the input X and Y coordinates. Points on this plot +can then be gated. +} +\examples{ +\dontrun{ +library(dplyr) +library(ggplot2) + +mtcars |> + dplyr::mutate(selected = gate_simple(dimension_x = mpg, dimension_y = wt)) |> + print() +} +} diff --git a/man/server.Rd b/man/server.Rd new file mode 100644 index 0000000..4136b6a --- /dev/null +++ b/man/server.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/gate_app.R +\name{server} +\alias{server} +\title{Run Shiny App for interactive gating} +\usage{ +server(input, output, session) +} +\arguments{ +\item{input}{Server input parameter} + +\item{output}{Server output parameter} + +\item{session}{Server session parameter} +} +\value{ +NA +} +\description{ +Run Shiny App for interactive gating +} diff --git a/man/ui.Rd b/man/ui.Rd new file mode 100644 index 0000000..297cc28 --- /dev/null +++ b/man/ui.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/gate_app.R +\docType{data} +\name{ui} +\alias{ui} +\title{Create Shiny App UI} +\format{ +An object of class \code{shiny.tag.list} (inherits from \code{list}) of length 4. +} +\usage{ +ui +} +\value{ +Fluid UI container +} +\description{ +Create Shiny App UI +} +\keyword{datasets} diff --git a/vignettes/introdution.Rmd b/vignettes/introdution.Rmd index 062ea49..fb7f521 100755 --- a/vignettes/introdution.Rmd +++ b/vignettes/introdution.Rmd @@ -1,6 +1,6 @@ --- title: "tidygate: high-level data analysis and manipulation in tidyverse style" -output: github_documentdate: "`r Sys.Date()`" +date: "`r Sys.Date()`" package: tidygate output: BiocStyle::html_document: