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

Commit 56a635d

Browse files
authored
Merge pull request #40 from stemangiola/nectar
Move to Nectar backend
2 parents 34e6900 + 22a2fae commit 56a635d

File tree

6 files changed

+93
-93
lines changed

6 files changed

+93
-93
lines changed

DESCRIPTION

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ Imports:
3232
Seurat,
3333
methods,
3434
rlang,
35-
stats
35+
stats,
36+
RPostgres
3637
Suggests:
3738
here,
3839
stringr,
@@ -46,9 +47,9 @@ Suggests:
4647
SingleR,
4748
tools,
4849
rmarkdown,
49-
dbplyr,
5050
knitr,
51-
testthat
51+
testthat,
52+
dbplyr (>= 2.3.0)
5253
Biarch: true
5354
biocViews:
5455
AssayDomain,

NAMESPACE

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ importFrom(BiocGenerics,cbind)
99
importFrom(DBI,dbConnect)
1010
importFrom(HDF5Array,HDF5RealizationSink)
1111
importFrom(HDF5Array,loadHDF5SummarizedExperiment)
12-
importFrom(RSQLite,SQLITE_RO)
13-
importFrom(RSQLite,SQLite)
12+
importFrom(RPostgres,Postgres)
1413
importFrom(S4Vectors,DataFrame)
1514
importFrom(Seurat,as.Seurat)
1615
importFrom(SeuratObject,as.sparse)
@@ -38,7 +37,6 @@ importFrom(glue,glue)
3837
importFrom(httr,GET)
3938
importFrom(httr,modify_url)
4039
importFrom(httr,parse_url)
41-
importFrom(httr,progress)
4240
importFrom(httr,stop_for_status)
4341
importFrom(httr,write_disk)
4442
importFrom(methods,as)

R/query.R

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ aside <- function(x, ...) {
1212
x
1313
}
1414

15-
REMOTE_URL <- "https://harmonised-human-atlas.s3.amazonaws.com/"
15+
REMOTE_URL <- "https://swift.rc.nectar.org.au/v1/AUTH_06d6e008e3e642da99d806ba3ea629c5/harmonised-human-atlas"
1616

1717
#' Given a data frame of HCA metadata, returns a SingleCellExperiment object
1818
#' corresponding to the samples in that data frame
@@ -339,11 +339,9 @@ get_seurat <- function(...) {
339339
#' Returns a data frame of Human Cell Atlas metadata, which should be filtered
340340
#' and ultimately passed into get_SingleCellExperiment.
341341
#'
342-
#' @param repository Optional character vector of length 1. An HTTP URL pointing
343-
#' to the location of the sqlite database.
344-
#' @param cache_directory Optional character vector of length 1. A file path on
345-
#' your local system to a directory (not a file) that will be used to store
346-
#' metadata.sqlite
342+
#' @param connection Optional list of postgres connection parameters used to
343+
#' connect to the metadata database. Possible parameters are described here:
344+
#' https://rpostgres.r-dbi.org/reference/postgres.
347345
#' @return A lazy data.frame subclass containing the metadata. You can interact
348346
#' with this object using most standard dplyr functions. However, it is
349347
#' recommended that you use the %LIKE% operator for string matching, as most
@@ -360,21 +358,21 @@ get_seurat <- function(...) {
360358
#' )
361359
#'
362360
#' @importFrom DBI dbConnect
363-
#' @importFrom RSQLite SQLite SQLITE_RO
361+
#' @importFrom RPostgres Postgres
364362
#' @importFrom dplyr tbl
365-
#' @importFrom httr progress
366363
#'
367364
get_metadata <- function(
368-
repository = "https://harmonised-human-atlas.s3.amazonaws.com/metadata.sqlite",
369-
cache_directory = get_default_cache_dir()
370-
) {
371-
sqlite_path <- file.path(cache_directory, "metadata.sqlite")
372-
sync_remote_file(
373-
repository,
374-
sqlite_path,
375-
progress(type = "down", con = stderr())
365+
connection = list(
366+
dbname="metadata",
367+
host="zki3lfhznsa.db.cloud.edu.au",
368+
port="5432",
369+
password="password",
370+
user="public_access"
376371
)
377-
SQLite() |>
378-
dbConnect(drv = _, dbname = sqlite_path, flags = SQLITE_RO) |>
372+
) {
373+
Postgres() |>
374+
list(drv=_) |>
375+
c(connection) |>
376+
do.call(dbConnect, args=_) |>
379377
tbl("metadata")
380378
}

man/get_metadata.Rd

Lines changed: 5 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

readme.md

Lines changed: 54 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Load the metadata
1313
``` r
1414
get_metadata()
1515
#> # Source: table<metadata> [?? x 56]
16-
#> # Database: sqlite 3.40.0 [/vast/scratch/users/milton.m/cache/hca_harmonised/metadata.sqlite]
16+
#> # Database: postgres [[email protected]:5432/metadata]
1717
#> .cell sampl…¹ .sample .samp…² assay assay…³ file_…⁴ cell_…⁵ cell_…⁶ devel…⁷ devel…⁸ disease disea…⁹ ethni…˟ ethni…˟ file_id is_pr…˟ organ…˟ organ…˟ sampl…˟ sex sex_o…˟ tissue
1818
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
1919
#> 1 AAACCT… 8a0fe0… 5f20d7… D17PrP… 10x … EFO:00… 1e334b… basal … CL:000… 31-yea… HsapDv… normal PATO:0… Europe… HANCES… 00d626… FALSE Homo s… NCBITa… <NA> male PATO:0… perip…
@@ -43,33 +43,34 @@ get_metadata() |>
4343
count(tissue) |>
4444
arrange(desc(n))
4545
#> # Source: SQL [?? x 2]
46-
#> # Database: sqlite 3.40.0 [/vast/scratch/users/milton.m/cache/hca_harmonised/metadata.sqlite]
46+
#> # Database: postgres [[email protected]:5432/metadata]
4747
#> # Ordered by: desc(n)
48-
#> tissue n
49-
#> <chr> <int>
50-
#> 1 blood 47
51-
#> 2 heart left ventricle 46
52-
#> 3 cortex of kidney 31
53-
#> 4 renal medulla 29
54-
#> 5 lung 27
55-
#> 6 middle temporal gyrus 24
56-
#> 7 liver 24
57-
#> 8 kidney 19
58-
#> 9 intestine 18
59-
#> 10 thymus 17
48+
#> tissue n
49+
#> <chr> <int64>
50+
#> 1 blood 47
51+
#> 2 heart left ventricle 46
52+
#> 3 cortex of kidney 31
53+
#> 4 renal medulla 29
54+
#> 5 lung 27
55+
#> 6 liver 24
56+
#> 7 middle temporal gyrus 24
57+
#> 8 kidney 19
58+
#> 9 intestine 18
59+
#> 10 thymus 17
6060
#> # … with more rows
6161
```
6262

6363
Query raw counts
6464

6565
``` r
66+
library(stringr)
6667
sce <-
6768
get_metadata() |>
6869
filter(
6970
ethnicity == "African" &
70-
assay %LIKE% "%10x%" &
71-
tissue == "lung parenchyma" &
72-
cell_type %LIKE% "%CD4%"
71+
str_like(assay, "%10x%") &
72+
tissue == "lung parenchyma" &
73+
str_like(cell_type, "%CD4%")
7374
) |>
7475
get_SingleCellExperiment()
7576
#> ℹ Realising metadata.
@@ -99,9 +100,9 @@ sce <-
99100
get_metadata() |>
100101
filter(
101102
ethnicity == "African" &
102-
assay %LIKE% "%10x%" &
103-
tissue == "lung parenchyma" &
104-
cell_type %LIKE% "%CD4%"
103+
str_like(assay, "%10x%") &
104+
tissue == "lung parenchyma" &
105+
str_like(cell_type, "%CD4%")
105106
) |>
106107
get_SingleCellExperiment(assays = "cpm")
107108
#> ℹ Realising metadata.
@@ -129,9 +130,9 @@ Extract only a subset of genes:
129130
get_metadata() |>
130131
filter(
131132
ethnicity == "African" &
132-
assay %LIKE% "%10x%" &
133-
tissue == "lung parenchyma" &
134-
cell_type %LIKE% "%CD4%"
133+
str_like(assay, "%10x%") &
134+
tissue == "lung parenchyma" &
135+
str_like(cell_type, "%CD4%")
135136
) |>
136137
get_SingleCellExperiment(features = "PUM1")
137138
#> ℹ Realising metadata.
@@ -157,9 +158,9 @@ Extract the counts as a Seurat object:
157158
get_metadata() |>
158159
filter(
159160
ethnicity == "African" &
160-
assay %LIKE% "%10x%" &
161-
tissue == "lung parenchyma" &
162-
cell_type %LIKE% "%CD4%"
161+
str_like(assay, "%10x%") &
162+
tissue == "lung parenchyma" &
163+
str_like(cell_type, "%CD4%")
163164
) |>
164165
get_seurat()
165166
#> ℹ Realising metadata.
@@ -190,30 +191,34 @@ sessionInfo()
190191
#> [1] stats graphics grDevices utils datasets methods base
191192
#>
192193
#> other attached packages:
193-
#> [1] dplyr_1.0.10 HCAquery_0.1.0
194+
#> [1] stringr_1.5.0 dplyr_1.0.10 HCAquery_0.1.0 testthat_3.1.6 RPostgres_1.4.4
194195
#>
195196
#> loaded via a namespace (and not attached):
196197
#> [1] plyr_1.8.8 igraph_1.3.5 lazyeval_0.2.2 sp_1.5-1 splines_4.2.1 listenv_0.9.0
197-
#> [7] scattermore_0.8 GenomeInfoDb_1.32.4 ggplot2_3.4.0 digest_0.6.31 htmltools_0.5.4 fansi_1.0.3
198-
#> [13] magrittr_2.0.3 memoise_2.0.1 tensor_1.5 cluster_2.1.3 ROCR_1.0-11 globals_0.16.2
199-
#> [19] matrixStats_0.63.0 spatstat.sparse_3.0-0 colorspace_2.0-3 blob_1.2.3 rappdirs_0.3.3 ggrepel_0.9.2
200-
#> [25] xfun_0.36 RCurl_1.98-1.9 jsonlite_1.8.4 progressr_0.12.0 spatstat.data_3.0-0 survival_3.3-1
201-
#> [31] zoo_1.8-11 glue_1.6.2 polyclip_1.10-4 gtable_0.3.1 zlibbioc_1.42.0 XVector_0.36.0
202-
#> [37] leiden_0.4.3 DelayedArray_0.22.0 Rhdf5lib_1.18.2 future.apply_1.10.0 SingleCellExperiment_1.18.1 BiocGenerics_0.42.0
203-
#> [43] HDF5Array_1.24.2 abind_1.4-5 scales_1.2.1 DBI_1.1.3 spatstat.random_3.0-1 miniUI_0.1.1.1
204-
#> [49] Rcpp_1.0.9 viridisLite_0.4.1 xtable_1.8-4 reticulate_1.26 bit_4.0.5 stats4_4.2.1
205-
#> [55] htmlwidgets_1.6.0 httr_1.4.4 RColorBrewer_1.1-3 ellipsis_0.3.2 Seurat_4.3.0 ica_1.0-3
206-
#> [61] pkgconfig_2.0.3 uwot_0.1.14 dbplyr_2.2.1 deldir_1.0-6 utf8_1.2.2 tidyselect_1.2.0
207-
#> [67] rlang_1.0.6 reshape2_1.4.4 later_1.3.0 munsell_0.5.0 tools_4.2.1 cachem_1.0.6
208-
#> [73] cli_3.5.0 generics_0.1.3 RSQLite_2.2.20 ggridges_0.5.4 evaluate_0.19 stringr_1.5.0
209-
#> [79] fastmap_1.1.0 yaml_2.3.6 goftest_1.2-3 knitr_1.41 bit64_4.0.5 fitdistrplus_1.1-8
210-
#> [85] purrr_1.0.0 RANN_2.6.1 pbapply_1.6-0 future_1.30.0 nlme_3.1-157 mime_0.12
211-
#> [91] compiler_4.2.1 rstudioapi_0.14 plotly_4.10.1 png_0.1-8 spatstat.utils_3.0-1 tibble_3.1.8
212-
#> [97] stringi_1.7.8 lattice_0.20-45 Matrix_1.5-3 vctrs_0.5.1 pillar_1.8.1 lifecycle_1.0.3
213-
#> [103] rhdf5filters_1.8.0 spatstat.geom_3.0-3 lmtest_0.9-40 RcppAnnoy_0.0.20 data.table_1.14.6 cowplot_1.1.1
214-
#> [109] bitops_1.0-7 irlba_2.3.5.1 httpuv_1.6.7 patchwork_1.1.2 GenomicRanges_1.48.0 R6_2.5.1
215-
#> [115] promises_1.2.0.1 KernSmooth_2.23-20 gridExtra_2.3 IRanges_2.30.1 parallelly_1.33.0 codetools_0.2-18
216-
#> [121] MASS_7.3-57 assertthat_0.2.1 rhdf5_2.40.0 SummarizedExperiment_1.26.1 withr_2.5.0 SeuratObject_4.1.3
217-
#> [127] sctransform_0.3.5 S4Vectors_0.34.0 GenomeInfoDbData_1.2.8 parallel_4.2.1 grid_4.2.1 tidyr_1.2.1
218-
#> [133] rmarkdown_2.19 MatrixGenerics_1.8.1 Rtsne_0.16 spatstat.explore_3.0-5 Biobase_2.56.0 shiny_1.7.4
198+
#> [7] scattermore_0.8 usethis_2.1.6 GenomeInfoDb_1.32.4 ggplot2_3.4.0 digest_0.6.31 htmltools_0.5.4
199+
#> [13] fansi_1.0.3 magrittr_2.0.3 memoise_2.0.1 tensor_1.5 cluster_2.1.3 ROCR_1.0-11
200+
#> [19] remotes_2.4.2 globals_0.16.2 matrixStats_0.63.0 timechange_0.2.0 spatstat.sparse_3.0-0 prettyunits_1.1.1
201+
#> [25] colorspace_2.0-3 blob_1.2.3 rappdirs_0.3.3 ggrepel_0.9.2 xfun_0.36 callr_3.7.3
202+
#> [31] crayon_1.5.2 RCurl_1.98-1.9 jsonlite_1.8.4 roxygen2_7.2.3 progressr_0.12.0 spatstat.data_3.0-0
203+
#> [37] survival_3.3-1 zoo_1.8-11 glue_1.6.2 polyclip_1.10-4 gtable_0.3.1 zlibbioc_1.42.0
204+
#> [43] XVector_0.36.0 leiden_0.4.3 DelayedArray_0.22.0 pkgbuild_1.4.0 Rhdf5lib_1.18.2 future.apply_1.10.0
205+
#> [49] SingleCellExperiment_1.18.1 BiocGenerics_0.42.0 HDF5Array_1.24.2 abind_1.4-5 scales_1.2.1 DBI_1.1.3
206+
#> [55] spatstat.random_3.0-1 miniUI_0.1.1.1 Rcpp_1.0.9 viridisLite_0.4.1 xtable_1.8-4 reticulate_1.26
207+
#> [61] bit_4.0.5 stats4_4.2.1 profvis_0.3.7 htmlwidgets_1.6.0 httr_1.4.4 RColorBrewer_1.1-3
208+
#> [67] ellipsis_0.3.2 Seurat_4.3.0 ica_1.0-3 urlchecker_1.0.1 pkgconfig_2.0.3 dbplyr_2.3.0
209+
#> [73] uwot_0.1.14 deldir_1.0-6 utf8_1.2.2 tidyselect_1.2.0 rlang_1.0.6 reshape2_1.4.4
210+
#> [79] later_1.3.0 munsell_0.5.0 tools_4.2.1 cachem_1.0.6 cli_3.5.0 generics_0.1.3
211+
#> [85] RSQLite_2.2.20 devtools_2.4.5 ggridges_0.5.4 evaluate_0.19 fastmap_1.1.0 yaml_2.3.6
212+
#> [91] goftest_1.2-3 knitr_1.41 processx_3.8.0 bit64_4.0.5 fs_1.5.2 fitdistrplus_1.1-8
213+
#> [97] purrr_1.0.1 RANN_2.6.1 nlme_3.1-157 pbapply_1.6-0 future_1.30.0 mime_0.12
214+
#> [103] xml2_1.3.3 brio_1.1.3 compiler_4.2.1 rstudioapi_0.14 plotly_4.10.1 png_0.1-8
215+
#> [109] spatstat.utils_3.0-1 tibble_3.1.8 stringi_1.7.8 ps_1.7.2 desc_1.4.2 lattice_0.20-45
216+
#> [115] Matrix_1.5-3 vctrs_0.5.1 pillar_1.8.1 lifecycle_1.0.3 rhdf5filters_1.8.0 spatstat.geom_3.0-3
217+
#> [121] lmtest_0.9-40 RcppAnnoy_0.0.20 data.table_1.14.6 cowplot_1.1.1 bitops_1.0-7 irlba_2.3.5.1
218+
#> [127] httpuv_1.6.7 patchwork_1.1.2 GenomicRanges_1.48.0 R6_2.5.1 promises_1.2.0.1 KernSmooth_2.23-20
219+
#> [133] gridExtra_2.3 IRanges_2.30.1 parallelly_1.33.0 sessioninfo_1.2.2 codetools_0.2-18 MASS_7.3-57
220+
#> [139] assertthat_0.2.1 pkgload_1.3.2 rhdf5_2.40.0 SummarizedExperiment_1.26.1 rprojroot_2.0.3 withr_2.5.0
221+
#> [145] SeuratObject_4.1.3 sctransform_0.3.5 S4Vectors_0.34.0 GenomeInfoDbData_1.2.8 parallel_4.2.1 hms_1.1.2
222+
#> [151] grid_4.2.1 tidyr_1.2.1 rmarkdown_2.19 MatrixGenerics_1.8.1 Rtsne_0.16 spatstat.explore_3.0-5
223+
#> [157] lubridate_1.9.0 Biobase_2.56.0 shiny_1.7.4
219224
```

vignettes/readme.Rmd

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,14 @@ get_metadata() |>
4242
Query raw counts
4343

4444
```{r}
45+
library(stringr)
4546
sce <-
4647
get_metadata() |>
4748
filter(
4849
ethnicity == "African" &
49-
assay %LIKE% "%10x%" &
50-
tissue == "lung parenchyma" &
51-
cell_type %LIKE% "%CD4%"
50+
str_like(assay, "%10x%") &
51+
tissue == "lung parenchyma" &
52+
str_like(cell_type, "%CD4%")
5253
) |>
5354
get_SingleCellExperiment()
5455
@@ -62,9 +63,9 @@ sce <-
6263
get_metadata() |>
6364
filter(
6465
ethnicity == "African" &
65-
assay %LIKE% "%10x%" &
66-
tissue == "lung parenchyma" &
67-
cell_type %LIKE% "%CD4%"
66+
str_like(assay, "%10x%") &
67+
tissue == "lung parenchyma" &
68+
str_like(cell_type, "%CD4%")
6869
) |>
6970
get_SingleCellExperiment(assays = "cpm")
7071
@@ -77,9 +78,9 @@ Extract only a subset of genes:
7778
get_metadata() |>
7879
filter(
7980
ethnicity == "African" &
80-
assay %LIKE% "%10x%" &
81-
tissue == "lung parenchyma" &
82-
cell_type %LIKE% "%CD4%"
81+
str_like(assay, "%10x%") &
82+
tissue == "lung parenchyma" &
83+
str_like(cell_type, "%CD4%")
8384
) |>
8485
get_SingleCellExperiment(features = "PUM1")
8586
```
@@ -90,9 +91,9 @@ Extract the counts as a Seurat object:
9091
get_metadata() |>
9192
filter(
9293
ethnicity == "African" &
93-
assay %LIKE% "%10x%" &
94-
tissue == "lung parenchyma" &
95-
cell_type %LIKE% "%CD4%"
94+
str_like(assay, "%10x%") &
95+
tissue == "lung parenchyma" &
96+
str_like(cell_type, "%CD4%")
9697
) |>
9798
get_seurat()
9899
```

0 commit comments

Comments
 (0)