Skip to content

Commit

Permalink
sample_id stuff. Closing #28 and #40; really see previous commits
Browse files Browse the repository at this point in the history
  • Loading branch information
lambdamoses committed Jul 20, 2024
1 parent c876c74 commit cb8e164
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions R/split.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ setMethod("splitByCol", c("SpatialFeatureExperiment", "sfc"),
setMethod("splitByCol", c("SpatialFeatureExperiment", "list"),
function(x, f, sample_id = "all", colGeometryName = 1L, cover = FALSE) {
sample_id <- .check_sample_id(x, sample_id, one = FALSE)
f <- f[sample_id]
if (!length(f))
if (!any(sample_id %in% names(f)))
stop("None of the geometries correspond to sample_id")
f <- f[intersect(sample_id, names(f))]
out <- lapply(sample_id, function(s) {
splitByCol(x, f[[s]], sample_id = s, colGeometryName = colGeometryName,
cover = cover)
Expand All @@ -78,7 +78,6 @@ setMethod("splitByCol", c("SpatialFeatureExperiment", "list"),
#' @export
splitSamples <- function(x) {
ss <- sampleIDs(x)
if (length(ss) == 1L) return(x)
out <- lapply(ss, function(s) x[, x$sample_id == s])
names(out) <- ss
out
Expand Down

0 comments on commit cb8e164

Please sign in to comment.