knitr::opts_chunk$set(
  collapse = TRUE
)
library(dplyr)
library(LoomExperiment)
library(hca)
library(hcaquery)

Introduction

This package, in conjunction with the hca package, allows for exploration of the Human Cell Atlas' data, made available by their API.

Setup

A core functionality of this packages is the generation of relational database tables containing data from .loom and .h5ad files. This vignette makes use of a dockerized PostgreSQL database (see /inst/docker/docker-compose.yaml for details) Some helpful commandline aliases for working with the database:

alias hcadbup='docker-compose -f ./inst/docker/docker-compose.yaml up -d && docker-compose -f ./inst/docker/docker-compose.yaml logs -f'
alias hcadbdownv='docker-compose -f ./inst/docker/docker-compose.yaml down -v'

remember to delete the persistent data in inst/docker/postgres-data should you wish to clear the database

alias hcadb='docker exec -ti bioc-hca-db psql -U hca_user bioc_hca'

Credentials Management

The database user must provide a username and password for connecting to the database, with the package first checking to see if the appropriate environment variables HCA_USER and HCA_PASSWORDare set in .Renviron (or your .Renviron of choice). If using the provided docker-compose.yaml, ensure that the values match those of the file. If the environment variables are not, the user will be prompted to input them manually.

Example 1: Loading files into a database

Focusing on the two smallest files generated by the Optimus v4.2.2 pipeline

test_file_filter <- hca::filters(workflow = list(is = c("optimus_v4.2.2")),
                                 fileFormat = list(is = c("loom", "h5ad")))
test_file_tbl <- hca::files(filters = test_file_filter,
                            size = 2, sort = "fileSize", order = "asc")

files_to_db(test_file_tbl)

Example 2: Querying the database for specific genes

genes <- c("Gm18956", "Gm37180", "Gm37363")
smat <- hca_file_gene_query(genes = genes,
                            file_ident = "b077b456-6362-59ea-a5b6-230dd8bc6d91")

smat

Session info

sessionInfo()


Bioconductor/hcaquery documentation built on Dec. 17, 2021, 10:56 a.m.