Skip to content

Commit

Permalink
update to use inherets() for SPE check across functions
Browse files Browse the repository at this point in the history
  • Loading branch information
MicTott committed Dec 24, 2024
1 parent 9f16259 commit f0df01e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
5 changes: 3 additions & 2 deletions R/findArtifacts.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ findArtifacts <- function(
shape = "hexagonal", log = TRUE, name = "artifact", var_output = TRUE) {

# ===== Validity checks =====
if (!("SpatialExperiment" %in% class(spe))) {
stop("Input data must be a SpatialExperiment object.")
# Check if 'spe' is (or inherits from) SpatialExperiment
if (!inherits(spe, "SpatialExperiment")) {
stop("Input data must be a SpatialExperiment or inherit from SpatialExperiment.")
}

if (!all(mito_percent %in% colnames(colData(spe)))) {
Expand Down
7 changes: 3 additions & 4 deletions R/flagVisiumOutliers.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@
#'
flagVisiumOutliers <- function(spe) {

# Check if 'spe' is a SpatialExperiment object
# Check if 'spe' is a valid object with required components
if (!("SpatialExperiment" %in% class(spe))) {
stop("Input data must be either a SpatialExperiment")
# Check if 'spe' is (or inherits from) SpatialExperiment
if (!inherits(spe, "SpatialExperiment")) {
stop("Input data must be a SpatialExperiment or inherit from SpatialExperiment.")
}

# Load the biased_spots dataset
Expand Down
6 changes: 3 additions & 3 deletions R/localOutliers.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ localOutliers <- function(
log = TRUE, cutoff = 3, workers=1) {

# ===== Validity checks =====
# Check if 'spe' is a valid object with required components
if (!("SpatialExperiment" %in% class(spe) || "SingleCellExperiment" %in% class(spe))) {
stop("Input data must be either a SpatialExperiment or SingleCellExperiment object.")
# Check if 'spe' is (or inherits from) SpatialExperiment
if (!inherits(spe, "SpatialExperiment")) {
stop("Input data must be a SpatialExperiment or inherit from SpatialExperiment.")
}

# Validate 'direction'
Expand Down
6 changes: 3 additions & 3 deletions R/localVariance.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ localVariance <- function(spe, n_neighbors = 36,
workers = 1) {

# ===== Validity checks =====
# Check if 'spe' is a valid object with required components
if (!("SpatialExperiment" %in% class(spe))) {
stop("Input data must be a SpatialExperiment object.")
# Check if 'spe' is (or inherits from) SpatialExperiment
if (!inherits(spe, "SpatialExperiment")) {
stop("Input data must be a SpatialExperiment or inherit from SpatialExperiment.")
}

# Validate 'metric' is a character vector
Expand Down

0 comments on commit f0df01e

Please sign in to comment.