@@ -22,6 +22,18 @@ COUNTS_URL <- single_line_str(
2222# ' version is released
2323COUNTS_VERSION <- " 0.2.1"
2424
25+ # ' @inherit get_single_cell_experiment
26+ # ' @inheritDotParams get_single_cell_experiment
27+ # ' @importFrom cli cli_alert_warning
28+ # ' @export
29+ get_SingleCellExperiment <- function (... ){
30+ single_line_str(" This function name is deprecated.
31+ Please use `get_single_cell_experiment()` instead" ) | >
32+ cli_alert_warning()
33+
34+ get_single_cell_experiment(... )
35+ }
36+
2537# ' Gets a SingleCellExperiment from curated metadata
2638# '
2739# ' Given a data frame of Curated Atlas metadata obtained from [get_metadata()],
@@ -46,7 +58,7 @@ COUNTS_VERSION <- "0.2.1"
4658# ' assays argument
4759# ' @examples
4860# ' meta <- get_metadata() |> head(2)
49- # ' sce <- get_SingleCellExperiment (meta)
61+ # ' sce <- get_single_cell_experiment (meta)
5062# '
5163# ' @importFrom dplyr pull filter as_tibble inner_join collect
5264# ' @importFrom tibble column_to_rownames
@@ -64,34 +76,39 @@ COUNTS_VERSION <- "0.2.1"
6476# ' @importFrom stats setNames
6577# ' @importFrom S4Vectors DataFrame
6678# ' @export
67- get_SingleCellExperiment <- function (
79+ get_single_cell_experiment <- function (
6880 data ,
6981 assays = " counts" ,
7082 cache_directory = get_default_cache_dir(),
7183 repository = COUNTS_URL ,
7284 features = NULL
7385) {
7486 # Parameter validation
87+
7588 assays %in% names(assay_map ) | >
7689 all() | >
7790 assert_that(
7891 msg = ' assays must be a character vector containing "counts" and/or
79- "cpm"'
92+ "cpm"'
8093 )
81- (! anyDuplicated(assays )) | > assert_that()
82- inherits(cache_directory , " character" ) | > assert_that()
83- is.null(repository ) || is.character(repository ) | > assert_that()
84- is.null(features ) || is.character(features ) | > assert_that()
94+ assert_that(
95+ ! anyDuplicated(assays ),
96+ inherits(cache_directory , " character" ),
97+ is.null(repository ) || is.character(repository ),
98+ is.null(features ) || is.character(features )
99+ )
85100
86101 # Data parameter validation (last, because it's slower)
87102 # # Evaluate the promise now so that we get a sensible error message
88- data
103+ force( data )
89104 # # We have to convert to an in-memory table here, or some of the dplyr
90105 # # operations will fail when passed a database connection
91106 cli_alert_info(" Realising metadata." )
92107 raw_data <- collect(data )
93- inherits(raw_data , " tbl" ) | > assert_that()
94- has_name(raw_data , c(" cell_" , " file_id_db" )) | > assert_that()
108+ assert_that(
109+ inherits(raw_data , " tbl" ),
110+ has_name(raw_data , c(" cell_" , " file_id_db" ))
111+ )
95112
96113 versioned_cache_directory <- file.path(cache_directory , COUNTS_VERSION )
97114 versioned_cache_directory | > dir.create(
@@ -182,10 +199,10 @@ group_to_sce <- function(i, df, dir_prefix, features) {
182199
183200 file.exists(sce_path ) | >
184201 assert_that(
185- msg = " Your cache does not contain a file you
202+ msg = " Your cache does not contain a file {sce_path} you
186203 attempted to query. Please provide the repository
187204 parameter so that files can be synchronised from the
188- internet"
205+ internet" | > glue()
189206 )
190207
191208 sce <- loadHDF5SummarizedExperiment(sce_path )
@@ -194,11 +211,12 @@ group_to_sce <- function(i, df, dir_prefix, features) {
194211 cells <- colnames(sce ) | > intersect(df $ cell_ )
195212
196213 if (length(cells ) < nrow(df )){
197- str_replace_all(
198- " Some cells were filtered out because of extremely low counts. The
214+ single_line_str(
215+ " Some cells were filtered out while loading {head(df$file_id_db, 1)}
216+ because of extremely low counts. The
199217 number of cells in the SingleCellExperiment will be less than the
200218 number of cells you have selected from the metadata."
201- )
219+ ) | > cli_alert_warning()
202220 df <- filter(df , .data $ cell_ %in% cells )
203221 }
204222 else if (length(cells ) > nrow(df )){
0 commit comments