Skip to content

Commit

Permalink
Revert "Enhancements to Subsampling Feature in tidygate"
Browse files Browse the repository at this point in the history
  • Loading branch information
stemangiola authored Nov 27, 2023
1 parent c93b37f commit f03f226
Show file tree
Hide file tree
Showing 9 changed files with 3 additions and 73 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Depends:
R (>= 3.6.0)
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.2.3
RoxygenNote: 7.1.1
Imports:
utils,
graphics,
Expand Down
22 changes: 2 additions & 20 deletions R/functions_chr_int.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ pretty_plot_chr_int = function(.data,
.color = NULL,
.shape = NULL,
.size = NULL,
subsample = NULL,
opacity = 1,
is_size_fixed) {
# Comply with CRAN NOTES
Expand All @@ -59,19 +58,8 @@ pretty_plot_chr_int = function(.data,
.shape = enquo(.shape)
.size = enquo(.size)
my_size_range = c(1, 3)

if (!is.null(subsample)) {
if (subsample > 0 && subsample < 1) {
# Subsample as a fraction
set.seed(123) # Set seed for reproducibility
.data <- .data %>% sample_frac(subsample)
} else if (subsample >= 1) {
# Subsample as a fixed number
set.seed(123) # Set seed for reproducibility
.data <- .data %>% sample_n(subsample)
}
}




.data_formatted =
.data %>%
Expand Down Expand Up @@ -275,7 +263,6 @@ pretty_plot_chr_int = function(.data,
#' @param .color A column symbol. Color of points
#' @param .shape A column symbol. Shape of points
#' @param .size A column symbol. Size of points
#' @param subsample A numeric value or a fraction indicating the subset of data to sample.
#' @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.
Expand All @@ -290,7 +277,6 @@ gate_interactive_chr_int <-
.color = NA,
.shape = NULL,
.size = NULL,
subsample = NULL,
opacity = 1,
how_many_gates = 1,
is_size_fixed,
Expand Down Expand Up @@ -350,8 +336,6 @@ gate_interactive_chr_int <-
# size can be number or column
.size = !!.size,

subsample = subsample,

opacity = opacity,
is_size_fixed = is_size_fixed
)
Expand Down Expand Up @@ -443,7 +427,6 @@ gate_programmatic_chr_int <-
.color = NULL,
.shape = NULL,
.size = NULL,
subsample = NULL,
opacity = 1,
how_many_gates = 1,
.group_by = NULL,
Expand Down Expand Up @@ -501,7 +484,6 @@ gate_programmatic_chr_int <-
.color = .color,
.shape = .shape,

subsample =subsample,
# size can be number of column
.size = .size,

Expand Down
7 changes: 0 additions & 7 deletions R/methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#' @param .color A column symbol. Colour of points
#' @param .shape A column symbol. Shape of points
#' @param .size A column symbol. Size of points
#' @param subsample A numeric value or a fraction indicating the subset of data to sample.
#' @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 .group_by A column symbol. The column that is used to calculate distance (i.e., normally genes)
Expand Down Expand Up @@ -74,7 +73,6 @@ gate_chr <- function(.dim1,
.color = NULL,
.shape = NULL,
.size = NULL,
subsample = NULL,
opacity = 1,
how_many_gates = 1,
.group_by = NULL,
Expand All @@ -97,7 +95,6 @@ gate_chr.numeric = function( .dim1,
.color = NULL,
.shape = NULL,
.size = NULL,
subsample = NULL,
opacity = 1,
how_many_gates = 1,
.group_by = NULL,
Expand All @@ -112,7 +109,6 @@ gate_chr.numeric = function( .dim1,
.color = .color,
.shape = .shape,
.size = .size,
subsample = subsample,
opacity = opacity,
how_many_gates = how_many_gates,
.group_by = .group_by,
Expand Down Expand Up @@ -140,7 +136,6 @@ gate_int <- function(.dim1,
.color = NULL,
.shape = NULL,
.size = NULL,
subsample = NULL,
opacity = 1,
how_many_gates = 1,
.group_by = NULL,
Expand All @@ -162,7 +157,6 @@ gate_int.numeric = function( .dim1,
.color = NULL,
.shape = NULL,
.size = NULL,
subsample = NULL,
opacity = 1,
how_many_gates = 1,
.group_by = NULL,
Expand All @@ -176,7 +170,6 @@ gate_int.numeric = function( .dim1,
.color = .color,
.shape = .shape,
.size = .size,
subsample = subsample,
opacity = opacity,
how_many_gates = how_many_gates,
.group_by = .group_by,
Expand Down
11 changes: 0 additions & 11 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,4 @@ tidygate_data %>%
```

## Subsampling

The `subsample` parameter allows you to sample a subset of your data for analysis with a fixed seed. This can be particularly useful for large datasets or for preliminary exploratory analysis. Here's how you can use it:

```{r}
# For sampling 50% of your data
result <- your_function(data, subsample = 0.5)
# For sampling 100 specific observations
result <- your_function(data, subsample = 100)
```
21 changes: 0 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,24 +131,3 @@ tidygate_data %>%
## 9 adrenal 1 fibrobla… immune_c… 0.52 ACC -0.776 -0.383 0
## 10 adrenal 1 immune_c… endothel… 1 ACC 0.980 -0.116 0
## # … with 2,230 more rows

## Subsampling

The `subsample` parameter allows you to sample a subset of your data for analysis with a fixed seed. This can be particularly useful for large datasets or for preliminary exploratory analysis. Here's how you can use it:

```r
# For sampling 50% of your data
tidygate_data %>%
mutate( gate = gate_chr(
Dim1, Dim2, subsample = 0.5
))


# For sampling 100 specific observations
tidygate_data %>%
mutate( gate = gate_chr(
Dim1, Dim2, subsample = 100
))


```
4 changes: 0 additions & 4 deletions man/gate_chr-methods.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions man/gate_chr.numeric.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions man/gate_int.numeric.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions man/gate_interactive_chr_int.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f03f226

Please sign in to comment.