Skip to content

Commit

Permalink
- corrected formatting bug in documentation of channelSummaryStats.Rd()
Browse files Browse the repository at this point in the history
- corrected bug in channelSummaryStats (when channels are not explicitly provided)
- bumped version to 0.99.8
  • Loading branch information
phauchamps committed Jan 16, 2024
1 parent 48f73d1 commit 6fda9b4
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 21 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: CytoMDS
Title: Low Dimensions projection of cytometry samples
Version: 0.99.7
Version: 0.99.8
Authors@R:
c(person(given = "Philippe",
family = "Hauchamps",
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ for not loading the whole flowSet in memory at once.
unidimensional histograms and store them instead of recalculating them each
time a distance between 2 samples is calculated. This improves CPU time and
memory consumption.

### CytoMDS 0.99.8
- renamed `getChannelSummaryStats()` into `channelSummaryStats()`
- in `channelSummaryStats(), added support for `BiocParallel`, and allowed
for not loading the whole flowSet in memory at once.
Expand Down
14 changes: 11 additions & 3 deletions R/stats.R
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,10 @@ pairwiseEMDDist <- function(
packages = c("flowCore"))) {
#browser()

if (!is.numeric(nSamples) || nSamples < 1) {
stop("nSamples should be a numeric >= 1")
}

nStats <- length(statFUNs)
if (nStats < 1) {
stop("At least one stat function should be provided for calculation")
Expand Down Expand Up @@ -1241,7 +1245,7 @@ pairwiseEMDDist <- function(

# rearrange outputs

nCh <- length(channels)
nCh <- ncol(statMatBlockList[[1]][[1]])
chStats <- list()
for (s in seq_along(statFUNs)){
chStats[[s]] <- matrix(
Expand All @@ -1266,8 +1270,9 @@ pairwiseEMDDist <- function(
chStats
}

#' @title Calculate a summary statistic of some channels of
#' all flowFrames of a flowSet
#' @title Summary statistics per channel computation
#' @description Computation of summary statistic for selected channels,
#' for all flowFrames of a flowSet.
#' This method provides two different input modes:
#' - the user provides directly a flowSet loaded in memory (RAM).
#' - the user provides (1.) a number of samples `nSamples`; (2.) an ad-hoc
Expand Down Expand Up @@ -1377,6 +1382,9 @@ channelSummaryStats <- function(
return(fs[[ffIndex]])
}
nSamples <- length(x)
if (nSamples < 1) {
stop("empty flowSet passed")
}
chStats <- .channelSummaryStats(
nSamples = nSamples,
loadFlowFrameFUN = getFF,
Expand Down
18 changes: 3 additions & 15 deletions man/channelSummaryStats.Rd

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

29 changes: 27 additions & 2 deletions tests/testthat/test-stats.R
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ test_that("channelSummaryStats works", {
fsAll,
channels = channelsOrMarkers,
statFUNs = list("mean" = mean, "std.dev" = stats::sd),
verbose = TRUE)
verbose = FALSE)

expect_equal(names(ret), c("mean", "std.dev"))
expect_equal(unname(rownames(ret[[1]])), flowCore::sampleNames(fsAll))
Expand Down Expand Up @@ -676,6 +676,31 @@ test_that("channelSummaryStats works", {
expect_equal(unname(ret[1,1]), 1.900298)
expect_equal(unname(ret[1,2]), 1.39186533)
expect_equal(unname(ret[1,3]), 1.8544648)

# case where no channels is provided
ret <- channelSummaryStats(
fsAll,
statFUNs = list("mean" = mean, "std.dev" = stats::sd),
verbose = FALSE
)

allSignalChannels <-
flowCore::colnames(fsAll)[CytoPipeline::areSignalCols(fsAll)]
nSignalCh <- length(allSignalChannels)

allSignalChannelNames <- allSignalChannels
for (i in seq_along(allSignalChannels)) {
channelMarker <-
flowCore::getChannelMarker(fsAll[[1]], allSignalChannels[i])$desc
if (!is.null(channelMarker) && !is.na(channelMarker)){
allSignalChannelNames[i] <- channelMarker
}
}

expect_equal(unname(rownames(ret[[1]])),
c("Donor1", "Donor2", "Agg1", "Agg2", "Agg3"))
expect_equal(unname(colnames(ret[[1]])), allSignalChannelNames)

})

test_that("channelSummaryStats dynamic memory loading simulation", {
Expand All @@ -690,7 +715,7 @@ test_that("channelSummaryStats dynamic memory loading simulation", {
channelsOrMarkers <- c("FSC-A", "SSC-A", "BV785 - CD3")

nSamples <- 10
verbose <- TRUE
verbose <- FALSE
ret <- CytoMDS::channelSummaryStats(
x = nSamples,
loadFlowFrameFUN = simulMemoryLoad,
Expand Down

0 comments on commit 6fda9b4

Please sign in to comment.