ggGate is a one-function-package that enables point-and-click gating on a ggplot2 object through shiny
You can install ggGate from GitHub with:
# install.packages("devtools")
devtools::install_github("northNomad/ggGate")
suppressMessages(library(ggGate))
#> Warning: package 'shiny' was built under R version 4.1.2
#create ggplot2 object
p <- ggplot(iris, aes(Sepal.Length, Sepal.Width)) + geom_point()
ggGate(p, write_data_to = "df_new", write_gate_to = "df_gate")
Name the current gate using the Name of gate text box
Single-click on plot to create and draw gate
Double-click on plot to finish gate
Click on action buttons to save gate coordinates and annotated data
New columns corresponding to each gate are added to the data.frame underlying the ggplot2 object.
The new columns store boolean values indicating if the data points (rows) fall inside the respective gates.
colnames(iris)
#> [1] "Sepal.Length" "Sepal.Width" "Petal.Length" "Petal.Width" "Species"
colnames(df_new)
#> [1] "Sepal.Length" "Sepal.Width" "Petal.Length" "Petal.Width" "Species"
#> [6] "Group A" "Group B" "Group C" "Group D"
dplyr::select(df_new, starts_with("Group")) %>% colSums()
#> Group A Group B Group C Group D
#> 6 5 0 8
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.