Skip to content

Commit

Permalink
Merge pull request #236 from josschavezf/dev
Browse files Browse the repository at this point in the history
fix errors when running rcmdcheck
  • Loading branch information
josschavezf authored Sep 25, 2024
2 parents f2f4e09 + dec7d7d commit c0cca85
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 38 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

S3method(.DollarNames,affine2d)
S3method(.DollarNames,dimObj)
S3method(.DollarNames,giotto)
S3method(.DollarNames,metaData)
S3method(.DollarNames,spatEnrObj)
S3method(.DollarNames,spatLocsObj)
Expand Down
14 changes: 11 additions & 3 deletions R/methods-extract.R
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ NULL
#' This may remove some unexpected information. For specifically splitting the
#' `giotto` object by spatial unit and/or feature type while keeping all
#' expected information, use [sliceGiotto()]
#' @param x giotto object
#' @param spat_unit spatial unit (e.g. "cell")
#' @param feat_type feature type to use (e.g. "rna", "protein")
#' @param i character. Indicates the slot name
#' @param j character. Indicates the subobject name
#' @param drop logical. Default = TRUE
#' @param \dots additional arguments
#' @examples
#' g <- GiottoData::loadGiottoMini("vizgen")
#' force(g)
Expand Down Expand Up @@ -1277,8 +1284,6 @@ setMethod(


#' @rdname subset_giotto
#' @param feat_ids feature IDs to select
#' @param cell_ids cell/spatial IDs to select
#' @param subset Logical expression evaluated in expression values
#' @param negate logical. if `TRUE` all IDs that are **not** in the `subset`
#' are selected
Expand Down Expand Up @@ -1480,6 +1485,9 @@ sliceGiotto <- function(
#' @param x the object to coerce
#' @param slots character vector. Which data slots to include in list. See
#' details
#' @param spat_unit spatial unit (e.g. "cell")
#' @param feat_type feature type to use (e.g. "rna", "protein")
#' @param name name of the elements to select from the slot
#' @param \dots additional arguments
#' @details
#' * Giotto method - the slots argument currently accepts any or multiple of:
Expand Down Expand Up @@ -1530,4 +1538,4 @@ setMethod("as.list", signature("giotto"), function(
}
.dbrkt_on_filter <- function(x, y) {
x[objName(x) %in% y]
}
}
8 changes: 4 additions & 4 deletions R/save_load.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ saveGiotto <- function(gobject,
)
terra::writeVector(
x = gobject@feat_info[[feat]]@spatVector,
filename = filename
filename = filename, overwrite = TRUE
)
}

Expand Down Expand Up @@ -134,7 +134,7 @@ saveGiotto <- function(gobject,
)
terra::writeVector(
gobject@spatial_info[[spatinfo]]@spatVector,
filename = filename
filename = filename, overwrite = TRUE
)
}

Expand Down Expand Up @@ -162,7 +162,7 @@ saveGiotto <- function(gobject,
)
terra::writeVector(
gobject@spatial_info[[spatinfo]]@spatVectorCentroids,
filename = filename
filename = filename, overwrite = TRUE
)
}

Expand Down Expand Up @@ -197,7 +197,7 @@ saveGiotto <- function(gobject,
)
terra::writeVector(
gobject@spatial_info[[spatinfo]]@overlaps[[feature]],
filename = filename
filename = filename, overwrite = TRUE
)
}
}
Expand Down
6 changes: 6 additions & 0 deletions man/as.list.Rd

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

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

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

15 changes: 15 additions & 0 deletions man/subset_giotto_subobjects.Rd

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

42 changes: 19 additions & 23 deletions tests/testthat/test-GiottoInstructions.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,35 +41,31 @@ test_that("Instructions are created", {
expect_type(instrs, "list")
})

# readGiottoInstructions
test_that("readGiottoInstructions reads a few giotto object params correctly", {
expect_type(readGiottoInstructions(gobject, param = "show_plot"), "logical")
expect_type(readGiottoInstructions(gobject, param = "plot_format"), "character")
expect_type(readGiottoInstructions(gobject, param = "dpi"), "double")
# read GiottoInstructions
test_that("instructions reads a few giotto object params correctly", {
expect_type(instructions(gobject, param = "show_plot"), "logical")
expect_type(instructions(gobject, param = "plot_format"), "character")
expect_type(instructions(gobject, param = "dpi"), "double")
})

# showGiottoInstructions
test_that("showGiottoInstructions returns expected list", {
expect_type(showGiottoInstructions(gobject), "list")
# show GiottoInstructions
test_that("instructions returns expected list", {
expect_type(instructions(gobject), "list")
})

# changeGiottoInstructions
gobject <- changeGiottoInstructions(
gobject,
params = c("show_plot", "save_plot"),
new_values = c(FALSE, TRUE),
return_gobject = TRUE
)
# change GiottoInstructions
instructions(gobject,
param = c("show_plot", "save_plot")) <- list(FALSE, TRUE)

test_that("changeGiottoInstructions changes instruction params in object", {
expect_false(readGiottoInstructions(gobject, param = "show_plot"))
expect_true(readGiottoInstructions(gobject, param = "save_plot"))
test_that("change GiottoInstructions changes instruction params in object", {
expect_false(instructions(gobject, param = "show_plot"))
expect_true(instructions(gobject, param = "save_plot"))
})

# replaceGiottoInstructions
gobject <- replaceGiottoInstructions(gobject, instrs)
# replace GiottoInstructions
instructions(gobject) <- instrs

test_that("replaceGiottoInstructions returns object instructions to original", {
expect_true(readGiottoInstructions(gobject, param = "show_plot"))
expect_false(readGiottoInstructions(gobject, param = "save_plot"))
test_that("instructions returns object instructions to original", {
expect_true(instructions(gobject, param = "show_plot"))
expect_false(instructions(gobject, param = "save_plot"))
})
5 changes: 1 addition & 4 deletions tests/testthat/test-interoperability.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ giotto_obj <- GiottoData::loadGiottoMini("visium")
seurat_obj <- giottoToSeuratV5(giotto_obj)
spe_obj <- giottoToSpatialExperiment(giotto_obj)

Seurat_obj2 <- SeuratData::LoadData("stxBrain", type = "anterior1" )
giotto_obj2 <- seuratToGiottoV5(Seurat_obj2)

giotto_obj_roundtrip <- seuratToGiottoV5(seurat_obj, "rna")

test_that("giottotoseurat function handles basic conversion", {
Expand Down Expand Up @@ -66,4 +63,4 @@ test_that("Giotto to SpatialExperiment Conversion Works",{

#TODO
#spe
#annData
#annData
17 changes: 17 additions & 0 deletions tests/testthat/test-save_load.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,20 @@ test_that("gobject an be ovewritten and loaded - qs", {

expect_true(methods::validObject(g3))
})

test_that("gobject can be saved and loaded - RDS", {
rlang::local_options(lifecycle_verbosity = "quiet")
saveGiotto(g, dir = test, overwrite = TRUE, verbose = FALSE)
g2 <<- loadGiotto(file.path(test, "saveGiottoDir"))

expect_true(methods::validObject(g2))
})

test_that("gobject an be ovewritten and loaded - RDS", {
rlang::local_options(lifecycle_verbosity = "quiet")
saveGiotto(g2, dir = test, overwrite = TRUE, verbose = FALSE)
g3 <- loadGiotto(file.path(test, "saveGiottoDir"))

expect_true(methods::validObject(g3))
})

0 comments on commit c0cca85

Please sign in to comment.