Skip to content

Commit

Permalink
Prepare v0.1.3 for CRAN
Browse files Browse the repository at this point in the history
* Actions taken regarding feedback from Prof. Brian Ripley:
  * Removed 'ncdFlow', 'flowWorkspaceData', and 'knitr' from Suggests
  * Created a random data set 'randCyto' and all documentation
  * Updated examples and testthat to use 'randCyto' data
  * Updated vignette with clearer language
  • Loading branch information
Ian Buller, PhD, MA committed Nov 17, 2020
1 parent 12fe622 commit 1056690
Show file tree
Hide file tree
Showing 23 changed files with 298 additions and 479 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
^vignette\.Rmd$
^dev$
^CRAN-RELEASE$
^data-raw$
13 changes: 5 additions & 8 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.3.9000
Date: 2020-11-10
Version: 0.1.3
Date: 2020-11-16
Authors@R:
c(person(given = "Ian D.",
family = "Buller",
Expand All @@ -27,10 +27,10 @@ Authors@R:
person(given = "NCI",
role = "cph"))
Maintainer: Ian D. Buller <[email protected]>
Description: Estimates statistically significant fluorescent marker combination values within
Description: Estimates statistically significant marker combination values within
which one immunologically distinctive group (i.e., disease case) is more associated than
another group (i.e., healthy control), successively, using various combinations (i.e.,
"gates") of fluorescent markers to examine features of cells that may be different between
"gates") of markers to examine features of cells that may be different between
groups. For a two-group comparison, the 'gateR' package uses the spatial relative risk
function that is estimated using the 'sparr' package. Details about the 'sparr' package
methods can be found in the tutorial: Davies et al. (2018) <doi:10.1002/sim.7577>. Details
Expand All @@ -56,10 +56,7 @@ Imports:
stats,
tibble,
utils
Suggests:
flowWorkspaceData,
knitr,
ncdfFlow,
Suggests:
R.rsp,
spelling,
testthat
Expand Down
8 changes: 5 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# gateR (development version)

# gateR v0.1.3.9000

*
# gateR v0.1.3
* Removed 'ncdFlow', 'flowWorkspaceData', and 'knitr' from Suggests
* Created a random data set 'randCyto' and all documentation
* Updated examples and testthat to use 'randCyto' data
* Updated vignette with clearer language
41 changes: 4 additions & 37 deletions R/gating.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,46 +56,13 @@
#'
#' @examples
#' if (interactive()) {
#' # Use 'extdata' from the {flowWorkspaceData} package
#' flowDataPath <- system.file("extdata", package = "flowWorkspaceData")
#' fcsFiles <- list.files(pattern = "CytoTrol", flowDataPath, full = TRUE)
#' ncfs <- ncdfFlow::read.ncdfFlowSet(fcsFiles)
#' fr1 <- ncfs[[1]]
#' fr2 <- ncfs[[2]]
#'
#' # Comparison of two samples (single condition) "g1"
#' ## Two gates (four markers) "CD4", "CD38", "CD8", and "CD3"
#' ## Log10 Transformation for both markers
#' ## Remove cells with NA and Inf values
#'
#' # First sample
#' obs_dat1 <- data.frame("id" = seq(1, nrow(fr1@exprs), 1),
#' "g1" = rep(1, nrow(fr1@exprs)),
#' "log10_CD4" = log(fr1@exprs[ , 5], 10),
#' "log10_CD38" = log(fr1@exprs[ , 6], 10),
#' "log10_CD8" = log(fr1@exprs[ , 7], 10),
#' "log10_CD3" = log(fr1@exprs[ , 8], 10))
#' # Second sample
#' obs_dat2 <- data.frame("id" = seq(1, nrow(fr2@exprs), 1),
#' "g1" = rep(2, nrow(fr2@exprs)),
#' "log10_CD4" = log(fr2@exprs[ , 5], 10),
#' "log10_CD38" = log(fr2@exprs[ , 6], 10),
#' "log10_CD8" = log(fr2@exprs[ , 7], 10),
#' "log10_CD3" = log(fr2@exprs[ , 8], 10))
#' # Full set
#' obs_dat <- rbind(obs_dat1, obs_dat2)
#' obs_dat <- obs_dat[complete.cases(obs_dat), ] # remove NAs
#' obs_dat <- obs_dat[is.finite(rowSums(obs_dat)), ] # remove Infs
#' obs_dat$g1 <- as.factor(obs_dat$g1) # set "g1" as binary factor
#'
#' # Run gating() function
#' ## Single condition, no multiple testing correction
#' test_gate <- gateR::gating(dat = obs_dat,
#' vars = c("log10_CD4", "log10_CD38",
#' "log10_CD8", "log10_CD3"),
#' test_gate <- gateR::gating(dat = randCyto,
#' vars = c("arcsinh_CD4", "arcsinh_CD38",
#' "arcsinh_CD8", "arcsinh_CD3"),
#' n_condition = 1,
#' p_correct = "none")
#' }
#' }
#'
gating <- function(dat,
vars,
Expand Down
37 changes: 1 addition & 36 deletions R/lotrrs.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,42 +44,7 @@
#' @export
#'
#' @examples
#' if (interactive()) {
#' # Use 'extdata' from the {flowWorkspaceData} package
#' flowDataPath <- system.file("extdata", package = "flowWorkspaceData")
#' fcsFiles <- list.files(pattern = "CytoTrol", flowDataPath, full = TRUE)
#' ncfs <- ncdfFlow::read.ncdfFlowSet(fcsFiles)
#' fr1 <- ncfs[[1]]
#' fr2 <- ncfs[[2]]
#'
#' # Comparison of two samples at two time points (two conditions) "g1" and "g2"
#' ## (Create a random binary variable for "g2")
#' ## One gate (two markers) "CD4", "CD38"
#' ## Log10 Transformation for both markers
#' ## Remove cells with NA and Inf values
#'
#' # First sample
#' obs_dat1 <- data.frame("id" = seq(1, nrow(fr1@exprs), 1),
#' "g1" = rep(1, nrow(fr1@exprs)),
#' "g2" = stats::rbinom(nrow(fr1@exprs), 1, 0.5),
#' "log10_CD4" = log(fr1@exprs[ , 5], 10),
#' "log10_CD38" = log(fr1@exprs[ , 6], 10))
#' # Second sample
#' obs_dat2 <- data.frame("id" = seq(1, nrow(fr2@exprs), 1),
#' "g1" = rep(2, nrow(fr2@exprs)),
#' "g2" = stats::rbinom(nrow(fr2@exprs), 1, 0.5),
#' "log10_CD4" = log(fr2@exprs[ , 5], 10),
#' "log10_CD38" = log(fr2@exprs[ , 6], 10))
#' # Full set
#' obs_dat <- rbind(obs_dat1, obs_dat2)
#' obs_dat <- obs_dat[complete.cases(obs_dat), ] # remove NAs
#' obs_dat <- obs_dat[is.finite(rowSums(obs_dat)), ] # remove Infs
#' obs_dat$g1 <- as.factor(obs_dat$g1) # set "g1" as binary factor
#' obs_dat$g2 <- as.factor(obs_dat$g2) # set "g2" as binary factor
#'
#' # Run lotrrs() function
#' test_lotrrs <- lotrrs(dat = obs_dat, p_correct = "none")
#' }
#' test_lotrrs <- lotrrs(dat = randCyto)
#'
lotrrs <- function(dat,
alpha = 0.05,
Expand Down
4 changes: 4 additions & 0 deletions R/package.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
#'
#' \code{\link{lotrrs}} Estimates a ratio of relative risk surfaces and computes the asymptotic p-value surface for a single gate with two conditions. Includes features for basic visualization. This function is used internally within the \code{\link{gating}} function to extract the points within the significant areas. This function can also be used as a standalone function.
#'
#' \bold{Flow Cytometry Data}
#'
#' \code{\link{randCyto}} A sample dataset containing information about flow cytometry data with two binary categorical variables. The data are a random subset of the 'extdata' data in the 'flowWorkspaceData' package found on Bioconductor \url{http://bioconductor.org/packages/release/data/experiment/html/flowWorkspaceData.html} and formated for gateR input.
#'
#' @name gateR-package
#' @aliases gateR-package gateR
#' @docType package
Expand Down
19 changes: 19 additions & 0 deletions R/randCyto.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#' Subset of the 'extdata' data in the 'flowWorkspaceData' package
#'
#' A sample dataset containing information about flow cytometry data with two binary conditions and four markers. The data are a random subset of the 'extdata' data in the 'flowWorkspaceData' package found on Bioconductor \url{http://bioconductor.org/packages/release/data/experiment/html/flowWorkspaceData.html} and formated for 'gateR' input. The selected markers are arcsinh transformed.
#'
#' @format A data frame with 11763 rows and 7 variables:
#' \describe{
#' \item{id}{cell ID number}
#' \item{g1}{binary condition #1}
#' \item{g2}{binary condition #2}
#' \item{arcsinh_CD4}{arcsinh-transformed CD4}
#' \item{arcsinh_CD38}{arcsinh-transformed CD38}
#' \item{arcsinh_CD8}{arcsinh-transformed CD8}
#' \item{arcsinh_CD3}{arcsinh-transformed CD3}
#' }
#' @examples
#' head(randCyto)
#'
#' @source \url{https://github.com/Waller-SUSAN/gateR/blob/master/README.md}
"randCyto"
40 changes: 2 additions & 38 deletions R/rrs.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,44 +37,8 @@
#' @importFrom sparr OS risk
#' @export
#'
#' @examples
#' if (interactive()) {
#' # Use 'extdata' from the {flowWorkspaceData} package
#' flowDataPath <- system.file("extdata", package = "flowWorkspaceData")
#' fcsFiles <- list.files(pattern = "CytoTrol", flowDataPath, full = TRUE)
#' ncfs <- ncdfFlow::read.ncdfFlowSet(fcsFiles)
#' fr1 <- ncfs[[1]]
#' fr2 <- ncfs[[2]]
#'
#' # Comparison of two samples (single condition) "g1"
#' ## One gate (two markers) "CD4", "CD38"
#' ## Log10 Transformation for both markers
#' ## Remove cells with NA and Inf values
#'
#' # First sample
#' obs_dat1 <- data.frame("id" = seq(1, nrow(fr1@exprs), 1),
#' "g1" = rep(1, nrow(fr1@exprs)),
#' "log10_CD4" = log(fr1@exprs[ , 5], 10),
#' "log10_CD38" = log(fr1@exprs[ , 6], 10))
#' # Second sample
#' obs_dat2 <- data.frame("id" = seq(1, nrow(fr2@exprs), 1),
#' "g1" = rep(2, nrow(fr2@exprs)),
#' "log10_CD4" = log(fr2@exprs[ , 5], 10),
#' "log10_CD38" = log(fr2@exprs[ , 6], 10))
#' # Full set
#' obs_dat <- rbind(obs_dat1, obs_dat2)
#' obs_dat <- obs_dat[complete.cases(obs_dat), ] # remove NAs
#' obs_dat <- obs_dat[is.finite(rowSums(obs_dat)), ] # remove Infs
#' obs_dat$g1 <- as.factor(obs_dat$g1) # set "g1" as binary factor
#'
#' # Create a placeholder variable
#' g2 <- stats::rbinom(nrow(obs_dat), 1, 0.5)
#' obs_dat$g2 <- as.factor(g2)
#' obs_dat <- obs_dat[ , c(1:2,5,3:4)]
#'
#' # Run rrs() function
#' test_rrs <- rrs(dat = obs_dat)
#' }
#' @examples
#' test_rrs <- rrs(dat = randCyto)
#'
rrs <- function(dat,
alpha = 0.05,
Expand Down
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,30 @@ Available functions
</tbody>
<table>

<h2 id="available-data">

Available sample data sets

</h2>

<table>
<colgroup>
<col width="30%" />
<col width="70%" />
</colgroup>
<thead>
<tr class="header">
<th>Function</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<td><code>randCyto</code></td>
<td>A sample dataset containing information about flow cytometry data with two binary conditions and four markers. The data are a random subset of the 'extdata' data in the {flowWorkspaceData} package found on [Bioconductor](http://bioconductor.org/packages/release/data/experiment/html/flowWorkspaceData.html) and formated for {gateR} input.</td>
</tr>
</tbody>
<table>

<h2 id="authors">

Authors
Expand All @@ -99,6 +123,7 @@ set.seed(1234) # for reproducibility
# ------------------ #

library(gateR)
library(dplyr)
library(flowWorkspaceData)
library(ncdfFlow)
library(stats)
Expand Down Expand Up @@ -146,6 +171,9 @@ g2 <- stats::rbinom(nrow(obs_dat), 1, 0.5)
obs_dat$g2 <- as.factor(g2)
obs_dat <- obs_dat[ , c(1:2,7,3:6)]

# Export 'randCyto' data for CRAN examples
randCyto <- dplyr::sample_frac(obs_dat, size = 0.1) # random subsample

# ---------------------------- #
# Run gateR with one condition #
# ---------------------------- #
Expand Down
27 changes: 10 additions & 17 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
## This is the second resubmission
## This is the third resubmission

* Actions taken regarding feedback from Gregor Seyer:
* Reduced the length of the title to less than 65 characters
* Replaced cat() with message() in gating(), lotrrs(), and rrs() functions to allow for suppressable information messages
* Actions taken regarding feedback from Prof. Brian Ripley:
* Removed 'ncdFlow', 'flowWorkspaceData', and 'knitr' from Suggests
* Created a random data set 'randCyto' and all documentation
* Updated examples and testthat to use 'randCyto' data
* Updated vignette with clearer language

## Test environments
* local OS X install, R 3.6.3
Expand All @@ -12,23 +14,14 @@
* Ubuntu Linux 16.04 LTS, R-release, GCC
* Windows Server 2008 R2 SP1, R-devel, 32⁄64 bit
* Debian Linux, R-devel, GCC

There was 1 NOTE:

* Possibly mis-spelled words in DESCRIPTION:
* Bithell (38:63, 40:24)
* Cytometry (3:57)
* al (37:57)
* et (37:54)
* immunologically (32:19)

## R CMD check results
0 errors | 0 warnings | 0 notes

* Duration
* local OS X install, R 3.6.3: 99 seconds
* win-builder, devel: 341 seconds
* win-builder, oldrelease: 282 seconds
* win-builder, release: 330 seconds
* local OS X install, R 3.6.3: 98 seconds
* win-builder, devel: 337 seconds
* win-builder, oldrelease: 302 seconds
* win-builder, release: 345 seconds

## Submitted by Maintainer
62 changes: 62 additions & 0 deletions data-raw/get_randCyto.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# code to prepare `randCyto` dataset

set.seed(1234)

# ------------------ #
# Necessary packages #
# ------------------ #

library(dplyr)
library(flowWorkspaceData)
library(ncdfFlow)
library(stats)
library(usethis)

# ---------------- #
# Data preparation #
# ---------------- #

# Use 'extdata' from the {flowWorkspaceData} package
flowDataPath <- system.file("extdata", package = "flowWorkspaceData")
fcsFiles <- list.files(pattern = "CytoTrol", flowDataPath, full = TRUE)
ncfs <- ncdfFlow::read.ncdfFlowSet(fcsFiles)
fr1 <- ncfs[[1]]
fr2 <- ncfs[[2]]

## Comparison of two samples (single condition) "g1"
## Two gates (four markers) "CD4", "CD38", "CD8", and "CD3"
## Arcsinh Transformation for all markers
## Remove cells with NA and Inf values

# First sample
obs_dat1 <- data.frame("id" = seq(1, nrow(fr1@exprs), 1),
"g1" = rep(1, nrow(fr1@exprs)),
"arcsinh_CD4" = asinh(fr1@exprs[ , 5]),
"arcsinh_CD38" = asinh(fr1@exprs[ , 6]),
"arcsinh_CD8" = asinh(fr1@exprs[ , 7]),
"arcsinh_CD3" = asinh(fr1@exprs[ , 8]))
# Second sample
obs_dat2 <- data.frame("id" = seq(1, nrow(fr2@exprs), 1),
"g1" = rep(2, nrow(fr2@exprs)),
"arcsinh_CD4" = asinh(fr2@exprs[ , 5]),
"arcsinh_CD38" = asinh(fr2@exprs[ , 6]),
"arcsinh_CD8" = asinh(fr2@exprs[ , 7]),
"arcsinh_CD3" = asinh(fr2@exprs[ , 8]))

# Full set
obs_dat <- rbind(obs_dat1, obs_dat2)
obs_dat <- obs_dat[complete.cases(obs_dat), ] # remove NAs
obs_dat <- obs_dat[is.finite(rowSums(obs_dat)), ] # remove Infs
obs_dat$g1 <- as.factor(obs_dat$g1) # set "g1" as binary factor

## Create a second condition (randomly split the data)
## In practice, use data with a measured second condition
g2 <- stats::rbinom(nrow(obs_dat), 1, 0.5)
obs_dat$g2 <- as.factor(g2)
obs_dat <- obs_dat[ , c(1:2,7,3:6)]

# Reduce size for CRAN exportation
randCyto <- dplyr::sample_frac(obs_dat, size = 0.1) # saved as `randCyto` data

# Export
usethis::use_data(randCyto, overwrite = TRUE)
Binary file added data/randCyto.rda
Binary file not shown.
3 changes: 2 additions & 1 deletion dev/build.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ install.packages(c("devtools", "roxygen2", "testthat", "knitr"))
library(devtools)
devtools::has_devel()
library(roxygen2)
library(rhub)
library(testthat)

devtools::load_all()
Expand Down Expand Up @@ -35,7 +36,7 @@ usethis::use_build_ignore(c("build"))
usethis::use_build_ignore(c("figures"))

# rhub
devtools::check_rhub()
#devtools::check_rhub()
rhub::check_for_cran()

# Check on windows
Expand Down
Loading

0 comments on commit 1056690

Please sign in to comment.