HCAMatrixBrowser Quick Start

Installation

HCAMatrixBrowser and HCABrowser

First install the HCABrowser to be able to query for bundle_fqid identifiers.

if (!requireNamespace("BiocManager", quietly = TRUE)
    install.packages("BiocManager")

BiocManager::install("HCABrowser")
BiocManager::install("HCAMatrixBrowser")

Load packages:

library(HCABrowser)
library(HCAMatrixBrowser)

Constructing a query using the HCABrowser

Warning. HCABrowser queries under construction.

hcabrowser <- HCABrowser::HCABrowser()

res <- hcabrowser %>% filter(
    library_construction_approach.ontology == "EFO:0008931" &
    paired_end == True &
    specimen_from_organism_json.biomaterial_core.ncbi_taxon_id == 9606
)

(bundle_fqids <- res %>% pullBundles)

Alternatively, we can provide our own bundle identifiers as a character vector:

bundle_fqids <-
    c("ffd3bc7b-8f3b-4f97-aa2a-78f9bac93775.2019-05-14T122736.345000Z",
    "f69b288c-fabc-4ac8-b50c-7abcae3731bc.2019-05-14T120110.781000Z",
    "f8ba80a9-71b1-4c15-bcfc-c05a50660898.2019-05-14T122536.545000Z",
    "fd202a54-7085-406d-a92a-aad6dd2d3ef0.2019-05-14T121656.910000Z",
    "fffe55c1-18ed-401b-aa9a-6f64d0b93fec.2019-05-17T233932.932000Z")

Downloading HCA expression matrix data

First, we create an HCA Matrix API object with the use of the HCAMatrix function:

hca <- HCAMatrix()

v0 Service (legacy)

By default, the loadHCAMatrix function from HCAMatrixBrowser uses the loom format as output. See the 'Supported formats' section below for more details.

(lex <- loadHCAMatrix(hca, bundle_fqids = bundle_fqids,
    format = "loom"))
head(colnames(lex))

v1 Service

The newer v1 matrix service allows users to apply filters to the matrix requests. This is convenient for narrowing down the data to a set of features.

Filters can be created using the API object and the filter function:

hca1 <- filter(hca, bundle_uuid == "ffd3bc7b-8f3b-4f97-aa2a-78f9bac93775")

We can have a look at the created filters using the filters function on the API object:

filters(hca1)

To request the download, we can use the loadHCAMatrix function as well:

Note. Now the bundle_fqids argument is left empty.

loadHCAMatrix(hca1, format = "loom")

Supported formats

The matrix service allows you to request three different file formats:

  1. loom (default)
  2. mtx
  3. csv

These can be requested by changing the format argument in the loadHCAMatrix function. For more details, see our "Generating HCAMatrix queries with the API" vignette.

filter operations

Recent changes to the HCAMatrixBrowser package, allow us to make use of the built-in API functionality. We can use one or more filters to specify a particular query in the HCAMatrix API.

In this example, we use the existing bundle_fqids character vector to generate a filter and apply it to the API class object (hca).

hca2 <- filter(hca, dss_bundle_fqid %in% bundle_fqids)

filters

We use the filters function to get a view of the applied filters.

filters(hca2)

For more information on filters, see the HCAMatrix vignette titled 'Generating HCAMatrix queries with the API'.

Sending the query

Once we have prepared the appropriate filters, we can send the query off to the HCA Matrix Service to get generate a response.

Note. We don't need to do much more than supplying the HCA API object and a particular data format (default is loom).

loadHCAMatrix(hca2)


Try the HCAMatrixBrowser package in your browser

Any scripts or data that you put into this service are public.

HCAMatrixBrowser documentation built on Nov. 8, 2020, 5:15 p.m.