From 63bfda1635cdc367cfdb60c8691661c05a10c5ab Mon Sep 17 00:00:00 2001 From: kollo97 Date: Wed, 8 Jan 2025 15:03:32 +0100 Subject: [PATCH] pass BiocCheck again --- .Rbuildignore | 2 +- R/example.R | 25 +++++++++++++------------ R/objects.R | 1 + man/dot-get_meta_data.Rd | 12 ------------ man/sce_example.Rd | 2 +- 5 files changed, 16 insertions(+), 26 deletions(-) delete mode 100644 man/dot-get_meta_data.Rd diff --git a/.Rbuildignore b/.Rbuildignore index b751679..a6efef0 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -16,4 +16,4 @@ ^doc$ ^Meta$ ^codecov\.yml$ -^.vscode \ No newline at end of file +^.vscode diff --git a/R/example.R b/R/example.R index df7b027..eba1df1 100644 --- a/R/example.R +++ b/R/example.R @@ -8,25 +8,26 @@ #' @importFrom SingleCellExperiment SingleCellExperiment #' @importFrom stats rpois #' @importFrom S4Vectors DataFrame +#' @importFrom withr with_seed #' @return A SingleCellExperiment object #' @examples #' sce <- sce_example() #' sce #' @export -sce_example <- function(){ - # Set seed for reproducibility (optional) - set.seed(42) +sce_example <- function(seed = 42){ # generate example data with two "batches" - counts_mat <- cbind( - matrix(rpois(300 * 300, lambda = 5), - nrow = 300, - dimnames = list(paste0("gene", 1:300), paste0("cell", 1:300)) - ), - matrix(rpois(300 * 300, lambda = 3), - nrow = 300, - dimnames = list(paste0("gene", 1:300), paste0("cell", 301:600)) + withr::with_seed(seed, { + counts_mat <- cbind( + matrix(rpois(300 * 300, lambda = 5), + nrow = 300, + dimnames = list(paste0("gene", 1:300), paste0("cell", 1:300)) + ), + matrix(rpois(300 * 300, lambda = 3), + nrow = 300, + dimnames = list(paste0("gene", 1:300), paste0("cell", 301:600)) + ) ) - ) + }) # add metadata batch <- rep(c("batch1", "batch2"), each = 300) dataset <- rep(c("dataset1", "dataset2", "dataset1", "dataset2"), each = 150) diff --git a/R/objects.R b/R/objects.R index f6d544e..8ed48d1 100644 --- a/R/objects.R +++ b/R/objects.R @@ -561,6 +561,7 @@ setGeneric( #' @import checkmate #' @importFrom SingleCellExperiment colData #' @keywords internal +#' @noRd .get_meta_data <- function(object) { if (checkmate::test_class(object, "Seurat")) { return(object[[]]) diff --git a/man/dot-get_meta_data.Rd b/man/dot-get_meta_data.Rd deleted file mode 100644 index f8780dd..0000000 --- a/man/dot-get_meta_data.Rd +++ /dev/null @@ -1,12 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/objects.R -\name{.get_meta_data} -\alias{.get_meta_data} -\title{Internal helper function to get metadata from a Seurat or SCE object} -\usage{ -.get_meta_data(object) -} -\description{ -Internal helper function to get metadata from a Seurat or SCE object -} -\keyword{internal} diff --git a/man/sce_example.Rd b/man/sce_example.Rd index 858c61f..c4e46a0 100644 --- a/man/sce_example.Rd +++ b/man/sce_example.Rd @@ -4,7 +4,7 @@ \alias{sce_example} \title{Generate example SingleCellExperiment object} \usage{ -sce_example() +sce_example(seed = 42) } \value{ A SingleCellExperiment object