Skip to content
This repository was archived by the owner on Oct 14, 2025. It is now read-only.

Commit d48a132

Browse files
authored
Merge pull request #58 from stemangiola/r-cmd-check
R CMD check
2 parents 15d5831 + 8dbfa92 commit d48a132

File tree

5 files changed

+44
-27
lines changed

5 files changed

+44
-27
lines changed

.Rbuildignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
^.*\.Rproj$
22
^\.Rproj\.user$
3-
^dev*
3+
^dev
44
^\.github$
55
^LICENSE\.md$
66
^README\.Rmd$
77
^doc$
88
^Meta$
99
makeflow*
10-
dev/makeflow*

DESCRIPTION

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ Type: Package
22
Package: CuratedAtlasQueryR
33
Title: Queries the Human Cell Atlas
44
Version: 0.1.0
5-
Authors@R: c(person("Stefano", "Mangiola", email = "[email protected]",
6-
role = c("aut", "cre"))
7-
)
5+
Authors@R: c(
6+
person(
7+
"Stefano",
8+
"Mangiola",
9+
email = "[email protected]",
10+
role = c("aut", "cre")
11+
))
812
Description: Provides access to a copy of the Human Cell Atlas, but with
913
harmonised metadata. This allows for uniform querying across numerous
1014
datasets within the Atlas using common fields such as cell type, tissue
@@ -13,8 +17,7 @@ Description: Provides access to a copy of the Human Cell Atlas, but with
1317
into a SingleCellExperiment object.
1418
License: GPL-3
1519
Depends:
16-
R (>= 4.2.0),
17-
dbplyr (>= 2.3.0)
20+
R (>= 4.2.0)
1821
Imports:
1922
dplyr,
2023
SummarizedExperiment,
@@ -33,7 +36,11 @@ Imports:
3336
methods,
3437
rlang,
3538
stats,
36-
RSQLite
39+
RSQLite,
40+
S4Vectors,
41+
tibble,
42+
utils,
43+
dbplyr (>= 2.3.0)
3744
Suggests:
3845
here,
3946
stringr,
@@ -45,7 +52,6 @@ Suggests:
4552
cellxgenedp,
4653
celldex,
4754
SingleR,
48-
tools,
4955
rmarkdown,
5056
knitr,
5157
testthat,

NAMESPACE

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ S3method(as.sparse,DelayedMatrix)
44
export(get_SingleCellExperiment)
55
export(get_metadata)
66
export(get_seurat)
7-
importClassesFrom(SingleCellExperiment,SingleCellExperiment)
7+
import(Seurat)
8+
import(dbplyr)
89
importFrom(BiocGenerics,cbind)
910
importFrom(DBI,dbConnect)
1011
importFrom(HDF5Array,HDF5RealizationSink)
1112
importFrom(HDF5Array,loadHDF5SummarizedExperiment)
1213
importFrom(RSQLite,SQLITE_RO)
1314
importFrom(RSQLite,SQLite)
1415
importFrom(S4Vectors,DataFrame)
15-
importFrom(Seurat,as.Seurat)
16+
importFrom(SeuratObject,as.Seurat)
1617
importFrom(SeuratObject,as.sparse)
1718
importFrom(SingleCellExperiment,SingleCellExperiment)
1819
importFrom(SingleCellExperiment,simplifyToSCE)
@@ -53,3 +54,6 @@ importFrom(rlang,.data)
5354
importFrom(stats,setNames)
5455
importFrom(tibble,column_to_rownames)
5556
importFrom(tools,R_user_dir)
57+
importFrom(utils,head)
58+
importFrom(utils,packageName)
59+
importFrom(utils,untar)

R/query.R

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1+
# These are hacks to force the above packages to be loaded, and also to
2+
# satisfy R CMD check. We don't need to attach them at all.
3+
#' @import dbplyr
4+
#' @import Seurat
5+
NULL
6+
17
# Maps user provided assay names to their corresponding paths in the repository
28
assay_map <- c(
39
counts = "original",
410
cpm = "cpm"
511
)
612

7-
# ' Used in a pipeline to run one or more expressions with side effects, but
8-
# ' return the input value as the output value unaffected
13+
#' Used in a pipeline to run one or more expressions with side effects, but
14+
#' return the input value as the output value unaffected
915
aside <- function(x, ...) {
1016
# Courtesy of Hadley: https://fosstodon.org/@hadleywickham/109558265769090930
1117
list(...)
@@ -120,7 +126,7 @@ get_SingleCellExperiment <- function(
120126
)
121127

122128
raw_data |>
123-
dplyr::group_by(file_id_db) |>
129+
dplyr::group_by(.data$file_id_db) |>
124130
# Load each file and attach metadata
125131
dplyr::summarise(sces = list(group_to_sce(
126132
dplyr::cur_group_id(),
@@ -146,18 +152,17 @@ get_SingleCellExperiment <- function(
146152

147153
#' Converts a data frame into a single SCE
148154
#'
149-
#' @param prefix Prefix to be added to the column names
155+
#' @param i Suffix to be added to the column names, to make them unique
150156
#' @param df The data frame to be converted
151157
#' @param dir_prefix The path to the single cell experiment, minus the final segment
152158
#' @param features The list of genes/rows of interest
153-
#'
154159
#' @return A SingleCellExperiment object
155160
#' @importFrom dplyr mutate
156161
#' @importFrom HDF5Array loadHDF5SummarizedExperiment
157162
#' @importFrom SummarizedExperiment colData<-
158163
#' @importFrom tibble column_to_rownames
159-
#' @importClassesFrom SingleCellExperiment SingleCellExperiment
160-
#'
164+
#' @importFrom utils head
165+
#' @noRd
161166
group_to_sce <- function(i, df, dir_prefix, features) {
162167
sce_path <- df$file_id_db |>
163168
head(1) |>
@@ -183,7 +188,7 @@ group_to_sce <- function(i, df, dir_prefix, features) {
183188
# variable
184189
new_cellnames <- paste0(cells, "_", i)
185190
new_coldata <- df |>
186-
mutate(original_cell_id = .cell, .cell = new_cellnames) |>
191+
mutate(original_cell_id = .data$.cell, .cell = new_cellnames) |>
187192
column_to_rownames(".cell") |>
188193
as("DataFrame")
189194

@@ -300,18 +305,20 @@ sync_remote_file <- function(full_url, output_file, ...) {
300305
#'
301306
#' @return A length one character vector.
302307
#' @importFrom tools R_user_dir
308+
#' @importFrom utils packageName
303309
#' @noRd
304310
#'
305311
get_default_cache_dir <- function() {
306312
packageName() |>
307313
R_user_dir(
308314
"cache"
309-
)
315+
) |>
316+
normalizePath()
310317
}
311318

312-
#' @importFrom SeuratObject as.sparse
313319
#' @importFrom assertthat assert_that
314320
#' @importFrom methods as
321+
#' @importFrom SeuratObject as.sparse
315322
#' @exportS3Method
316323
as.sparse.DelayedMatrix <- function(x) {
317324
# This is glue to ensure the SCE -> Seurat conversion works properly with
@@ -323,7 +330,7 @@ as.sparse.DelayedMatrix <- function(x) {
323330
#' the samples in that data frame
324331
#'
325332
#' @inheritDotParams get_SingleCellExperiment
326-
#' @importFrom Seurat as.Seurat
333+
#' @importFrom SeuratObject as.Seurat
327334
#' @export
328335
#' @return A Seurat object containing the same data as a call to
329336
#' get_SingleCellExperiment.
@@ -365,7 +372,7 @@ get_seurat <- function(...) {
365372
#' @importFrom dplyr tbl
366373
#' @importFrom httr progress
367374
#' @importFrom cli cli_alert_info
368-
#'
375+
#' @importFrom utils untar
369376
get_metadata <- function(
370377
remote_url = "https://object-store.rc.nectar.org.au/v1/AUTH_06d6e008e3e642da99d806ba3ea629c5/metadata-sqlite/metadata.tar.xz",
371378
cache_directory = get_default_cache_dir()

tests/testthat/test-query.R

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ test_that("get_default_cache_dir() returns the correct directory on Linux", {
1919
grepl("linux", version$platform, fixed = TRUE) |>
2020
skip_if_not()
2121

22-
expect_equal(
23-
get_default_cache_dir(),
24-
"~/.cache/hca_harmonised"
25-
)
22+
"~/.cache/R/CuratedAtlasQueryR" |>
23+
normalizePath() |>
24+
expect_equal(
25+
get_default_cache_dir(),
26+
)
2627
})
2728

2829
test_that("sync_assay_files() syncs appropriate files", {

0 commit comments

Comments
 (0)