Skip to content

Commit

Permalink
Remove the option to exclude cells again
Browse files Browse the repository at this point in the history
  • Loading branch information
nilseling committed Oct 13, 2023
1 parent 4a977af commit 4723167
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 26 deletions.
22 changes: 1 addition & 21 deletions R/testInteractions.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
#' @param tolerance single numeric larger than 0. This parameter defines the
#' difference between the permuted count and the actual counts at which both
#' are regarded as equal. Default taken from \code{all.equal}.
#' @param remove_unconnected single logical indicating if cells that don't have
#' any neighbors should be removed before testing. Default \code{FALSE}.
#' @param BPPARAM parameters for parallelized processing.
#'
#' @section Counting and summarizing cell-cell interactions:
Expand Down Expand Up @@ -74,13 +72,6 @@
#' or avoidance), overall \code{p} value and significance by comparison to
#' \code{p_treshold} (\code{sig} and \code{sigval}) are derived.
#'
#' @section Symmetry of interaction testing results:
#' From tests we observed that p-values and therefore sigificance values
#' are symmetric if (i) a symmertic graph is used (e.g., an expansion graph)
#' and (ii) if all cells are part of the graph. To achieve symmetric results,
#' unconnected cells can be removed prior to testing via setting
#' \code{remove_unconnected = TRUE}.
#'
#' @return a DataFrame containing one row per \code{group_by} entry and unique
#' \code{label} entry combination (\code{from_label}, \code{to_label}). The
#' object contains following entries:
Expand Down Expand Up @@ -174,25 +165,14 @@ testInteractions <- function(object,
p_threshold = 0.01,
return_samples = FALSE,
tolerance = sqrt(.Machine$double.eps),
remove_unconnected = FALSE,
BPPARAM = SerialParam()){

# Input check
method <- match.arg(method)
.valid.countInteractions.input(object, group_by, label, method,
patch_size, colPairName)
.valid.testInteractions.input(iter, p_threshold, return_samples,
tolerance, remove_unconnected)

# Remove cells that are not part of the graph
if (remove_unconnected) {
cur_ids <- seq_len(ncol(object))
cur_cells <- cur_ids[!(cur_ids %in% from(colPair(object, colPairName)))]

if (length(cur_cells) > 0) {
object <- object[,-cur_cells]
}
}
tolerance)

# Re-level group_by label
if(is.factor(colData(object)[[group_by]])) {
Expand Down
6 changes: 1 addition & 5 deletions R/validityChecks.R
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@
}

.valid.testInteractions.input <- function(iter, p_threshold, return_samples,
tolerance, remove_unconnected){
tolerance){
if (length(iter) != 1 | !is.numeric(iter)) {
stop("'iter' must be a single positive numeric.")
}
Expand Down Expand Up @@ -988,10 +988,6 @@
if (tolerance < 0) {
stop("'tolerance' must be larger than 0.")
}

if (length(remove_unconnected) != 1 | !is.logical(remove_unconnected)) {
stop("'remove_unconnected' must be a single logical.")
}
}

.valid.findBorderCells.input <- function(object, img_id, border_dist, coords){
Expand Down

0 comments on commit 4723167

Please sign in to comment.