Skip to content

Commit

Permalink
Merge pull request #27 from boyiguo1/v1.1.2
Browse files Browse the repository at this point in the history
Add Example to make_escheR Manual
  • Loading branch information
boyiguo1 authored Sep 20, 2023
2 parents 4716dbe + 19f85b8 commit e8f02e8
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions R/make_escheR.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,23 @@
#'
#' @examples
#' library(STexampleData)
#'
#' # SpatialExperiment Object
#' spe <- Visium_humanDLPFC()
#'
#' make_escheR(spe)
#'
#' # SingleCellExperiment Object
#' sce <- SingleCellExperiment(counts(spe))
#' reducedDims(sce) <- list(
#' # Example embedding
#' EG = matrix(seq.int(1, ncol(spe)*2), ncol = 2)
#' )
#' make_escheR(sce, dimred = "EG")
#'
#' # data.frame Object
#' x <- spatialCoords(spe)[,1]
#' y <- spatialCoords(spe)[,2]
#' df <- colData(spe) |> data.frame()
#' make_escheR(object = df, .x = x , .y = y)
make_escheR <- function(object, spot_size = 2, ...) {
UseMethod("make_escheR", object)
}
Expand Down Expand Up @@ -80,8 +93,8 @@ make_escheR.SingleCellExperiment <- function(
" is not found in reducedDim(object).")


if(ncol(reducedDim(sce, dimred)) <= 2)
stop("reducedDim(object, ", dimred, " ) must have more than 2 columns.")
if(ncol(reducedDim(sce, dimred)) < 2)
stop("reducedDim(object, ", dimred, " ) must have at least 2 columns.")

# TODO (Medium): How about dimension reduction assays?
coord_df <- reducedDim(sce, dimred)[ , c(1,2), drop = FALSE]
Expand Down

0 comments on commit e8f02e8

Please sign in to comment.