Space Ranger1.1 (latest), printed on 10/27/2020
When doing large studies involving multiple Capture Areas of consecutive sections of the same tissue block, run spaceranger count on FASTQ data from each of the capture area individually, and then pool the results using spaceranger aggr, as described here.
|spaceranger aggr is not designed for combining multiple sequencing runs of a single capture area. For that, you should pass a list of FASTQ files from multiple sequencing runs of the same capture area to the --fastqs argument of spaceranger count.|
|The feature references in each individual capture area should be identical when spaceranger aggr is used to aggregate multiple capture areas with feature references. Re-run spaceranger count with a common feature reference to allow aggregation.|
The spaceranger aggr command takes a CSV file specifying a list of spaceranger count output files (specifically the
molecule_info.h5 from each run), and produces a single feature-barcode matrix containing all the data.
When combining multiple capture areas, the barcode sequences for each channel are distinguished by a capture area suffix appended to the barcode sequence (see Capture Area).
By default, the reads from each capture area are subsampled such that all capture areas have the same effective sequencing depth, measured in terms of reads that are confidently mapped to the transcriptome or assigned to the feature IDs per spot. However, it is possible to change the depth normalization mode (see Depth Normalization).
The first step is to run spaceranger count on each individual capture area prepared using the 10x Visium™ platform, as described in Single-capture area Analysis.
For example, suppose you ran three count pipelines as follows:
$ cd /opt/runs $ spaceranger count --id=LV123 ... ... wait for pipeline to finish ... $ spaceranger count --id=LB456 ... ... wait for pipeline to finish ... $ spaceranger count --id=LP789 ... ... wait for pipeline to finish ...
Now you can aggregate these three runs to get a single feature-barcode matrix and analysis. In order to do so, you need to create an Aggregation CSV.
Create a CSV file with a header line containing the following columns:
library_id: Unique identifier for this input capture area. This will be used for labeling purposes only; it doesn't need to match any previous ID you've assigned to the capture area.
molecule_h5: Path to the
molecule_info.h5file produced by spaceranger count. For example, if you processed your capture area by calling spaceranger count --id=ID in some directory
/DIR, this path would be
cloupe_file: Path to the
cloupe.cloupefile produced by spaceranger count. For example, if you processed your capture area by calling spaceranger count --id=ID in some directory
/DIR, this path would be
You can either make the CSV file in a text editor, or create it in Excel and export to CSV. Continuing the example from the previous section, your Excel spreadsheet would look like this:
When you save it as a CSV, the result would look like this:
library_id,molecule_h5,cloupe_file,spatial_folder LV123,/opt/runs/LV123/outs/molecule_info.h5,/opt/runs/LV123/outs/cloupe.cloupe,/opt/runs/LV123/outs/spatial LB456,/opt/runs/LB456/outs/molecule_info.h5,/opt/runs/LB456/outs/cloupe.cloupe,/opt/runs/LB456/outs/spatial LP789,/opt/runs/LP789/outs/molecule_info.h5,/opt/runs/LP789/outs/cloupe.cloupe,/opt/runs/LP789/outs/spatial
In addition to the CSV columns expected by spaceranger aggr, you may optionally supply additional columns containing library meta-data (e.g., lab or sample origin). These custom library annotations do not affect the analysis pipeline but can be visualized downstream in the Loupe Browser (see below). Note that unlike other CSV inputs to Spaceranger, these custom columns may contain characters outside the ASCII range (e.g., non-Latin characters).
When combining multiple samples into a single dataset with the spaceranger aggr pipeline, you can assign categories and values to individual samples by adding columns to the spaceranger aggr input spreadsheet. These category assignments propagate into Loupe Browser, where you can view them, and determine genes that drive differences within samples. For example, the following spreadsheet was used to aggregate the tutorial dataset:
Any columns in addition to 'library_id', 'molecule_h5', 'cloupe_file' and 'spatial_folder' will be converted into categories, and the spots in each sample will be assigned to one of the values in that category.
spaceranger aggr does not perform batch correction for removal of technical artifacts due to differences in assays. For this reason, 10x does not recommend combining Visium data from fundamentally different treatments such as immunofluorescence and H&E stained tissue sections. spaceranger aggr can be used with samples from different biological conditions of the same tissue.
These are the most common command line arguments (run spaceranger aggr --help for a full list):
|A unique run ID string: e.g. |
|Path of a CSV file containing a list of spaceranger count outputs (see Setting up a CSV).|
|(Optional) String specifying how to normalize depth across the input libraries. Valid values: |
After specifying these input arguments, run spaceranger aggr:
$ cd /home/jdoe/runs $ spaceranger aggr --id=AGG123 \ --csv=AGG123_libraries.csv \ --normalize=mapped
The pipeline will begin to run, creating a new folder named with the aggregation ID you specified (e.g.
/home/jdoe/runs/AGG123) for its output. If this folder already exists, spaceranger will assume it is an existing pipestance and attempt to resume running it.
The spaceranger aggr pipeline generates output files that contain all of the data from the individual input jobs, aggregated into single output files, for convenient multi-sample analysis. The capture area suffix of each barcode is updated to prevent barcode collisions, as described below.
Each output file produced by spaceranger aggr follows the format described in the Understanding Output section of the documentation, but includes the union of all the relevant barcodes from each of the input jobs.
|spaceranger aggr does not perform a spot-calling step, it simply aggregates the spot calls from each input job into a final set of spot calls.|
A successful run should conclude with a message similar to this:
2018-10-04 13:36:33 [runtime] (run:local) ID.AGG123.SPATIAL_RNA_AGGREGATOR_CS.SPATIAL_RNA_AGGREGATOR.SUMMARIZE_AGGREGATED_REPORTS.fork0.join 2018-10-04 13:36:36 [runtime] (join_complete) ID.AGG123.SPATIAL_RNA_AGGREGATOR_CS.SPATIAL_RNA_AGGREGATOR.SUMMARIZE_AGGREGATED_REPORTS 2018-10-04 13:36:45 [runtime] VDR killed 210 files, 29MB. Outputs: - Aggregation metrics summary HTML: /home/jdoe/runs/AGG123/outs/web_summary.html - Aggregation metrics summary JSON: /home/jdoe/runs/AGG123/outs/summary.json - Secondary analysis output CSV: /home/jdoe/runs/AGG123/outs/analysis - Filtered feature-barcode matrices MEX: /home/jdoe/runs/AGG123/outs/filtered_feature_bc_matrix - Filtered feature-barcode matrices HDF5: /home/jdoe/runs/AGG123/outs/filtered_feature_bc_matrix.h5 - Unfiltered feature-barcode matrices MEX: /home/jdoe/runs/AGG123/outs/raw_feature_bc_matrix - Unfiltered feature-barcode matrices HDF5: /home/jdoe/runs/AGG123/outs/raw_feature_bc_matrix.h5 - Copy of the input aggregation CSV: /home/jdoe/runs/AGG123/outs/aggregation.csv - Loupe Browser file: /home/jdoe/runs/AGG123/outs/cloupe.cloupe - Aggregated tissue positions list: /home/jdoe/runs/AGG123/outs/aggr_tissue_positions_list.csv - Spatial folder containing spatial images and scalefactors: /home/jdoe/runs/AGG123/outs/spatial Pipestance completed successfully!
Once spaceranger aggr has successfully completed, you can browse the resulting summary HTML file in any supported web browser, open the .cloupe file in Loupe Browser, or refer to the Understanding Output section to explore the data by hand. For machine-readable versions of the summary metrics, refer to the spaceranger aggr section of the Summary Metrics page.
Each capture area is a physically distinct partition on a Visium slide. However, each of these capture areas are printed with the same set of barcode tagged mRNA capture sequences known as the barcode whitelist. To keep the barcodes unique when aggregating multiple libraries, we append a small integer identifying the capture area to the barcode nucleotide sequence, and use that nucleotide sequence plus ID as the unique identifier in the feature-barcode matrix. For example,
AAACAACGAATAGTTC-2 are distinct spot barcodes from different capture areas, despite having the same barcode nucleotide sequence.
This number, called the capture area suffix, tells us which capture area the barcode sequence came from. The numbering of the capture area will reflect the order that the capture area were provided in the Aggregation CSV.
When combining data from multiple capture areas, the spaceranger aggr pipeline automatically equalizes the read depth between groups before merging, which is the recommended approach in order to avoid the batch effect introduced by sequencing depth. It is possible to turn off normalization or change the way normalization is done. The
none option may be appropriate if you want to maximize sensitivity and plan to deal with depth normalization in a downstream step.
There are two normalization modes:
mapped(default): Subsample reads from higher-depth capture areas until they all have, on average, an equal number of reads per tissue covered spot that are confidently mapped to the transcriptome.
none: Do not normalize at all.