Build and Deployment Protocol
SEA-AD Multiregion Gene Expression Viewer
Protocol overview
This protocol describes the construction and deployment of the SEA-AD Multiregion Gene Expression Viewer from regional single-nucleus RNA-sequencing count matrices and associated ABC Atlas metadata. The procedure generates library-by-Supertype pseudobulk data, prepares a gene-partitioned AWS back end, deploys an R Shiny application, and publishes its documentation.
Complete the sections in order. Run the named scripts from the project repository; select the inputs and outputs specified below. Directory trees describe file organization, not executable commands.
Go to the GitHub source · Return to the user guide
Starting materials
- ABC Atlas Access regional raw-count H5AD files, nucleus and library metadata, donor metadata, and the matching SEA-AD taxonomy release.
- Code Ocean, GitHub, and AWS accounts with permission to create a Capsule, repository, and S3 bucket.
- A web browser. R, Python, Node.js, and publishing tools are installed in the Code Ocean environment during the procedure.
A shinyapps.io account is created during the protocol. Donor-level continuous pseudoprogression scores (CPS) are downloaded as a separate published metadata resource; they are not calculated from the RNA count matrices.
Products
- A versioned pseudobulk H5AD containing summed counts and expressing-nucleus counts.
- A complete app-ready data directory published to a new S3 bucket.
- A deployed Shiny application in the operator’s shinyapps.io account.
- A GitHub Pages site containing the user guide and this protocol.
1. Establish the project configuration
- Fork the application repository into the GitHub account that will maintain the new deployment. Record the source commit identifier. Keep the Shiny deployment workflow disabled until the new application has been created and its deployment target configured.
- Create a project configuration record in the repository. Record the ABC Atlas manifest, included regions, source commit, Capsule identifier, S3 bucket, AWS region, S3 prefix, shinyapps.io account name, application name, and application ID. Populate the hosting fields when they are assigned.
- Use
releases/20260711/manifest.jsonfor the ABC Atlas release. Include AnG, DFC, FI, HIP, ITG, LEC, MEC, MTG, STG, and V1C fromSEA-AD-Multiregion-10X, with annotations fromSEA-AD-Multiregion-taxonomy. Keep expression and taxonomy inputs tied to this release. - Use
SEAAD_multiregion/v1as the deployment prefix in the new S3 bucket andmultiregion_gene_explorationas the new Shiny application name. Use the operator’s own bucket and hosting account throughout the protocol.
counts_by_gene/, metadata/, and statistics/. Use the same prefix in the upload destination and application configuration. Do not reuse an application ID or account name from another deployment.2. Create the Code Ocean environment
- Connect the GitHub account to Code Ocean using its Git-provider integration. Select New Capsule → Clone from Git and enter the HTTPS address of the fork. Confirm that
code/,environment/, andmetadata/are present. - Build the Capsule environment using
environment/Dockerfile,environment/postInstall, andrequirements.txt. Launch a Cloud Workstation with RStudio and a terminal. Retain the environment definitions in version control. - Verify the Python dependencies
abc_atlas_access,anndata,h5py,numpy,pandas,scipy,pyarrow, andpybiomart. Install missing dependencies in the Capsule environment and rebuild it. - Restore the R environment from
code/shiny/renv.lock. Verify Shiny, bslib, Arrow with S3 support, dplyr, ggplot2, scales, shinycssloaders, cachem, DT, and jsonlite. Install rsconnect for publishing. Install Node.js and thekiwi-schemapackage for ABC Atlas URL generation. - Allocate writable storage for the ABC Atlas cache and regional intermediates. Set the cache directory to
/scratch/abc_atlas_cache, the intermediate directory to/scratch/seaad_pseudobulk, and the durable output directory to/results. Select compute resources appropriate for the regional input matrices and monitor storage and memory during processing. - Keep credentials in account integrations or secret storage. Exclude AWS credentials, shinyapps.io tokens, saved R workspaces, raw matrices, and local package libraries from Git commits and application bundles.
3. Prepare the source data
- Place the ABC Atlas Access files in the cache directory, retaining the manifest-defined directory structure and filenames. Configure ABC Atlas Access to use that cache and the selected manifest.
- Confirm that every selected region has a raw-count H5AD matrix. Retain the nucleus-level metadata, library metadata, donor metadata, and taxonomy membership and annotation tables required by
code/create_seaad_pseudobulk.py. Do not substitute log-normalized expression matrices. - Download global_cps_multiregion.csv and retain it as a local processing input. Record its source and checksum. Verify the columns
donor_id,CPS_Global,CPS_Global_ABeta, andCPS_Global_pTau. - Check that CPS donor identifiers are nonmissing and unique and that score columns are numeric. Compare the identifiers with donor metadata as strings. Preserve missing scores as missing values.
4. Generate the pseudobulk H5AD
- Run
code/create_seaad_pseudobulk.pywith the selected manifest, all ten regions, the cache and scratch directories defined above, and output/results/SEA_AD_Multiregion_library_supertype_pseudobulk.h5ad. Use a matrix chunk size of 1,024 observations and a metadata chunk size of 250,000 rows. - Process each regional matrix independently. Join nucleus identifiers to library and donor metadata and to the matching Class, Subclass, and Supertype annotations. Normalize identifier types before joining. Review the processing log for unmatched or excluded nuclei.
- Aggregate assigned nuclei by
library_label × Supertype. For each gene, sum raw counts and count nuclei with raw expression greater than zero. Record the total number of contributing nuclei for each pseudobulk observation. - Combine the regional pseudobulk objects after confirming a consistent gene axis. Reopen the final H5AD and verify the matrix and metadata contract below.
- Capture the final H5AD and processing log as a versioned Code Ocean Data Asset. Record the source manifest, source commit, region list, and checksum. Attach the asset to the Capsule at
/data/pseudobulkfor subsequent steps.
Required H5AD structure
X: summed raw counts, with pseudobulk observations in rows and genes in columns.layers["number_of_nuclei_expressing"]: expressing-nucleus counts with the same dimensions and ordering asX.obs: unique observation identifiers,library_label,Number of nuclei,Donor ID,Brain Region,Class,Subclass,Supertype, andCognitive Status, together with available study, clinical, and quality-control annotations.var: gene symbols and source identifiers aligned to the count matrix. Preserve distinct matrix keys for duplicated gene symbols.
5. Generate gene-partitioned Parquet files
- Run
code/create_seaad_parquet.py. Set the input to/data/pseudobulk/SEA_AD_Multiregion_library_supertype_pseudobulk.h5ad, the output to/results/SEAAD_parquet_by_gene, and the CPS source to the local CSV downloaded in Step 13. Use a gene block size of 64 and Zstandard compression. - Write
metadata/obs_metadata.parquetwith one uniquesample_idper pseudobulk observation. Preserve the observation order and itslibrary_label. Writemetadata/gene_map.parquetwith the mapping fromgene_symboltogene_column. - Calculate each pseudobulk row’s total raw counts across all genes. Write
metadata/CPM_scaling.csvwithlibrary_labelandCPM_scaling_factor, retaining exactly the observation-metadata row order. - Write one
counts_by_gene/gene=<gene_column>/data.parquetfile per gene. Retainsample_id,summed_counts, andnumber_of_nuclei_expressing, including zero-valued observations. Use the partition keys generated by the converter. - Confirm that the converter copied the CPS CSV to
metadata/global_cps_multiregion.csvand wrote its data manifest. Validate representative gene files against the H5AD before proceeding.
Expression and detection calculations
CPM_scaling_factor = 1,000,000 / total raw counts in the pseudobulk row CP10K = summed_counts × CPM_scaling_factor / 100 Displayed log expression = ln(CP10K + 1) Fraction expressing = number_of_nuclei_expressing / Number of nuclei
library_label sequences.6. Generate statistics and categorical metadata
- Run
code/create_seaad_statistics.pywith the mounted pseudobulk H5AD as input and/results/SEAAD_parquet_by_gene/statistics/seaad_gene_summary_statistics.csvas output. Use the same count and detection matrices used for Parquet conversion. - Calculate CPM-based expression summaries for the complete dataset, Dementia versus No dementia groups, Brain Region, and Subclass. Calculate detection fractions from pooled expressing-nucleus counts divided by pooled nucleus totals. Retain the script’s fold-change and fraction-difference definitions.
- Annotate gene biotypes using the script’s human BioMart lookup. Retain the gene-to-biotype mapping with the processing record and verify that each annotation is aligned to its gene symbol. Validate the required output columns below.
- Run
code/create_seaad_value_sets.pywith the same pseudobulk H5AD and output/results/SEAAD_parquet_by_gene/metadata/value_sets.csv. Use the columnslabel,field,color_hex_triplet, andorder. - Join the Class, Subclass, and Supertype labels in the value-set table to the matching ABC Atlas taxonomy annotation tables. Populate their taxonomy colors and order from that release. Preserve the script-generated clinical category order and colors for other fields. Exclude continuous variables from categorical value sets.
- Validate the CPS table against
obs_metadata.parquet. Joindonor_idtoDonor IDwithout changing observation order or duplicating observations. Retain unmatched scores as missing values and record their frequency.
Required statistics columns
gene_symbol ln(mean_CPM+1) frac_expr dementia_log2fc dementia_frac_diff max_ROI log2fc_ROI max_frac_ROI frac_diff_ROI max_subclass log2fc_subclass max_frac_subclass frac_diff_subclass gene_type
ln(mean_CPM+1) in the source CSV. The application converts this summary to CP10K for display. Keep fraction differences as proportions, without multiplying them by 100.7. Publish the data to AWS
- Create a new S3 bucket in
us-west-2with a globally unique name. Dedicate it to the public application data. Record the bucket name andSEAAD_multiregion/v1prefix in the project configuration. - Create an upload identity with permissions limited to the application bucket and required upload operations. Configure authenticated AWS access in Code Ocean using secret storage. Do not embed credentials in the application.
- Assemble the complete directory shown below. Validate filenames, partition coverage, sample alignment, detection-count bounds, CPS joins, and statistics before upload. Capture this directory as a versioned Code Ocean Data Asset.
- Upload the contents of
/results/SEAAD_parquet_by_genedirectly beneathSEAAD_multiregion/v1. Preserve the directory hierarchy. Compare local and remote object counts and sizes and read back representative files. - Configure a bucket policy granting anonymous
s3:GetObjectaccess only to objects under the application prefix. Grants3:ListBucketfor the application-prefix listings required by Arrow dataset discovery. Do not grant anonymous write or delete permissions. Adjust Block Public Access settings only as required for this public-data policy. - Test access without AWS credentials. Read each metadata file and the statistics CSV, then list and open a representative gene partition using Arrow. Keep private data outside this bucket.
Local output and S3 prefix contents
SEAAD_parquet_by_gene/
counts_by_gene/
gene=<gene_column>/
data.parquet
...
metadata/
obs_metadata.parquet
gene_map.parquet
CPM_scaling.csv
value_sets.csv
global_cps_multiregion.csv
statistics/
seaad_gene_summary_statistics.csv
manifest.json
8. Generate ABC Atlas links
- Open ABC Atlas and select the SEA-AD multiregion dataset. Select
PTPRGas the displayed gene and configure the intended starting view. Copy its complete share URL and record that URL together with the starting genePTPRG. - Load
code/shiny/abc_atlas_gene_url_function.Rin the preparation environment. Supplyabc_atlas_schema_kiwi.txt, the recorded starting URL, the starting gene, and the gene-symbol list fromgene_map.parquet. Generate a URL for each gene using the helper’s gene-substitution procedure. - Write a gzip-compressed CSV to
code/shiny/abc_atlas_gene_urls.csv.gz. Put the gene symbol in the first column and its URL in the second column. Include a header and omit row names or index columns. - Check coverage against the gene map and remove duplicate symbol entries. Open links for PTPRG, APOE, and another gene and confirm that each opens the intended gene and SEA-AD view. Retain the seed URL, starting gene, schema, and generation settings with the release record.
9. Configure and test the application
- Open
code/shiny/app.R. Set its S3 bucket, AWS region, and data prefix to the values recorded in Step 31. Confirm that its metadata, scaling, CPS, statistics, and gene-partition paths resolve beneath that prefix. - Assemble the application directory shown below. Keep
table_column_definitions.csvaligned to the statistics schema, with columnscolumn_namesandcolumn_definitions. Include the generated ABC Atlas lookup and the static assets. - Start a clean R session in
code/shinyand launch the application. Verify startup without a saved workspace. Confirm that no scientific-data path points to a local scratch directory or mounted Data Asset. - Load PTPRG and APOE and compare selected values with the generated Parquet files. Verify CP10K, log expression, detection fractions, and zero-valued observations. Test gene-table sorting, filtering, and selection.
- Test trajectory, heatmap, dot, distribution, and two-gene correlation plots. Confirm Subclass and Brain Region defaults for heatmap and dot plots, pooled detection fractions for dot sizes, and continuous numeric CPS axes for trajectories. Verify that missing CPS values are excluded from the selected trajectory axis rather than placed at zero.
- Test combined metadata filters, facets, plot sizing, distribution pagination, expression limits, comparison genes, and external links. Create bookmarks for a filtered trajectory, a faceted distribution, and a two-gene plot; reopen each in a fresh session and verify restoration.
Application directory
code/shiny/
app.R
table_column_definitions.csv
abc_atlas_gene_urls.csv.gz
renv.lock
manifest.json
www/
app_logo.png
allen_institute_logo.svg
tokens.csv
10. Create and deploy the hosted application
- Create a shinyapps.io account using the GitHub sign-in option. Choose an available account name and record it. Select a hosting plan and application resources appropriate for the tested app.
- Open the account’s token settings and obtain a publishing token and secret. Configure rsconnect in the Code Ocean R environment using that account name and credentials. Store credentials outside the repository.
- Generate
code/shiny/manifest.jsonfrom the tested R environment. Includeapp.R, table definitions, the compressed ABC Atlas lookup, and requiredwww/files. Verify package versions and public package sources. Exclude local libraries, credentials, raw data, saved workspaces, and development-only activation files. - Deploy
code/shinywith rsconnect to the new account using application namemultiregion_gene_exploration. Create a new application for this first deployment; do not supply an application ID belonging to another account. - Record the assigned application ID and hosted URL. Review the build and runtime logs. Open the hosted app in a fresh browser session and repeat the startup, gene retrieval, plot, external-link, and bookmark checks.
- Commit the tested application files,
renv.lock, and deployment manifest. Keep the data-generation manifest in the data output directory separate from the Shiny deployment manifest.
11. Configure automated deployment
- Open
.github/workflows/deploy.ymlin the fork. Set the publishing account, application name, and application ID to the values assigned in Section 10. Retaincode/shinyas the application directory. - Add
SHINYAPPS_TOKENandSHINYAPPS_SECRETas GitHub Actions repository secrets. Use credentials authorized to publish to the new account. - Configure the workflow to publish using the committed deployment manifest. Validate its Shiny application mode, package records, and file inventory. Refresh bundled-file checksums while preserving the tested package metadata. Exclude the local
.Rprofilefrom the runtime bundle. - Validate YAML and embedded R syntax. Enable manual dispatch and deployment on pushes to
mainaffectingcode/shiny/**or the deployment workflow. Enable the workflow and run a manual deployment. - Review the Actions log and verify that the existing new application was updated rather than duplicated. Repeat the hosted startup and bookmark checks. Commit future package changes together with an updated lockfile and regenerated deployment manifest.
12. Publish the documentation and archive the release
- Place
index.htmlanddeployment_documentation.htmlin the repository root. Keep relative links between the two pages. Retain the image pathscode/shiny/www/app_logo.pngandcode/shiny/www/allen_institute_logo.svg. - Update repository links to the fork and application launch links to the new hosted URL. In each example bookmark, replace only the application base address; preserve the complete encoded
viewer_statequery string. - In GitHub repository settings, open Pages. Select Deploy from a branch, choose
mainand the repository root, and save. Open the published site and test navigation, images, application links, and every Getting started example. - Archive the source commit, environment definitions, lockfile, deployment manifest, ABC Atlas manifest, input checksums, CPS resource, URL-generation seed, Data Asset versions, S3 location, and validation record. Record the hosted app URL and documentation URL.