ABCatlasR: access to ABC Atlas data in R

Introduction

ABCatlasR provides an R-native, release-aware interface to the Allen Brain Cell (ABC) Atlas [1]. The package connects the Atlas metadata and expression resources to a workflow that is natural for single-cell and spatial analysis in R.

A typical analysis begins with a biological question, uses Atlas metadata to define the relevant cells, and then retrieves the corresponding expression matrix. This approach is useful for questions such as:

  • cell identity and diversity: which neuronal and non-neuronal populations are represented within a brain region or dataset;
  • molecular specialization: how gene-expression profiles differ across cell types, states, or anatomical structures;
  • spatial organization: where molecularly defined populations are located within brain tissue;
  • development, aging, and disease: how cellular composition or molecular states vary across life stages or disease-associated collections;
  • cross-species neuroscience: which cellular and molecular features can be explored across mouse, marmoset, macaque, and human resources.

Package overview

ABCatlasR focuses on discovery, metadata-guided selection, retrieval, and representation of ABC Atlas data in R. It preserves the expression representation published by the Atlas and records the dataset and release used for retrieval. The package does not perform normalization, differential expression, integration, trajectory inference, cell-type prediction, or orthology mapping; those analyses remain downstream choices and can be carried out with Bioconductor or other single-cell analysis frameworks.

The main user-facing functions form a short workflow:

Function Purpose
abc_download_dir() View the directory used to store Atlas files.
list_datasets() List the ABC Atlas routes supported by the installed package.
load_data() Load and assemble cell and gene metadata for one dataset.
plan_fetch() Inspect the expression files and storage associated with a request.
fetch_data() Retrieve expression for selected cells and optionally selected genes.
abc_cache_connect() Open the release-aware cache for lower-level file access.

Most analyses use abc_download_dir(), list_datasets(), load_data(), plan_fetch(), and fetch_data(). abc_cache_connect() is a lower-level interface for users who need direct access to files listed in an ABC Atlas release manifest.

Installation

Install from Bioconductor:

if (!requireNamespace("BiocManager", quietly = TRUE)) {
    install.packages("BiocManager")
}
BiocManager::install("ABCatlasR")

Until the package is available on Bioconductor, the development version can alternatively be installed directly from GitHub:

if (!requireNamespace("remotes", quietly = TRUE)) {
    install.packages("remotes")
}
options(repos = BiocManager::repositories())
remotes::install_github("me37uday/ABCatlasR")

Load the package:

library(ABCatlasR)

HPC installation with Conda/Bioconda

For HPC systems, the repository includes inst/conda/environment-hpc.yml, which defines the R, CRAN, and Bioconductor runtime used by ABCatlasR, including SingleCellExperiment, and SpatialExperiment support.

The following sequence can be used on a new cluster.

Obtain the package source

Before the package is available through Bioconductor, clone the repository and enter the package directory:

git clone https://github.com/me37uday/ABCatlasR.git
cd ABCatlasR

Create the Conda environment from the supplied YAML file

The YAML file is the recommended installation route because it keeps the runtime definition with the package source:

conda env create -f inst/conda/environment-hpc.yml
conda activate abcatlasr

Bioconda recommends using conda-forge and bioconda with strict channel priority. If the cluster has not previously been configured for Bioconda, the equivalent one-time configuration is:

conda config --add channels bioconda
conda config --add channels conda-forge
conda config --set channel_priority strict

Confirm that the active R belongs to the Conda environment

which R
which Rscript
R --version
echo "$CONDA_PREFIX"

which R and which Rscript should resolve inside the active abcatlasr environment.

Install ABCatlasR into the active environment

Because the YAML file already installs the package dependencies, install the checked-out package source without asking R to resolve another dependency stack:

R CMD INSTALL .

Manual environment creation

If the YAML file cannot be used, the same runtime can be created manually:

conda create -n abcatlasr \
    --channel conda-forge \
    --channel bioconda \
    --strict-channel-priority \
    r-base=4.5 \
    r-biocmanager \
    r-remotes \
    r-curl \
    r-data.table \
    r-dplyr \
    r-jsonlite \
    r-matrix \
    r-processx \
    r-xml2 \
    bioconductor-hdf5array \
    bioconductor-rhdf5 \
    bioconductor-s4vectors \
    bioconductor-singlecellexperiment \
    bioconductor-spatialexperiment

conda activate abcatlasr

This Conda environment is intended for running ABCatlasR on HPC systems.

Choosing a dataset

list_datasets() returns the dataset routes supported by the installed version of ABCatlasR. The catalog is included with the package, so it can be inspected without downloading Atlas data.

datasets <- list_datasets()
datasets
#> ABC Atlas datasets: 25 routes (10 spatial, 1 imputed)
#> 
#>  dataset                         modality                        spatial
#>  WHB                             single_nucleus_transcriptomics  no     
#>  WMB                             single_cell_transcriptomics     no     
#>  ConsensusMouseAIBS              single_cell_transcriptomics     no     
#>  ConsensusMouseMacosko           single_nucleus_transcriptomics  no     
#>  DevelopingMouse                 single_cell_transcriptomics     no     
#>  AgingMouse                      single_cell_transcriptomics     no     
#>  HMBA                            single_nucleus_transcriptomics  no     
#>  HMBA_Human                      single_nucleus_transcriptomics  no     
#>  HMBA_Macaque                    single_nucleus_transcriptomics  no     
#>  HMBA_Marmoset                   single_nucleus_transcriptomics  no     
#>  HMBA_PatchSeq                   patch_seq_transcriptomics       no     
#>  HMBA_spatial_Human              spatial_transcriptomics         yes    
#>  HMBA_spatial_Macaque            spatial_transcriptomics         yes    
#>  HMBA_spatial_Marmoset           spatial_transcriptomics         yes    
#>  HMBA_Subcortex_Marmoset         single_nucleus_transcriptomics  no     
#>  HMBA_spatial_Subcortex_Marmoset spatial_transcriptomics         yes    
#>  Zhuang1                         spatial_transcriptomics         yes    
#>  Zhuang2                         spatial_transcriptomics         yes    
#>  Zhuang3                         spatial_transcriptomics         yes    
#>  Zhuang4                         spatial_transcriptomics         yes    
#>  MERFISH                         spatial_transcriptomics         yes    
#>  MERFISH_imputed                 imputed_spatial_transcriptomics yes    
#>  SEAAD_Multiregion               single_nucleus_transcriptomics  no     
#>  SEAAD_CaH                       single_nucleus_transcriptomics  no     
#>  PMDBS                           single_nucleus_transcriptomics  no     
#>  data                   
#>  raw,log2               
#>  raw,log2               
#>  raw,log2               
#>  raw,log2               
#>  raw,log2               
#>  raw,log2               
#>  raw,log2               
#>  raw,log2               
#>  raw,log2               
#>  raw,log2               
#>  log2                   
#>  raw,batch_normalized,ln
#>  raw,batch_normalized,ln
#>  raw,batch_normalized,ln
#>  raw,log2               
#>  raw,batch_normalized,ln
#>  raw,log2               
#>  raw,log2               
#>  raw,log2               
#>  raw,log2               
#>  raw,log2               
#>  log2                   
#>  raw,log2               
#>  raw,log2               
#>  raw,log2

The most useful catalog columns are:

  • dataset: the value passed to load_data();
  • modality: transcriptomic, spatial, or related data modality;
  • spatial: whether spatial coordinates are available;
  • default_data_type: the expression representation used by default;
  • available_data_types: the expression representations that can be requested.

The routes registered for the validated release cover several broad resource groups:

focus routes use
Whole mouse brain transcriptomics WMB, ConsensusMouseAIBS, ConsensusMouseMacosko Cell-type and whole-brain transcriptomic studies
Mouse spatial transcriptomics Zhuang1-Zhuang4, MERFISH, MERFISH_imputed Spatial localization and expression across the mouse brain
Mouse development and aging DevelopingMouse, AgingMouse Developmental and age-associated questions
Whole human brain WHB Human brain cell types across anatomical locations
Human disease and clinical collections SEAAD_Multiregion, SEAAD_CaH, PMDBS Disease, neuropathology, diagnosis, and donor-level questions
Mammalian basal ganglia HMBA, HMBA_Human, HMBA_Macaque, HMBA_Marmoset Human and non-human-primate basal-ganglia studies
Electrophysiology-linked transcriptomics HMBA_PatchSeq Transcriptomic analysis of macaque Patch-seq cells
Mammalian basal-ganglia spatial data HMBA_spatial_Human, HMBA_spatial_Macaque, HMBA_spatial_Marmoset Spatial studies across HMBA species
Marmoset subcortex HMBA_Subcortex_Marmoset, HMBA_spatial_Subcortex_Marmoset Single-nucleus and spatial studies of marmoset subcortex

The whole-mouse-brain transcriptomic and spatial resources provide a high-resolution molecular and anatomical framework for mouse brain cell types [2]. The Zhuang1-Zhuang4 routes provide spatially resolved whole-mouse-brain data and are described in the corresponding spatial atlas publication [3].

For cross-species work, the HMBA human, macaque, and marmoset routes provide related resources that can be explored using the same workflow. Annotations and gene identifiers should still be inspected independently for each route. ABCatlasR retrieves the published source data but does not perform orthology mapping or cross-species integration.

The examples in this vignette use release 20261130, the ABC Atlas release validated for this package version. The dataset registry and documentation are versioned with ABCatlasR; as newer Atlas releases are incorporated and validated, the supported routes and examples can be updated accordingly.

Basic workflow

After choosing a dataset, the central workflow is:

  1. choose where Atlas files will be stored;
  2. load metadata for the selected dataset;
  3. inspect the available annotations and select cells;
  4. optionally inspect the expression request with plan_fetch();
  5. retrieve the expression matrix with fetch_data().

The examples below use Zhuang4, a spatial mouse-brain resource from the published whole-mouse-brain spatial atlas [3].

Choose where Atlas files will be stored

ABCatlasR keeps downloaded ABC Atlas files in a persistent local cache so that later requests can reuse them. For an interactive local session, a convenient way to choose the location is:

options(ABCatlasR.download_base = "/path/to/abc_atlas_cache")
abc_download_dir()

abc_download_dir() reports the directory that will be used. A specific download_base can also be supplied directly to load_data() for a one-off workflow, while ABC_ATLAS_CACHE is convenient for shell scripts, HPC jobs, and other environment-managed workflows. If none of these are set, ABCatlasR uses its per-user cache directory.

Load metadata

load_data() assembles the cell metadata, gene metadata, and available annotations for a dataset. It does not retrieve expression matrices.

abc <- load_data(
    dataset = "Zhuang4",
    release = "20261130"
)
#> Downloading metadata/Zhuang-ABCA-4/20241115/cell_metadata.csv (38 MB)
#> Zhuang4: 162,578 cells loaded.
#> Downloading metadata/WMB-taxonomy/20231215/cluster_to_cluster_annotation_membership.csv (2.2 MB)
#> Downloading metadata/WMB-taxonomy/20231215/views/cluster_to_cluster_annotation_membership_pivoted.csv (530.6 kB)
#> Cell annotations loaded.
#> Downloading metadata/Zhuang-ABCA-4/20241115/gene.csv (84.7 kB)
#> Zhuang4: 1,122 genes loaded.
abc
#> <abc_data>
#>   dataset:        Zhuang4
#>   release:        20261130
#>   cells:          162578
#>   genes:          1122
#>   modality:       spatial_transcriptomics
#>   spatial:        yes
#>   expression:     raw, log2 (default: raw)
#>   expression data: not loaded

The returned abc_data object contains:

  • cell_metadata: one row per cell, including annotations published for the selected route;
  • gene_data: one row per gene, including stable gene identifiers and gene symbols when available;
  • unique_values: precomputed summaries of selected metadata variables;
  • dataset: the route name;
  • download_base: the cache location;
  • release: the ABC Atlas release used to assemble the object.

Explore annotations and select cells

The annotations available for biological selection differ among datasets. Inspect the metadata before defining the cells of interest:

names(abc$cell_metadata)
#>  [1] "cell_label"                "brain_section_label"      
#>  [3] "feature_matrix_label"      "donor_label"              
#>  [5] "donor_genotype"            "donor_sex"                
#>  [7] "cluster_alias"             "x"                        
#>  [9] "y"                         "z"                        
#> [11] "subclass_confidence_score" "cluster_confidence_score" 
#> [13] "high_quality_transfer"     "abc_sample_id"            
#> [15] "neurotransmitter"          "class"                    
#> [17] "subclass"                  "supertype"                
#> [19] "cluster"                   "cluster_color"            
#> [21] "supertype_color"           "subclass_color"           
#> [23] "class_color"               "neurotransmitter_color"
head(abc$cell_metadata)
#>                                                                      cell_label
#> 177536119734259275144748435471942472531 177536119734259275144748435471942472531
#> 256532006537596385088807329967308781746 256532006537596385088807329967308781746
#> 28801318882950773770397006451868070066   28801318882950773770397006451868070066
#> 301971869963235435117242882149875853185 301971869963235435117242882149875853185
#> 81203938259029510162263594992098070595   81203938259029510162263594992098070595
#> 121522424216293207909252794919720629128 121522424216293207909252794919720629128
#>                                         brain_section_label
#> 177536119734259275144748435471942472531   Zhuang-ABCA-4.002
#> 256532006537596385088807329967308781746   Zhuang-ABCA-4.002
#> 28801318882950773770397006451868070066    Zhuang-ABCA-4.002
#> 301971869963235435117242882149875853185   Zhuang-ABCA-4.002
#> 81203938259029510162263594992098070595    Zhuang-ABCA-4.002
#> 121522424216293207909252794919720629128   Zhuang-ABCA-4.002
#>                                         feature_matrix_label   donor_label
#> 177536119734259275144748435471942472531        Zhuang-ABCA-4 Zhuang-ABCA-4
#> 256532006537596385088807329967308781746        Zhuang-ABCA-4 Zhuang-ABCA-4
#> 28801318882950773770397006451868070066         Zhuang-ABCA-4 Zhuang-ABCA-4
#> 301971869963235435117242882149875853185        Zhuang-ABCA-4 Zhuang-ABCA-4
#> 81203938259029510162263594992098070595         Zhuang-ABCA-4 Zhuang-ABCA-4
#> 121522424216293207909252794919720629128        Zhuang-ABCA-4 Zhuang-ABCA-4
#>                                         donor_genotype donor_sex cluster_alias
#> 177536119734259275144748435471942472531          wt/wt         M          5249
#> 256532006537596385088807329967308781746          wt/wt         M          4167
#> 28801318882950773770397006451868070066           wt/wt         M          5252
#> 301971869963235435117242882149875853185          wt/wt         M          5252
#> 81203938259029510162263594992098070595           wt/wt         M          5249
#> 121522424216293207909252794919720629128          wt/wt         M          4167
#>                                                x        y        z
#> 177536119734259275144748435471942472531 12.84560 3.428535 1.958952
#> 256532006537596385088807329967308781746 12.85407 3.466185 1.958952
#> 28801318882950773770397006451868070066  12.82824 3.409277 1.958952
#> 301971869963235435117242882149875853185 12.82727 3.403092 1.958952
#> 81203938259029510162263594992098070595  12.82846 3.410416 1.958952
#> 121522424216293207909252794919720629128 12.88211 3.635425 1.958952
#>                                         subclass_confidence_score
#> 177536119734259275144748435471942472531                 0.9983652
#> 256532006537596385088807329967308781746                 0.9289256
#> 28801318882950773770397006451868070066                  0.9635175
#> 301971869963235435117242882149875853185                 0.9999843
#> 81203938259029510162263594992098070595                  0.9999484
#> 121522424216293207909252794919720629128                 0.9999648
#>                                         cluster_confidence_score
#> 177536119734259275144748435471942472531                0.8062046
#> 256532006537596385088807329967308781746                0.9289256
#> 28801318882950773770397006451868070066                 0.9485377
#> 301971869963235435117242882149875853185                0.8534079
#> 81203938259029510162263594992098070595                 0.9999484
#> 121522424216293207909252794919720629128                0.9999648
#>                                         high_quality_transfer
#> 177536119734259275144748435471942472531                  TRUE
#> 256532006537596385088807329967308781746                  TRUE
#> 28801318882950773770397006451868070066                   TRUE
#> 301971869963235435117242882149875853185                  TRUE
#> 81203938259029510162263594992098070595                   TRUE
#> 121522424216293207909252794919720629128                  TRUE
#>                                                                abc_sample_id
#> 177536119734259275144748435471942472531 5d53075c-ca36-40d5-a718-31e519b2abfb
#> 256532006537596385088807329967308781746 88ba4908-07d8-48a2-a85e-d0c10392c2ec
#> 28801318882950773770397006451868070066  4d018b6c-0b56-4c2c-b8fe-b591ac155118
#> 301971869963235435117242882149875853185 ac646972-132e-4773-9d14-42b426481b8a
#> 81203938259029510162263594992098070595  2af329e8-0cab-4622-b41c-187dd764428a
#> 121522424216293207909252794919720629128 a608223e-7cc6-4014-b221-0d6f72280e55
#>                                         neurotransmitter       class
#> 177536119734259275144748435471942472531            Other 33 Vascular
#> 256532006537596385088807329967308781746             GABA  28 CB GABA
#> 28801318882950773770397006451868070066             Other 33 Vascular
#> 301971869963235435117242882149875853185            Other 33 Vascular
#> 81203938259029510162263594992098070595             Other 33 Vascular
#> 121522424216293207909252794919720629128             GABA  28 CB GABA
#>                                                        subclass
#> 177536119734259275144748435471942472531              332 SMC NN
#> 256532006537596385088807329967308781746 311 CBX MLI Megf11 Gaba
#> 28801318882950773770397006451868070066              333 Endo NN
#> 301971869963235435117242882149875853185             333 Endo NN
#> 81203938259029510162263594992098070595               332 SMC NN
#> 121522424216293207909252794919720629128 311 CBX MLI Megf11 Gaba
#>                                                          supertype
#> 177536119734259275144748435471942472531              1192 SMC NN_1
#> 256532006537596385088807329967308781746 1149 CBX MLI Megf11 Gaba_1
#> 28801318882950773770397006451868070066              1193 Endo NN_1
#> 301971869963235435117242882149875853185             1193 Endo NN_1
#> 81203938259029510162263594992098070595               1192 SMC NN_1
#> 121522424216293207909252794919720629128 1149 CBX MLI Megf11 Gaba_1
#>                                                            cluster
#> 177536119734259275144748435471942472531              5307 SMC NN_1
#> 256532006537596385088807329967308781746 5188 CBX MLI Megf11 Gaba_1
#> 28801318882950773770397006451868070066              5309 Endo NN_1
#> 301971869963235435117242882149875853185             5309 Endo NN_1
#> 81203938259029510162263594992098070595               5307 SMC NN_1
#> 121522424216293207909252794919720629128 5188 CBX MLI Megf11 Gaba_1
#>                                         cluster_color supertype_color
#> 177536119734259275144748435471942472531       #009945         #1F6566
#> 256532006537596385088807329967308781746       #4F2E66         #246600
#> 28801318882950773770397006451868070066        #5C9994         #00992A
#> 301971869963235435117242882149875853185       #5C9994         #00992A
#> 81203938259029510162263594992098070595        #009945         #1F6566
#> 121522424216293207909252794919720629128       #4F2E66         #246600
#>                                         subclass_color class_color
#> 177536119734259275144748435471942472531        #FF9F73     #858881
#> 256532006537596385088807329967308781746        #8BCC5C     #FFFB46
#> 28801318882950773770397006451868070066         #994567     #858881
#> 301971869963235435117242882149875853185        #994567     #858881
#> 81203938259029510162263594992098070595         #FF9F73     #858881
#> 121522424216293207909252794919720629128        #8BCC5C     #FFFB46
#>                                         neurotransmitter_color
#> 177536119734259275144748435471942472531                #666666
#> 256532006537596385088807329967308781746                #FF3358
#> 28801318882950773770397006451868070066                 #666666
#> 301971869963235435117242882149875853185                #666666
#> 81203938259029510162263594992098070595                 #666666
#> 121522424216293207909252794919720629128                #FF3358

Depending on the resource, selection variables can describe cell identity, anatomy, donor or subject characteristics, disease annotations, spatial sections, or other dataset-specific information.

For example, select GABAergic cells from one Zhuang4 brain section:

selected_meta <- subset(
    abc$cell_metadata,
    brain_section_label == "Zhuang-ABCA-4.002" &
        neurotransmitter == "GABA"
)

cells <- head(selected_meta$cell_label, 1000)
length(cells)
#> [1] 1000

cell_label contains the identifiers expected by plan_fetch() and fetch_data().

Inspect the expression request

plan_fetch() reports the expression source files associated with the selected cells, their local cache status, and the storage associated with the request.

plan_fetch(
    abc,
    cell_ids = cells,
    data_type = "raw"
)
#> <abc_fetch_plan>
#>   dataset:        Zhuang4
#>   release:        20261130
#>   representation: raw
#>   cells:          1,000
#> 
#> Expression files:
#>   Zhuang-ABCA-4/Zhuang-ABCA-4/raw [1000 cells]
#>     size:                64.2 MB
#>     cached:              no
#>     resumable partial:   0 B
#>     additional download: 64.2 MB
#> 
#> Totals:
#>   selected-file size:   64.2 MB
#>   resumable partial:    0 B
#>   additional download:  64.2 MB
#>   available disk space: 94.7 GB
#>   required free space:  2.1 GB
#>   storage check:        PASS
#> 
#> No expression files were downloaded.

plan_fetch() is optional, but it is recommended before fetch_data() when working on a local machine, with an unfamiliar dataset, or with a large cell selection. The plan shows which source files are needed, whether they are already cached, and the storage associated with the request. This makes it easy to confirm that the selected cache location is appropriate before retrieval begins.

Retrieve the matrix

fetch_data() retrieves expression for the selected cells. The default return type is "matrix", so it does not need to be specified explicitly.

x <- fetch_data(
    abc,
    cell_ids = cells,
    data_type = "raw"
)
#> Downloading expression_matrices/Zhuang-ABCA-4/20230830/Zhuang-ABCA-4-raw.h5ad (64.2 MB)

When genes is not supplied, all genes available for the selected expression representation are returned.

The default abc_matrix contains:

  • expression: sparse dgCMatrix, with genes in rows and cells in columns;
  • cell_metadata: metadata aligned to the matrix columns;
  • gene_data: gene metadata aligned to the matrix rows;
  • data_type: the selected source expression representation;
  • provenance: information describing the dataset, release, modality, and request.

The alignment can be verified directly:

dim(x$expression)
#> [1] 1122 1000
class(x$expression)
#> [1] "dgCMatrix"
#> attr(,"package")
#> [1] "Matrix"

identical(
    colnames(x$expression),
    x$cell_metadata$cell_label
)
#> [1] TRUE

identical(
    rownames(x$expression),
    x$gene_data$gene_identifier
)
#> [1] TRUE

The matrix can then be used in downstream single-cell workflows without another Atlas request.

Expression representations

The expression representations supported by each route are shown by list_datasets().

Depending on the dataset, these can include:

  • "raw": raw counts;
  • "log2": log2-transformed expression published by the ABC Atlas;
  • "batch_normalized": batch-normalized counts for supported routes;
  • "ln": natural-log-transformed values where published by the Atlas.

Specify the representation with data_type:

x_log2 <- fetch_data(
    abc,
    cell_ids = cells,
    data_type = "log2"
)

If data_type is omitted, the registered default for that route is used. ABCatlasR does not calculate one representation from another; it returns the selected source values as published.

For downstream methods that require counts, request data_type = "raw" when raw counts are available.

Optional gene selection

Gene filtering is optional. With the default genes = NULL, all genes in the selected expression representation are returned.

For a targeted analysis, genes can contain canonical gene_identifier values or unambiguous gene symbols:

x_panel <- fetch_data(
    abc,
    cell_ids = cells,
    genes = c("Gad2", "Slc32a1", "Slc17a7"),
    data_type = "raw"
)
#> Using cached expression_matrices/Zhuang-ABCA-4/20230830/Zhuang-ABCA-4-raw.h5ad (64.2 MB); no download needed.

Stable gene identifiers are preferable where available because a published symbol can be ambiguous. Matrix rows are keyed by gene_identifier, while published symbols remain available in gene_data$gene_symbol.

Expression source files are retrieved at file level, so selecting fewer genes primarily reduces the size of the returned R object rather than necessarily reducing the size of an uncached download.

Return types

Matrix

The default return type is the abc_matrix described above:

x <- fetch_data(
    abc,
    cell_ids = cells,
    data_type = "raw"
)
#> Using cached expression_matrices/Zhuang-ABCA-4/20230830/Zhuang-ABCA-4-raw.h5ad (64.2 MB); no download needed.

This format is convenient when the expression matrix is passed directly to another single-cell framework.

SingleCellExperiment

Use return_type = "sce" to obtain a SingleCellExperiment:

sce <- fetch_data(
    abc,
    cell_ids = cells,
    data_type = "raw",
    return_type = "sce"
)
#> Using cached expression_matrices/Zhuang-ABCA-4/20230830/Zhuang-ABCA-4-raw.h5ad (64.2 MB); no download needed.

Raw expression is stored in the counts assay. Other source representations are stored in an assay named after the requested data type.

SpatialExperiment

For routes marked as spatial by list_datasets(), use return_type = "spatial" to obtain a SpatialExperiment containing the available spatial coordinates:

spe <- fetch_data(
    abc,
    cell_ids = cells,
    data_type = "log2",
    return_type = "spatial"
)

Using the default matrix with other frameworks

The default matrix bundle can also be used with packages outside the direct Bioconductor return types.

Seurat

seu <- SeuratObject::CreateSeuratObject(
    counts = x$expression,
    meta.data = x$cell_metadata
)

x$gene_data retains the original ABC Atlas gene identifiers and symbols.

Monocle 3

gene_metadata <- x$gene_data
gene_metadata$gene_short_name <- gene_metadata$gene_symbol

cds <- monocle3::new_cell_data_set(
    x$expression,
    cell_metadata = x$cell_metadata,
    gene_metadata = gene_metadata
)

Cache, releases, and offline use

ABCatlasR stores downloaded Atlas files in a persistent cache. Once a source file has been downloaded for a given release, later requests can reuse the same local copy instead of downloading it again.

The directory currently used by the package can be checked with:

abc_download_dir()
#> [1] "/tmp/RtmpYnaq3G/ABCatlasR-cache"

The cache location can be chosen in several ways. For an interactive R session, it can be set with:

options(ABCatlasR.download_base = "/path/to/abc_atlas_cache")

A different location can also be supplied directly through the download_base argument of load_data() or abc_cache_connect(). On HPC systems, the ABC_ATLAS_CACHE environment variable is often convenient because the storage path can be configured in the shell or job script without changing the R analysis code.

If no cache location is specified, ABCatlasR uses its per-user cache directory automatically.

For reproducible analyses, the ABC Atlas release can be pinned explicitly:

abc <- load_data(
    "Zhuang4",
    release = "20261130"
)
#> Using cached metadata/Zhuang-ABCA-4/20241115/cell_metadata.csv (38 MB); no download needed.
#> Zhuang4: 162,578 cells loaded.
#> Using cached metadata/WMB-taxonomy/20231215/cluster_to_cluster_annotation_membership.csv (2.2 MB); no download needed.
#> Using cached metadata/WMB-taxonomy/20231215/views/cluster_to_cluster_annotation_membership_pivoted.csv (530.6 kB); no download needed.
#> Cell annotations loaded.
#> Using cached metadata/Zhuang-ABCA-4/20241115/gene.csv (84.7 kB); no download needed.
#> Zhuang4: 1,122 genes loaded.

The selected release is retained in the returned object and in the expression provenance, allowing the source version used for an analysis to be recorded.

On HPC systems where compute nodes do not have internet access, the required metadata and expression files can be downloaded in advance on an internet-enabled login or data-transfer node and stored in a shared or persistent cache. Compute jobs can then point to the same cache and use the package’s offline mode so that no network connection is required during the analysis.

Lower-level cache access

Most users do not need to call abc_cache_connect() directly because load_data() and fetch_data() manage the cache automatically.

For workflows that need access to individual files listed in an ABC Atlas release manifest, a cache connection can be opened explicitly:

cache <- abc_cache_connect(
    download_base = abc_download_dir(),
    release = "20261130"
)
cache
#> <abc_cache> releases/20261130/manifest.json
#>   download_base: /tmp/RtmpYnaq3G/ABCatlasR-cache
#>   directories:   46

The returned abc_cache object records the release manifest and provides helpers for locating or reading files in that release.

References

  1. Allen Institute for Brain Science. Allen Brain Cell Atlas (RRID:SCR_024440). https://portal.brain-map.org/atlases-and-data/bkp/abc-atlas
  2. Yao Z, van Velthoven CTJ, Kunst M, et al. (2023). A high-resolution transcriptomic and spatial atlas of cell types in the whole mouse brain. Nature 624, 317-332. https://doi.org/10.1038/s41586-023-06812-z
  3. Zhang M, Pan X, Jung W, et al. (2023). Molecularly defined and spatially resolved cell atlas of the whole mouse brain. Nature 624, 343-354. https://doi.org/10.1038/s41586-023-06808-9

Session information

sessionInfo()
#> R version 4.6.2 (2026-10-29)
#> Platform: x86_64-pc-linux-gnu
#> Running under: Ubuntu 26.04.1 LTS
#> 
#> Matrix products: default
#> BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
#> LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.32.so;  LAPACK version 3.12.0
#> 
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
#>  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
#>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
#> 
#> time zone: Etc/UTC
#> tzcode source: system (glibc)
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] ABCatlasR_0.99.0 BiocStyle_2.41.0
#> 
#> loaded via a namespace (and not attached):
#>  [1] sass_0.5.0                  generics_0.1.4             
#>  [3] SparseArray_1.15.0          xml2_1.6.0                 
#>  [5] lattice_0.23-1              h5mread_1.5.7              
#>  [7] digest_0.6.39               magrittr_2.0.5             
#>  [9] evaluate_1.0.5              grid_4.6.2                 
#> [11] fastmap_1.2.0               jsonlite_2.0.0             
#> [13] Matrix_1.7-6                BiocManager_1.30.27        
#> [15] SingleCellExperiment_1.35.2 HDF5Array_1.43.0           
#> [17] jquerylib_0.1.4             abind_1.4-8                
#> [19] cli_3.6.6                   rlang_1.3.0                
#> [21] XVector_0.53.0              Biobase_2.73.2             
#> [23] cachem_1.1.0                DelayedArray_0.39.8        
#> [25] yaml_2.3.12                 otel_0.3.0                 
#> [27] S4Arrays_1.15.0             tools_4.6.2                
#> [29] dplyr_1.2.1                 Rhdf5lib_2.3.0             
#> [31] SummarizedExperiment_1.45.0 BiocGenerics_0.59.13       
#> [33] curl_8.2.0                  buildtools_1.0.0           
#> [35] vctrs_0.7.3                 R6_2.6.1                   
#> [37] matrixStats_1.5.0           stats4_4.6.2               
#> [39] lifecycle_1.0.5             rhdf5_2.59.0               
#> [41] Seqinfo_1.5.0               S4Vectors_0.53.0           
#> [43] IRanges_2.47.5              pkgconfig_2.0.3            
#> [45] pillar_1.11.1               bslib_0.12.0               
#> [47] data.table_1.18.6.1         glue_1.8.1                 
#> [49] GenomicRanges_1.67.0        xfun_0.62                  
#> [51] tibble_3.3.1                tidyselect_1.2.1           
#> [53] rhdf5filters_1.25.5         sys_3.4.3                  
#> [55] MatrixGenerics_1.27.0       knitr_1.52                 
#> [57] htmltools_0.5.9             rmarkdown_2.32             
#> [59] maketools_1.3.2             compiler_4.6.2