why do this?
As a step-by-step tutorial to guides users build their own scRNAseq database by R package - SeuratExplorerServer, which also provide researchers a new tool to investigate fly scRNAseq data.
Check the demo database, Account: shiny, Password: 12345.
Download data from FLY CELL ATLAS, only select H5AD files.
Refer to s1_download-h5ad-files.md: manually copy the Data Table from the Fly Cell Atlas website (select "Show 100 entries", select all, paste into Excel).
All download links have already been extracted and saved in input-data_updated.csv (column H5AD_Links), in the format:
https://cloud.flycellatlas.org/index.php/s/{token}/download/{filename}.h5ad
Use download managers, such as Neat Download Manager (for windows) or Uget (for linux). Download all H5AD files into a flat directory, e.g. Downloaded_Data/.
s2.0_arrange-data-meta.R: read input-data_updated.csv, deduplicate filenames (append (1) to duplicates), check file existence, add SCope/ASAP external viewer links, rename columns, and output metadata.csv.
metadata.csv is the master metadata table used by downstream conversion (step 2) and the index page (step 3.4).
All Fly Cell Atlas single-cell data (both 10x and SMART-seq2) was mapped to the same reference:
| Item | Version |
|---|---|
| Genome assembly | BDGP6 (dm6), patch BDGP6.31 |
| Gene annotation | FlyBase release 6.31 (r6.31) |
| Reference type | pre-mRNA (introns retained, for single-nucleus sequencing) |
| Cell Ranger | v3.1.0 (for 10x data) |
See Reference-used-infered-by-AI.md for the full derivation.
s2.1_trans-anndata-to-seurat.sh: create a conda environment scanpy and install scanpy, anndata, numpy, pandas, jupyter.
conda create --name scanpy
conda activate scanpy
conda install scanpy anndata numpy pandas jupyter
jupyter-notebooks2.2_update-anndata-to-use-raw.ipynb: for each H5AD file, convert to raw counts if adata.raw exists (raw usually has more genes), and save as *_new.h5ad.
Key logic per file:
- If
*_new.h5adalready exists → skip (printescaped!). - If
adata.rawis not None → back upobsm['X_umap'],obsm['X_tsne'], anduns; doadata = adata.raw.to_adata(); restore the backed-up embeddings anduns; write*_new.h5ad. - If
adata.rawis None → skip (printEscaped for no raw data found!).
The UMAP/tSNE/uns backup is necessary because
raw.to_adata()only carries over X/var/obs and dropsobsmanduns.
The notebook also generates two cell-count reports:
cell_counts.txt: filename and cell count (adata.n_obs) for each original H5AD.cell_counts_new.txt: filename and cell count for each*_new.h5ad.
s2.3_trans-anndata-to-seurat.R: use R package schard to convert H5AD files to Seurat objects, saved in .qs2 format (via qs2).
Workflow:
- Read
metadata.csv; for each tissue, create a parent directoryData/{Tissue}/; for each analysis, createData/{Tissue}/{Analysis}/. - For each analysis, prefer the
*_new.h5adfile (from step 2.2) if it exists, otherwise fall back to the original H5AD. - Convert via
h5ad2seurat()and save as.qs2. Skip if the.qs2already exists. Errors are caught withtryCatchso one failure does not stop the batch. - Second pass: read back each
.qs2file, record cell count (ncol) intometadata.csv. - Aggregate metadata by tissue (collapse multiple analyses per tissue into semicolon-separated strings) and write
meta_data_index.csv.
Output directory structure:
Data/
├── Antenna/
│ ├── 10x_and_SMART-seq2_Integrated_Antenna/
│ │ └── antenna.qs2
│ ├── 10x_VSN_Antenna_(Relaxed)/
│ │ └── r_fca_biohub_antenna_10x.qs2
│ └── ...
├── Body/
│ └── ...
└── ...
Build directories bellow, which should under shinyserver site directory, refer to 'Database Deployment Guide' part from fentouxungui/SeuratExplorerServer
shiny-server/
├── apps
└── index-page
apps to save individual app for each tissue
index-page to browse all apps, which has included all urls of all apps
s3.1_generate-credentials-file.R: use shinymanager to create a credentials file credentials.rds.
After creating credentials, modify the credentials parameter in app.R_demo file to point to the absolute path of credentials.rds.
s3.2_batch-generate-apps.R: batch create apps for each tissue using SeuratExplorerServer.
For each tissue directory under ../Data:
- Create
../shiny-server/apps/{tissue}/. - Copy
app.R_demointo it asapp.R. - Scan for
.qs2/.rdsfiles recursively under../Data/{tissue}/. - Initialize metadata (
initialize_metadata) and save asdata_meta.rds.
Now you can test each app by use url: IP address plus app directory
in the demo: http://netinfo.nibs.ac.cn:666 is the shiny-server IP address (with port), FlyCellAtlas-SES/shiny-server/apps/Antenna/ is the relative path to shiny-server site directory. The demo shiny-server site directory is set to /home/zhangyc/ShinyServer.
app.R_index.R: modify IP_address, relative_path, downloaded_data_info_file. then put it into index-page directory, and rename it to app.R.
The index page reads meta_data_index.csv (generated by step 2.3) and displays an interactive table with:
- Tissue, Analysis, Technology, Age, Sex, Number of samples
- Cell counts per analysis
- Data link (to the tissue's Shiny app)
- H5AD download links (direct download from Fly Cell Atlas cloud)
- External viewer links (SCope, ASAP)
The info box documents the reference genome: FlyBase r6.31 pre-mRNA, CellRanger v3.1.0.
now you can visit index page use url: IP address plus index app directory
in the demo: http://netinfo.nibs.ac.cn:666 is the shiny-server IP address (with port), FlyCellAtlas-SES/shiny-server/index-page/ is the relative path to shiny-server site directory. The demo shiny-server site directory is set to /home/zhangyc/ShinyServer.
| Script | Description |
|---|---|
s1_download-h5ad-files.md |
Guide for obtaining H5AD download links from Fly Cell Atlas |
s2.0_arrange-data-meta.R |
Process input-data_updated.csv into metadata.csv |
s2.1_trans-anndata-to-seurat.sh |
Create conda environment with scanpy/anndata |
s2.2_update-anndata-to-use-raw.ipynb |
Convert H5AD to raw counts, preserve embeddings, generate cell-count reports |
s2.3_trans-anndata-to-seurat.R |
Convert H5AD to Seurat .qs2, organize by tissue/analysis, generate meta_data_index.csv |
s3.1_generate-credentials-file.R |
Generate credentials.rds via shinymanager |
s3.2_batch-generate-apps.R |
Batch generate Shiny apps per tissue |
app.R_demo |
Template app.R for each tissue app |
app.R_index.R |
Index page app showing all datasets with links |
input-data_updated.csv |
Master table with H5AD download links |
metadata.csv |
Processed metadata (generated by s2.0) |
meta_data_index.csv |
Tissue-aggregated metadata with cell counts (generated by s2.3) |
Reference-used-infered-by-AI.md |
Documentation of reference genome version |
All data and scripts can be downloaded from Fly Cell Atlas - by SeuratExplorer Server, and the scripts can also be downloaded from github - fentouxungui/FlyCellAtlas-SES
Congratulations!