Skip to content

Commit

Permalink
R CMD check problems
Browse files Browse the repository at this point in the history
  • Loading branch information
lambdamoses committed Oct 25, 2024
1 parent 2d348ee commit 7e37956
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 44 deletions.
7 changes: 5 additions & 2 deletions R/coerce.R
Original file line number Diff line number Diff line change
Expand Up @@ -541,8 +541,11 @@ setMethod("toSpatialFeatureExperiment", "SingleCellExperiment",
if (is_Visium == "VisiumV2")
# set scaling factor -> microns per pixel
scale_fct <- bin_um / spot_diameter
else
scale_fct <- .pixel2micron(sfe)
else {
df_coords <- as.data.frame(spatialCoords(sfe))
names(df_coords) <- c("pxl_col_in_fullres", "pxl_row_in_fullres")
scale_fct <- .pixel2micron(cbind(as.data.frame(colData(sfe)), df_coords))
}
cg <- spotPoly(sfe)
cg$geometry <- cg$geometry * scale_fct
spotPoly(sfe) <- cg
Expand Down
5 changes: 3 additions & 2 deletions R/graph_wrappers.R
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,8 @@ findVisiumGraph <- function(x, sample_id = "all", style = "W",
#' @concept Spatial neighborhood graph
#' @return A \code{listw} object for the graph.
#' @export
findVisiumHDGraph <- function(x, style = "W", queen = FALSE) {
findVisiumHDGraph <- function(x, style = "W", queen = FALSE,
zero.policy = TRUE) {
df <- as.data.frame(colData(x))
df$index <- seq_along(df$barcode)
cols_use <- c("index", "array_row", "array_col")
Expand Down Expand Up @@ -729,7 +730,7 @@ findVisiumHDGraph <- function(x, style = "W", queen = FALSE) {
args = list(
style = style,
zero.policy = zero.policy,
sample_id = sample_id
sample_id = sampleIDs(x)
)
)
out
Expand Down
25 changes: 5 additions & 20 deletions R/read.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#' @inheritParams findVisiumGraph
#' @inheritParams SpatialFeatureExperiment
#' @inheritParams DropletUtils::read10xCounts
#' @inheritParams SpatialExperiment::read10xVisium
#' @param sample To be consistent with \code{SpatialExperiment::read10xVisium},
#' one or more directories with Space Ranger output for a Visium sample. It is
#' assumed to have the \code{outs} directory in it but this can be overridden
Expand Down Expand Up @@ -270,8 +271,7 @@ read10xVisiumSFE <- function(samples = "",
sample_id, "\n"))
if (VisiumHD) {
colGraph(sfe, "visiumhd") <-
findVisiumHDGraph(sfe, sample_id = "all", style = style,
zero.policy = zero.policy)
findVisiumHDGraph(sfe, style = style, zero.policy = zero.policy)
} else {
colGraph(sfe, "visium") <-
findVisiumGraph(sfe, sample_id = "all",
Expand Down Expand Up @@ -311,21 +311,6 @@ read10xVisiumSFE <- function(samples = "",
#' \code{\link{Voyager::plotSpatialFeature}}.
#' @export
#' @examples
#' # load VisiumHD
#' # path to "binned_outputs" directory containing:
#' # |-- binned_outputs
#' # |-- square_002um
#' # |-- square_008um
#' # |-- square_016um
#' dir_hd <- "~/Downloads/Visium_HD_Mouse_Brain/binned_outputs/"
#' # this is public dataset ->
#' # https://www.10xgenomics.com/datasets/visium-hd-cytassist-gene-expression-libraries-of-mouse-brain-he
#' sfe_hd <-
#' read10xVisiumSFE(dirs = dir_hd,
#' bin_size = c(8, 16), # this defines which of 1:3 resolutions to load
#' type = "HDF5", # Note, "sparse" -> takes longer to load
#' data = "filtered", # spots under tissue
#' add_graph = TRUE)
#'
readVisiumHD <- function(data_dir, bin_size = c(2L, 8L, 16L),
sample_id = NULL,
Expand Down Expand Up @@ -461,7 +446,7 @@ readVisiumHD <- function(data_dir, bin_size = c(2L, 8L, 16L),
# check if not all are TRUE
if (!is_xen && is_Xenium) {
warning("Provided segmentations data for `.filter_polygons` indicates Xenium technology,", "\n",
"However, it doesnt contain `cell_id` and/or `label_id` columns")
"However, it doesn't contain `cell_id` and/or `label_id` columns")
}
# identify which column contains tech-specific cell ids
# ie, "cell_id" for Xenium; "cellID" for CosMX; "EntityID" for Vizgen
Expand Down Expand Up @@ -535,7 +520,7 @@ readVisiumHD <- function(data_dir, bin_size = c(2L, 8L, 16L),
inds <- which(areas > min_area)
if (any(inds)) {
message(">>> Removing ", c(length(areas) - length(inds)),
" cells with area < ", min_area, " µm\u00B2")
" cells with area < ", min_area, " \u03BCm\u00B2")
}
polys <- polys[inds, ]
} else { polys }
Expand Down Expand Up @@ -794,7 +779,7 @@ readVizgen <- function(data_dir,
# `cellpose_micron_space.parquet`
# `cellpose_mosaic_space.parquet`
# or any other `parquet` files
# use µm units
# use um units
parq_clean <-
grep("cell_boundaries|micron_space",
parq, value = TRUE)
Expand Down
4 changes: 3 additions & 1 deletion man/findVisiumHDGraph.Rd

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

8 changes: 7 additions & 1 deletion man/read10xVisiumSFE.Rd

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

4 changes: 4 additions & 0 deletions man/readCosMX.Rd

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

24 changes: 6 additions & 18 deletions man/readVisiumHD.Rd

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

4 changes: 4 additions & 0 deletions man/readXenium.Rd

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

0 comments on commit 7e37956

Please sign in to comment.