Skip to content

Commit

Permalink
Prepare for CRAN v0.1.9 release
Browse files Browse the repository at this point in the history
* Now `rlang` is in Depends.
  * Output for `gating()` now includes a diagnostic message saved as a character string for reference in a slot called `note`.
  * A diagnostic message can be viewed running `rlang::last_error()$out$note` after the unsuccessful run of `gating()`.
  * Removed redundant `@importFrom fields image.plot` in 'package.R'
  • Loading branch information
Ian Buller, PhD, MA committed Jun 20, 2021
1 parent b464ff0 commit db51213
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 63 deletions.
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: gateR
Type: Package
Title: Flow/Mass Cytometry Gating via Spatial Kernel Density Estimation
Version: 0.1.8
Date: 2021-03-14
Version: 0.1.9
Date: 2021-06-20
Authors@R:
c(person(given = "Ian D.",
family = "Buller",
Expand Down Expand Up @@ -54,6 +54,7 @@ Imports:
grDevices,
lifecycle,
raster,
rlang,
sparr,
SpatialPack,
stats,
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ importFrom(raster,cut)
importFrom(raster,extent)
importFrom(raster,raster)
importFrom(raster,values)
importFrom(rlang,abort)
importFrom(rlang,inform)
importFrom(sparr,OS)
importFrom(sparr,risk)
importFrom(spatstat.geom,as.im)
Expand Down
8 changes: 7 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# gateR (development version)

# gateR v0.1.9
* Now `rlang` is in Depends.
* Output for `gating()` now includes a diagnostic message saved as a character string for reference in a slot called `note`.
* A diagnostic message can be viewed running `rlang::last_error()$out$note` after the unsuccessful run of `gating()`.
* Removed redundant `@importFrom fields image.plot` in 'package.R'

# gateR v0.1.8
* Updated `spatstat` package to new subsetted packages based on feedback from the Spatstat Team (Adrian Baddeley and Ege Rubak). Now `spatstat.geom`, `spatstat.core`, `spatstat.linnet`, and `spatstat (>= 2.0-0)` are in Depends
* Fixed check for `vars` in `dat` within the `gating()` function
Expand All @@ -15,7 +21,7 @@
* Updated links in 'gateR-package.Rd' for package updates

# gateR v0.1.6
* Updated URLs in gateR-package.Rd
* Updated URLs in 'gateR-package.Rd'
* Updated year in DESCRIPTION

# gateR v0.1.5
Expand Down
109 changes: 60 additions & 49 deletions R/gating.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@
#'
#' \describe{
#' \item{\code{obs}}{An object of class 'tibble' of the same features as \code{dat} that includes the information for the cells extracted with significant clusters in the final gate.}
#' \item{\code{n}}{An object of class 'list' of the sample size of cells at each gate. The length is equal to the number of successful gates plus the final result.}
#' \item{\code{n}}{An object of class 'list' of the sample size of cells at each gate. The length is equal to the number of successful gates plus the final result.}
#' \item{\code{gate}}{An object of class 'list' of 'rrs' objects from each gate. The length is equal to the number of successful gates.}
#' \item{\code{note}}{An object of class 'character' of the gating diagnostic message.}
#' }
#'
#' The objects of class 'rrs' is similar to the output of the \code{\link[sparr]{risk}} function with two additional components:
Expand All @@ -54,6 +55,7 @@
#'
#' @importFrom grDevices chull
#' @importFrom lifecycle badge deprecate_warn deprecated is_present
#' @importFrom rlang abort inform
#' @importFrom spatstat.geom cut.im marks owin ppp
#' @importFrom tibble add_column
#' @export
Expand Down Expand Up @@ -183,44 +185,44 @@ gating <- function(dat,

# Estimate significant relative risk areas
## Bonferroni correction only necessary in first gate
if (k == 1) { p_correct <- p_correct } else { p_correct <- "none"}
if (k == 1) { p_correct <- p_correct } else { p_correct <- "none" }

n_out[[k]] <- nrow(df)
name_gate <- paste("gate", k, sep = "_")

if (n_condition == 2) {
out <- lotrrs(dat = df,
bandw = bandw,
win = win_gate,
plot_gate = plot_gate,
save_gate = save_gate,
name_gate = name_gate,
path_gate = path_gate,
alpha = alpha,
p_correct = p_correct,
nbc = nbc,
rcols = rcols,
lower_lrr = lower_lrr,
upper_lrr = upper_lrr,
c1n = c1n,
c2n = c2n,
...)
out <- lotrrs(dat = df,
bandw = bandw,
win = win_gate,
plot_gate = plot_gate,
save_gate = save_gate,
name_gate = name_gate,
path_gate = path_gate,
alpha = alpha,
p_correct = p_correct,
nbc = nbc,
rcols = rcols,
lower_lrr = lower_lrr,
upper_lrr = upper_lrr,
c1n = c1n,
c2n = c2n,
...)
} else {
out <- rrs(dat = df,
bandw = bandw,
win = win_gate,
plot_gate = plot_gate,
save_gate = save_gate,
name_gate = name_gate,
path_gate = path_gate,
alpha = alpha,
p_correct = p_correct,
nbc = nbc,
rcols = rcols,
lower_lrr = lower_lrr,
upper_lrr = upper_lrr,
c1n = c1n,
...)
out <- rrs(dat = df,
bandw = bandw,
win = win_gate,
plot_gate = plot_gate,
save_gate = save_gate,
name_gate = name_gate,
path_gate = path_gate,
alpha = alpha,
p_correct = p_correct,
nbc = nbc,
rcols = rcols,
lower_lrr = lower_lrr,
upper_lrr = upper_lrr,
c1n = c1n,
...)
}

# Convert p-value surface into a categorized 'im'
Expand All @@ -232,29 +234,37 @@ gating <- function(dat,
# Go back one gate if current gate has no significant area and produce output of previous gate
if (all(Ps$v == "2", na.rm = TRUE) | all(is.na(Ps$v))) {
if (k > 1) {
message(paste("Gate", k, "yielded no significant", type_cluster, "cluster(s)...",
"Returning results from Gate", k-1,
sep = " "))
output <- dat[which(dat[ , 1] %in% dat_gate[ , 1]), ]
out_list <- list("obs" = output, "n" = n_out, "gate" = list_gate)
return(out_list)
mess <- paste("Gate", k, "yielded no significant", type_cluster, "cluster(s)...",
"Returning results from Gate", k-1,
sep = " ")
rlang::inform(mess, mess = mess)
output <- dat[which(dat[ , 1] %in% dat_gate[ , 1]), ]
out_list <- list("obs" = output, "n" = n_out, "gate" = list_gate, "note" = mess)
return(out_list)
} else {
stop(paste("Gate 1 yielded no significant clustering... Returning no results", sep = " "))
mess <- paste("Gate 1 yielded no significant clustering... Returning no results", sep = " ")
out_list <- list("obs" = NULL, "n" = NULL, "gate" = list_gate, "note" = mess)
rlang::abort(mess, out = out_list)
return(out)
}
}

if (numerator == TRUE) { v <- "1" } else { v <- "3" }

if (!any(Ps$v == v, na.rm = TRUE)) {
if (k > 1) {
message(paste("Gate", k, "yielded no significant", type_cluster, "cluster(s)...",
"Returning results from Gate", k-1,
sep = " "))
output <- dat[which(dat[ , 1] %in% dat_gate[ , 1]), ]
out_list <- list("obs" = output, "n" = n_out, "gate" = list_gate)
return(out_list)
mess <- paste("Gate", k, "yielded no significant", type_cluster, "cluster(s)...",
"Returning results from Gate", k-1,
sep = " ")
rlang::inform(mess, mess = mess)
output <- dat[which(dat[ , 1] %in% dat_gate[ , 1]), ]
out_list <- list("obs" = output, "n" = n_out, "gate" = list_gate, "note" = mess)
return(out_list)
} else {
stop(paste("Gate 1 yielded no significant", type_cluster, "cluster(s)... Returning no results", sep = " "))
mess <- paste("Gate 1 yielded no significant", type_cluster, "cluster(s)... Returning no results", sep = " ")
out_list <- list("obs" = NULL, "n" = NULL, "gate" = list_gate, "note" = mess)
rlang::abort(mess, out = out_list)
return(out)
}
}

Expand All @@ -270,10 +280,11 @@ gating <- function(dat,

# Output for the final gate
if (k == n_gate) {
message(paste("Observations within significant", type_cluster, "cluster(s) of Gate", k, sep = " "))
mess <- paste("Observations within significant", type_cluster, "cluster(s) of Gate", k, sep = " ")
rlang::inform(mess, mess = mess)
output <- dat[which(dat[ , 1] %in% dat_gate[ , 1]), ]
n_out[[k + 1]] <- nrow(output)
out_list <- list("obs" = output, "n" = n_out, "gate" = list_gate)
out_list <- list("obs" = output, "n" = n_out, "gate" = list_gate, "note" = mess)
return(out_list)
}
}
Expand Down
2 changes: 1 addition & 1 deletion R/package.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ NULL
#' @importFrom grDevices chull colorRampPalette dev.off png
#' @importFrom lifecycle badge deprecate_warn deprecated is_present
#' @importFrom raster cut extent raster values
#' @importFrom rlang abort inform
#' @importFrom sparr OS risk
#' @importFrom SpatialPack modified.ttest
#' @importFrom stats na.omit pnorm relevel
#' @importFrom tibble add_column
#' @importFrom fields image.plot
#' @import spatstat.geom
#' @import spatstat.core
#' @import spatstat.linnet
Expand Down
10 changes: 6 additions & 4 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
## This is the eighth resubmission
## This is the nineth resubmission

* Updates since previous submission:
* Updated `spatstat` package to new subsetted packages based on feedback from the Spatstat Team (Adrian Baddeley and Ege Rubak). Now `spatstat.geom`, `spatstat.core`, `spatstat.linnet`, and `spatstat (>= 2.0-0)` are in Depends
* Fixed check for `vars` in `dat` within the `gating()` function
* Now `rlang` is in Depends.
* Output for `gating()` now includes a diagnostic message saved as a character string for reference in a slot called `note`.
* A diagnostic message can be viewed running `rlang::last_error()$out$note` after the unsuccessful run of `gating()`.
* Removed redundant `@importFrom fields image.plot` in 'package.R'

* Documentation for `pval_correct()` references a doi <https://doi.org/10.2307/2283989> that throws a NOTE in win-builder but no other environment
* Documentation for `pval_correct()` references doi <https://doi.org/10.2307/2283989> and <https://doi.org/10.1214/aop/1176996176> that throw NOTES in win-builder, Fedora Linux, and Ubuntu Linux but these are valid URLs

## Test environments
* local OS X install, R 4.0.4
Expand Down
5 changes: 3 additions & 2 deletions man/gating.Rd

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

4 changes: 2 additions & 2 deletions man/lotrrs.Rd

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

4 changes: 2 additions & 2 deletions man/rrs.Rd

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

0 comments on commit db51213

Please sign in to comment.