Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ Description: Definitions for the Giotto object and its subobjects.
License: MIT + file LICENSE
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.3
Depends:
R (>= 4.5.0)
Imports:
Expand Down Expand Up @@ -161,3 +160,4 @@ URL: https://giotto-suite.github.io/GiottoClass/
biocViews: Software, Technology, Spatial
VignetteBuilder: knitr
BugReports: https://github.com/giotto-suite/Giotto/issues
Config/roxygen2/version: 8.0.0
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ exportMethods(settleGeom)
exportMethods(shear)
exportMethods(snap)
exportMethods(spatIDs)
exportMethods(spatRelate)
exportMethods(spatShift)
exportMethods(spatUnit)
exportMethods(spin)
Expand Down
44 changes: 22 additions & 22 deletions R/classes-overlaps.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ setClass("overlapIntensity", contains = c("overlapInfo", "VIRTUAL"))
#' @title Polygon and Point Relationships
#' @description
#' Utility class for storing overlaps relationships between polygons and points
#' in a sparse `data.table` format. Retrieve the unique ID index of overlapped
#' points `[i, ]`. Get indices of which polys are overlapping specific feature
#' species using `[, j]`.
#'
#' Subsetting with `ids = FALSE` and `[i, j]` indexing is also supported.
#' in a sparse `data.table` format. `[i, ]` / `[, j]` / `[i, j]` all return a
#' subset `overlapPointDT`. To retrieve indices instead — feat_ID_uniqs
#' overlapped by poly i, or poly indices overlapping feature j — pass
#' `ids = TRUE`.
#'
#' Supports `as.matrix` for conversion to `dgCMatrix`. Contained poly and
#' feature names simplify rownames/colnames and empty row/col creation.
Expand All @@ -49,14 +48,15 @@ setClass("overlapIntensity", contains = c("overlapInfo", "VIRTUAL"))
#' polygons
#' @param j numeric, character, logical. Index of or name of feature being
#' overlapped.
#' @param use_names logical (default = `FALSE`). Whether to return as integer
#' indices or with character ids.
#' @param ids logical (default = `TRUE`). Whether to return the requested
#' integer indices (`TRUE`) or the subset overlap object (`FALSE`).
#' @param use_names logical (default = `FALSE`). When `ids = TRUE`, whether
#' to return integer indices (`FALSE`) or character ids (`TRUE`).
#' @param ids logical (default = `FALSE`). Whether to return the requested
#' integer indices (`TRUE`) or the subset overlap object (`FALSE`, default).
#' @param drop not used.
#' @param \dots additional params to pass (none implemented)
#' @returns integer or character if only `i` or `j` provided, depending on
#' `use_names`. A subset `overlapPointDT` if both `i` and `j` are used.
#' @returns A subset `overlapPointDT` by default. When `ids = TRUE`,
#' an integer (or character via `use_names = TRUE`) vector of the queried
#' indices.
#' @examples
#' g <- GiottoData::loadGiottoMini("vizgen")
#' poly <- g[["spatial_info", "z0"]][[1]]
Expand All @@ -68,19 +68,19 @@ setClass("overlapIntensity", contains = c("overlapInfo", "VIRTUAL"))
#' dim(ovlp)
#' nrow(ovlp) # number of relationships
#'
#' # get feature unique IDs overlapped by nth poly
#' ovlp[1] # check one (no overlaps returns integer(0))
#' ovlp[1:5] # check multiple
#' ovlp[1:5, use_names = TRUE] # returns feature names, but no longer unique
#' # subset (default) — returns an overlapPointDT
#' ovlp[1:10] # first 10 polys
#' ovlp[, 1:10] # first 10 feature species
#' ovlp[1:10, 1:10] # both
#'
#' # get integer index of poly(s) overlapping particular feature species
#' ovlp[, 1]
#' ovlp[, "Mlc1"] # this is the same
#' # selection query — feature unique IDs overlapped by nth poly
#' ovlp[1, ids = TRUE] # integer feat_ID_uniqs (integer(0) if no overlap)
#' ovlp[1:5, ids = TRUE]
#' ovlp[1:5, ids = TRUE, use_names = TRUE] # feature names instead of ints
#'
#' # get a subset of overlap object
#' ovlp[1:10, ids = FALSE] # subset to first 10 polys
#' ovlp[, 1:10, ids = FALSE] # subset to first 10 feature species
#' ovlp[1:10, 1:10] # subset to first 10 polys and first 10 features species
#' # selection query — poly indices overlapping particular feature species
#' ovlp[, 1, ids = TRUE]
#' ovlp[, "Mlc1", ids = TRUE]
#' @exportClass overlapPointDT
setClass("overlapPointDT",
contains = "overlapPoint",
Expand Down
19 changes: 12 additions & 7 deletions R/create.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,14 @@ NULL
#' from \code{\link{createGiottoInstructions}}
#' @param cores how many cores or threads to use to read data if paths are
#' provided
#' @param expression_matrix_class class of expression matrix to
#' use (e.g. 'dgCMatrix', 'DelayedArray')
#' @param expression_matrix_class deprecated. See `?createExprObj` for details
#' @param backend backend to use (optional). One of:
#'
#'
#' * `NULL` - (default) in memory object
#' * `filepath` - path at which to set up a project directory. Does not have
#' to already exist. Sets the backend manager as `gDirSource` by default.
#' * `gsource`-inheriting - A specific backend manager to use
#'
#'
#' `filepath` and `gsource` both require {GiottoDisk}.
#' @param h5_file deprecated. Use `backend` instead
#' @param verbose be verbose when building Giotto object
Expand Down Expand Up @@ -226,7 +225,7 @@ createGiottoObject <- function(expression,
instructions = NULL,
cores = determine_cores(),
raw_exprs = NULL,
expression_matrix_class = c("dgCMatrix", "DelayedArray"),
expression_matrix_class = deprecated(),
backend = NULL,
h5_file = deprecated(),
verbose = FALSE) {
Expand All @@ -245,6 +244,13 @@ createGiottoObject <- function(expression,
images <- c(images, largeImages)
}

if (is_present(expression_matrix_class)) {
warning(sprintf(
"[createGiottoObject] param '%s' is deprecated",
"expression_matrix_class"),
call. = FALSE)
}

if (is_present(h5_file)) backend <- h5_file
if (!is_present(h5_file)) h5_file <- NULL
if (!is.null(backend)) {
Expand Down Expand Up @@ -363,8 +369,7 @@ createGiottoObject <- function(expression,
sparse = TRUE,
cores = cores,
default_feat_type = expression_feat,
verbose = debug_msg,
expression_matrix_class = expression_matrix_class
verbose = debug_msg
)
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
gobject <- setExpression(
Expand Down
3 changes: 0 additions & 3 deletions R/data_evaluation.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ evaluate_input <- function(type, x, ...) {
#' @param inputmatrix inputmatrix to evaluate
#' @param sparse create sparse matrix (default = TRUE)
#' @param cores how many cores to use
#' @param expression_matrix_class `character` (optional). Matrix
#' representation to convert to. If left as NULL, no conversions will
#' be attempted
#' @details The inputmatrix can be a matrix, sparse matrix, data.frame,
#' data.table or path to any of these.
#' @keywords internal
Expand Down
4 changes: 2 additions & 2 deletions R/data_input.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ readExprMatrix <- function(
checkmate::assert_flag(transpose)
if (is_present(expression_matrix_class)) {
warning(sprintf(
"[readExprMatrix] param '%s' is deprecated",
"expression_matrix_class"),
"[readExprMatrix] param '%s' is deprecated",
"expression_matrix_class"),
call. = FALSE)
}

Expand Down
7 changes: 7 additions & 0 deletions R/generics.R
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,13 @@ setGeneric("splitGeom", function(x, ...) standardGeneric("splitGeom"))
setGeneric("overlaps", function(x, ...) standardGeneric("overlaps"))


# Methods and documentations found in methods-relate.R
setGeneric(
"spatRelate",
function(x, y, relation = "intersects", ...) standardGeneric("spatRelate")
)



# Giotto subnesting ####
# All methods and documentations found in methods-nesting.R
Expand Down
55 changes: 21 additions & 34 deletions R/methods-extract.R
Original file line number Diff line number Diff line change
Expand Up @@ -662,8 +662,7 @@ setMethod(
)

#' @rdname replace_bracket
#' @aliases [<-,coordDataDT,missing,missing,
#' ANY-method [<-,coordDataDT,missing,missing-method
#' @aliases [<-,coordDataDT,missing,missing-method
#' @docType methods
#' @section \code{`[<-`} methods:
#' Assign to \code{coordinates} slot in giotto S4
Expand Down Expand Up @@ -742,8 +741,7 @@ setMethod(
)

#' @rdname replace_bracket
#' @aliases [<-,metaData,missing,missing,
#' ANY-method [<-,metaData,missing,missing-method
#' @aliases [<-,metaData,missing,missing-method
#' @docType methods
#' @section \code{`[<-`} methods:
#' Assign to \code{metaDT} slot in giotto S4
Expand Down Expand Up @@ -783,8 +781,7 @@ setMethod(
)

#' @rdname replace_bracket
#' @aliases [<-,dimObj,missing,missing,
#' ANY-method [<-,dimObj,missing,missing-method
#' @aliases [<-,dimObj,missing,missing-method
#' @docType methods
#' @section \code{`[<-`} methods:
#' Assign to \code{coordinates} slot in giotto S4 dimObj
Expand Down Expand Up @@ -844,8 +841,7 @@ setMethod(
)

#' @rdname replace_bracket
#' @aliases [<-,exprData,missing,missing,
#' ANY-method [<-,exprData,missing,missing-method
#' @aliases [<-,exprData,missing,missing-method
#' @docType methods
#' @section \code{`[<-`} methods:
#' Assign to \code{exprMat} slot in giotto S4
Expand Down Expand Up @@ -876,8 +872,7 @@ setMethod(
)

#' @rdname replace_bracket
#' @aliases [<-,spatNetData,missing,missing,
#' ANY-method [<-,spatNetData,missing,missing-method
#' @aliases [<-,spatNetData,missing,missing-method
#' @docType methods
#' @section \code{`[<-`} methods:
#' Assign to \code{network} slot in giotto S4
Expand Down Expand Up @@ -906,8 +901,7 @@ setMethod(
)

#' @rdname replace_bracket
#' @aliases [<-,nnData,missing,missing,
#' ANY-method [<-,nnData,missing,missing-method
#' @aliases [<-,nnData,missing,missing-method
#' @docType methods
#' @section \code{`[<-`} methods:
#' Assign to \code{network} slot in giotto S4
Expand Down Expand Up @@ -968,8 +962,7 @@ setMethod(


#' @rdname replace_bracket
#' @aliases [<-,enrData,missing,missing,
#' ANY-method [<-,enrData,missing,missing-method
#' @aliases [<-,enrData,missing,missing-method
#' @docType methods
#' @section \code{`[<-`} methods:
#' Assign to \code{enrichDT} slot in giotto S4
Expand Down Expand Up @@ -1000,8 +993,7 @@ setMethod(
)

#' @rdname replace_bracket
#' @aliases [<-,spatGridData,missing,missing,
#' ANY-method [<-,spatGridData,missing,missing-method
#' @aliases [<-,spatGridData,missing,missing-method
#' @docType methods
#' @section \code{`[<-`} methods:
#' Assign to \code{gridDT} slot in giotto S4
Expand Down Expand Up @@ -1083,8 +1075,7 @@ setMethod(
)

#' @rdname replace_bracket
#' @aliases [<-,giottoPoints,missing,missing,
#' ANY-method [<-,giottoPoints,missing,missing-method
#' @aliases [<-,giottoPoints,missing,missing-method
#' @docType methods
#' @section \code{`[<-`} methods:
#' Assign to \code{spatVector} slot in giotto S4
Expand Down Expand Up @@ -1163,7 +1154,7 @@ setMethod(
if (!inherits(o[[feat]], "overlapInfo")) {
warning("[subset overlaps feats] unrecognized overlap type")
}
o[[feat]] <- o[[feat]][, i, ids = FALSE]
o[[feat]] <- o[[feat]][, i]
}
o
}
Expand Down Expand Up @@ -1200,7 +1191,7 @@ setMethod(
}
next
}
x@overlaps[[feat]] <- x@overlaps[[feat]][i, ids = FALSE]
x@overlaps[[feat]] <- x@overlaps[[feat]][i]
}
x
}
Expand Down Expand Up @@ -1389,8 +1380,7 @@ setMethod(


#' @rdname replace_bracket
#' @aliases [<-,giottoPolygon,missing,missing,
#' ANY-method [<-,giottoPolygon,missing,missing-method
#' @aliases [<-,giottoPolygon,missing,missing-method
#' @docType methods
#' @section \code{`[<-`} methods:
#' Assign to \code{spatVector} slot in giottoPolygon
Expand All @@ -1417,12 +1407,11 @@ setMethod("[",
i = "gIndex",
j = "missing",
drop = "missing"
), function(x, i, j, ..., use_names = FALSE, ids = TRUE, drop) {
if (!isTRUE(ids)) {
res <- .subset_overlap_point_dt_i(x, i)
return(res)
), function(x, i, j, ..., use_names = FALSE, ids = FALSE, drop) {
if (isTRUE(ids)) {
return(.select_overlap_point_dt_i(x, i, use_names = use_names))
}
.select_overlap_point_dt_i(x, i, use_names = use_names)
.subset_overlap_point_dt_i(x, i)
}
)

Expand All @@ -1434,12 +1423,11 @@ setMethod("[",
i = "missing",
j = "gIndex",
drop = "missing"
), function(x, i, j, ..., use_names = FALSE, ids = TRUE, drop) {
if (!isTRUE(ids)) {
res <- .subset_overlap_point_dt_j(x, j)
return(res)
), function(x, i, j, ..., use_names = FALSE, ids = FALSE, drop) {
if (isTRUE(ids)) {
return(.select_overlap_point_dt_j(x, j, use_names = use_names))
}
.select_overlap_point_dt_j(x, j, use_names = use_names)
.subset_overlap_point_dt_j(x, j)
}
)

Expand Down Expand Up @@ -1614,8 +1602,7 @@ setMethod(
)

#' @rdname replace_bracket
#' @aliases [<-,affine2d,missing,missing,
#' ANY-method [<-,affine2d,missing,missing-method
#' @aliases [<-,affine2d,missing,missing-method
#' @docType methods
#' @section \code{`[<-`} methods:
#' Assign to \code{affine} slot in affine2d
Expand Down
Loading