Preparing an SRA submission of bacterial isolate genomes
Source:vignettes/microbe-workflow.Rmd
microbe-workflow.RmdThis vignette walks through preparing an NCBI Sequence Read Archive
(SRA) submission of bacterial isolate genomes with lims2sra:
adding the species identifications from a separate MALDI-TOF report to a
sample report exported from a LIMS (here, LabVantage), turning the
result into BioSample and SRA metadata tables with
prepare_sra_metadata(package = "microbe"), and using those
tables in the NCBI Submission Portal. It also shows how a folder of
sequence files that holds only some of the report’s isolates changes the
result.
The example report lists 25 bacterial isolates from the FACEMDRO
study, cultured from throat, stool, perirectal and environmental swabs,
that were sequenced as paired-end Illumina whole genomes. For
metagenomes, see
vignette("metagenome-workflow", package = "lims2sra").
The NCBI submission in brief
An SRA submission is made of three linked records:
- a BioProject, describing the study as a whole;
- one BioSample per isolate, describing the organism and where it came from: species, isolate name, host, source, collection date and place;
- one SRA experiment and run per sequencing library, describing how it was sequenced and listing its read files.
All three can be created in one pass through the SRA submission
wizard of the NCBI
Submission Portal. The wizard asks for two tables, which are what
prepare_sra_metadata() writes: a BioSample
attributes table, in the column layout of the Microbe BioSample
package, and an SRA metadata table. The two are joined
by sample_name.
1. Set up an analysis directory
Keep each submission in its own directory, with the LIMS and MALDI
reports under data/ and the files for NCBI under
submission/:
FACEMDRO/ <- working directory
├── data/
│ ├── IDSampleReport_lims2sra_microbe_demo.xlsx <- LIMS report
│ ├── maldi_report.csv <- MALDI-TOF identifications
│ └── IDSampleReport_with_species.xlsx <- joined report (step 3)
├── fastq/ <- read files (step 5)
└── submission/ <- files for NCBI (steps 4-5)
The demo reports ship with lims2sra, in the
vignettes/microbe-demo/data/ folder of the package
source.
2. Read the sample report
library(lims2sra)
report <- readxl::read_excel("data/IDSampleReport_lims2sra_microbe_demo.xlsx")
dim(report)
#> [1] 25 18
knitr::kable(head(report[, c("Sample", "Sample Type", "Original Sample Type",
"Microbial Species", "External Participant ID",
"Collection Date")], 5))| Sample | Sample Type | Original Sample Type | Microbial Species | External Participant ID | Collection Date |
|---|---|---|---|---|---|
| S_240926_02278 | Bacterial Cell Iso | Throat Swab | NA | P003 | 2024-05-27 |
| S_240926_01702 | Bacterial Cell Iso | Environmental Swab | NA | P002 | 2024-05-27 |
| S_241030_02613 | Bacterial Cell Iso | Stool Swab | NA | P006 | 2024-05-27 |
| S_241022_01622 | Bacterial Cell Iso | Throat Swab | NA | P005 | 2024-05-27 |
| S_241022_01625 | Bacterial Cell Iso | Stool Swab | NA | P005 | 2024-05-27 |
prepare_sra_metadata() needs Sample,
Sample Type and Collection Date, and for the
microbe package it takes each isolate’s organism from
Microbial Species. It also uses
Original Sample Type and
External Participant ID when they are present; every other
column, including the internal Participant ID, the
custodian and the storage location, stays out of the submission.
Every isolate has the Sample Type “Bacterial Cell Iso”,
and its Original Sample Type records the specimen it was
cultured from:
table(report$`Sample Type`)
#>
#> Bacterial Cell Iso
#> 25
table(report$`Original Sample Type`)
#>
#> Environmental Swab Perirectal Swab Stool Swab Throat Swab
#> 7 4 6 8But Microbial Species is empty: the species were
identified by MALDI-TOF, and the identifications were never entered in
the LIMS.
3. Add the species from the MALDI report
The MALDI-TOF report lists each specimen ID with its identification:
maldi <- read.csv("data/maldi_report.csv")
dim(maldi)
#> [1] 25 2
head(maldi)
#> specimen_id microbial_species
#> 1 S_240926_01702 Pseudomonas aeruginosa
#> 2 S_240926_02278 Staphylococcus aureus
#> 3 S_241022_01622 Klebsiella aerogenes
#> 4 S_241022_01625 Escherichia coli
#> 5 S_241030_02613 Enterococcus faecalis
#> 6 S_241111_00791 Pseudomonas aeruginosaBefore joining, check that the two reports use the same IDs, written the same way. Every LIMS sample should have exactly one identification, and every identification should belong to a LIMS sample:
setdiff(report$Sample, maldi$specimen_id) # LIMS samples with no MALDI ID
#> character(0)
setdiff(maldi$specimen_id, report$Sample) # MALDI IDs not in the LIMS report
#> character(0)
anyDuplicated(maldi$specimen_id)
#> [1] 0Here they match exactly. If they did not, for example because one
system writes S_240926_02278 and the other
S-240926-02278 (the LIMS itself uses hyphens in its
Immediate Parent column), rewrite one set of IDs to match
the other, e.g. with gsub("-", "_", maldi$specimen_id),
before joining.
Fill in Microbial Species by matching on the specimen
ID, then save the joined report, since
prepare_sra_metadata() reads its input from a file:
report$`Microbial Species` <-
maldi$microbial_species[match(report$Sample, maldi$specimen_id)]
sort(table(report$`Microbial Species`), decreasing = TRUE)
#>
#> Enterococcus faecium Pseudomonas aeruginosa
#> 8 6
#> Staphylococcus aureus Escherichia coli
#> 3 2
#> Klebsiella aerogenes Klebsiella pneumoniae
#> 2 2
#> Enterococcus faecalis Staphylococcus ureilyticus
#> 1 1
joined_xlsx <- "data/IDSampleReport_with_species.xlsx"
writexl::write_xlsx(report, joined_xlsx)The organism must be a valid NCBI Taxonomy name, which species-level MALDI identifications are; check any that are reported only to the genus, or as a complex, against https://www.ncbi.nlm.nih.gov/taxonomy first.
prepare_sra_metadata() also has a
microbe_organism argument, but a vector given there is
matched to the samples by position. Joining into the report keeps each
species attached to its own isolate, including when some isolates are
dropped for lack of sequence files (step 5).
4. Prepare the BioSample and SRA metadata
Give the attributes that are the same for every isolate: the location
of collection (in the INSDC country vocabulary, and optionally as
latitude and longitude), the mandatory Microbe sample_type,
and the sequencing details. “Bacterial Cell Iso” is one of the default
derived_sample_types, so each isolate is described by the
specimen it was cultured from, its Original Sample Type;
add any other isolate types your LIMS uses to that argument.
meta <- prepare_sra_metadata(
joined_xlsx,
package = "microbe",
output_dir = "submission",
geo_loc_name = "USA: Pennsylvania, Philadelphia",
lat_lon = "39.95 N 75.19 W",
microbe_sample_type = "cell culture",
library_strategy = "WGS",
library_selection = "RANDOM",
platform = "ILLUMINA",
instrument_model = "Illumina NovaSeq 6000"
)
#> Wrote 25 samples (50 FASTQ files) for package 'microbe':
#> submission/Microbe.1.0_biosample_attributes.tsv
#> submission/Microbe.1.0_sra_metadata.tsv
#> submission/Microbe.1.0_submission.xlsxLeave bioproject_accession blank when the BioProject is
created in the same submission; if it already exists, give its accession
(e.g. "PRJNA123456").
The output files
list.files("submission")
#> [1] "Microbe.1.0_biosample_attributes.tsv"
#> [2] "Microbe.1.0_sra_metadata.tsv"
#> [3] "Microbe.1.0_submission.xlsx"| File | Contents | Used in the Submission Portal at |
|---|---|---|
Microbe.1.0_biosample_attributes.tsv |
one row per isolate, in the column order of NCBI’s Microbe (v1.0) BioSample package | the BioSample attributes step |
Microbe.1.0_sra_metadata.tsv |
one row per isolate, with its library details and its R1 and R2 file names | the SRA metadata step |
Microbe.1.0_submission.xlsx |
both tables, as sheets BioSample and
SRA_data
|
for review, or for combining several runs |
The same two tables are returned as data frames, so they can be checked in R before anything is uploaded.
BioSample attributes
names(meta$biosample)
#> [1] "*sample_name" "sample_title" "bioproject_accession"
#> [4] "*organism" "strain" "isolate"
#> [7] "host" "isolation_source" "*collection_date"
#> [10] "*geo_loc_name" "*sample_type" "altitude"
#> [13] "biomaterial_provider" "collected_by" "culture_collection"
#> [16] "depth" "env_broad_scale" "genotype"
#> [19] "host_tissue_sampled" "identified_by" "lab_host"
#> [22] "lat_lon" "mating_type" "passage_history"
#> [25] "samp_size" "serotype" "serovar"
#> [28] "specimen_voucher" "temp" "description"
#> [31] "host_subject_id"
knitr::kable(head(meta$biosample[, c("*sample_name", "*organism", "isolate",
"host", "isolation_source",
"host_tissue_sampled", "*sample_type",
"host_subject_id")], 6))| *sample_name | *organism | isolate | host | isolation_source | host_tissue_sampled | *sample_type | host_subject_id |
|---|---|---|---|---|---|---|---|
| S_240926_02278 | Staphylococcus aureus | S_240926_02278 | Homo sapiens | Throat Swab | oropharynx | cell culture | P003 |
| S_240926_01702 | Pseudomonas aeruginosa | S_240926_01702 | Environmental Swab | cell culture | P002 | ||
| S_241030_02613 | Enterococcus faecalis | S_241030_02613 | Homo sapiens | Stool Swab | feces | cell culture | P006 |
| S_241022_01622 | Klebsiella aerogenes | S_241022_01622 | Homo sapiens | Throat Swab | oropharynx | cell culture | P005 |
| S_241022_01625 | Escherichia coli | S_241022_01625 | Homo sapiens | Stool Swab | feces | cell culture | P005 |
| S_241111_00791 | Pseudomonas aeruginosa | S_241111_00791 | Environmental Swab | cell culture | P007 |
Column names starting with * are mandatory in the
package template; the portal reads them with or without the asterisk.
The Microbe package also requires at least one of strain
and isolate, and at least one of host and
isolation_source. lims2sra fills them in as
follows:
| Attribute | Value |
|---|---|
organism |
the Microbial Species added in step 3 |
isolate |
the LIMS Sample ID, which identifies the isolate |
isolation_source |
the specimen the isolate was cultured from
(Original Sample Type) |
host_tissue_sampled |
the body site of that specimen, from the body_site
mapping (blank for environmental swabs) |
host |
"Homo sapiens", except for isolates cultured from the
built environment (environmental_sample_types, which
include environmental swabs), which have no host |
host_subject_id |
the External Participant ID, added after the template
columns as a custom attribute |
collection_date and host_subject_id are
released publicly with the BioSamples. Check that the subject IDs cannot
identify participants, and whether your protocol requires dates to be
coarsened.
SRA metadata
names(meta$sra)
#> [1] "sample_name" "library_ID" "title"
#> [4] "library_strategy" "library_source" "library_selection"
#> [7] "library_layout" "platform" "instrument_model"
#> [10] "design_description" "filetype" "filename"
#> [13] "filename2"
knitr::kable(head(meta$sra[, c("sample_name", "title", "library_source",
"filename", "filename2")], 3))| sample_name | title | library_source | filename | filename2 |
|---|---|---|---|---|
| S_240926_02278 | Whole-genome sequencing of Staphylococcus aureus isolate S_240926_02278 | GENOMIC | S_240926_02278_R1.fastq.gz | S_240926_02278_R2.fastq.gz |
| S_240926_01702 | Whole-genome sequencing of Pseudomonas aeruginosa isolate S_240926_01702 | GENOMIC | S_240926_01702_R1.fastq.gz | S_240926_01702_R2.fastq.gz |
| S_241030_02613 | Whole-genome sequencing of Enterococcus faecalis isolate S_241030_02613 | GENOMIC | S_241030_02613_R1.fastq.gz | S_241030_02613_R2.fastq.gz |
meta$sra$design_description[1]
#> [1] "Paired-end whole-genome sequencing of DNA extracted from an isolate cultured from throat swab"Each run’s title names its organism and isolate, and its
design_description the specimen the isolate was cultured
from; give design_description to describe the library
preparation in more detail. library_source defaults to
GENOMIC for the microbe package. Without a FASTQ folder,
the read files are assumed to be named
<Sample>_R1.fastq.gz and
<Sample>_R2.fastq.gz. Sequencing cores rarely name
them that way, so in practice give the folder with the reads, as in the
next step.
5. Match the isolates to a folder of FASTQ files
A sequencing run often holds only some of a report’s isolates, and
may hold more than one set of reads for an isolate that was sequenced
again to reach the coverage wanted. For this example, make a
hypothetical run folder with empty files named the way Illumina’s
demultiplexing names them
(<Sample>_S<n>_R1_001.fastq.gz):
- 21 of the 25 isolates, each with an R1 and an R2 file;
- a second pair of files for one of them,
S_241022_01625, from a top-up run; - the run’s
Undeterminedreads, which belong to no isolate.
dir.create("fastq", showWarnings = FALSE)
sequenced <- report$Sample[1:21]
stems <- c(paste0(sequenced, "_S", seq_along(sequenced)),
"S_241022_01625_S40", "Undetermined_S0")
fastq_files <- c(paste0(stems, "_R1_001.fastq.gz"),
paste0(stems, "_R2_001.fastq.gz"))
invisible(file.create(file.path("fastq", fastq_files)))
head(sort(list.files("fastq")), 4)
#> [1] "S_240926_01702_S2_R1_001.fastq.gz" "S_240926_01702_S2_R2_001.fastq.gz"
#> [3] "S_240926_02278_S1_R1_001.fastq.gz" "S_240926_02278_S1_R2_001.fastq.gz"
length(list.files("fastq"))
#> [1] 46Pass the folder as fastq_dir, with the same arguments as
before:
meta_run <- prepare_sra_metadata(
joined_xlsx,
package = "microbe",
output_dir = "submission",
geo_loc_name = "USA: Pennsylvania, Philadelphia",
lat_lon = "39.95 N 75.19 W",
microbe_sample_type = "cell culture",
fastq_dir = "fastq",
instrument_model = "Illumina NovaSeq 6000"
)
#> Warning: 1 sample(s) match more than one pair of FASTQ files in fastq; only one
#> pair was used for each: S_241022_01625
#> Sample name matches between input_xlsx and fastq_dir:
#> input_xlsx samples found in fastq_dir: 21 of 25 (84.0%)
#> fastq_dir samples found in input_xlsx: 22 of 23 (95.7%)
#> Warning: 4 sample(s) lack an R1 and/or R2 file in fastq and were dropped:
#> S_250605_01642, S_250618_00004, S_250814_00377, S_250923_00607
#> Wrote 21 samples (42 FASTQ files) for package 'microbe':
#> submission/Microbe.1.0_biosample_attributes.tsv
#> submission/Microbe.1.0_sra_metadata.tsv
#> submission/Microbe.1.0_submission.xlsxFour things happen:
-
The match is summarized. 21 of the 25 report
isolates have files in the folder, and 22 of the 23 sample names in the
folder (stems before
_R1/_R2) belong to a report isolate: the one that does not isUndetermined_S0, which is ignored. -
An isolate with two pairs of files gets one. A
warning names
S_241022_01625, and only its first pair,_S5, is listed. - Isolates without both read files are dropped, with a warning naming them: here the 4 isolates that are not in the run. They are left out of both tables.
-
The actual file names are used in
filenameandfilename2:
nrow(meta_run$biosample)
#> [1] 21
knitr::kable(meta_run$sra[meta_run$sra$sample_name %in%
c("S_240926_02278", "S_241022_01625"),
c("sample_name", "filename", "filename2")],
row.names = FALSE)| sample_name | filename | filename2 |
|---|---|---|
| S_240926_02278 | S_240926_02278_S1_R1_001.fastq.gz | S_240926_02278_S1_R2_001.fastq.gz |
| S_241022_01625 | S_241022_01625_S5_R1_001.fastq.gz | S_241022_01625_S5_R2_001.fastq.gz |
So the outputs describe only the 21 isolates that can be submitted
now, and list exactly the 42 files to upload for them. The 4 isolates
not yet sequenced can go in a later submission. To submit both pairs of
the re-sequenced isolate as one run, either concatenate each read’s
files (gzipped FASTQ files can be joined with cat, keeping
R1 with R1 and R2 with R2) and list the combined files, or add the
second pair to that isolate’s row in the SRA metadata table as
filename3 and filename4.
Matching is exact, character for character: if the sequencing core
changed the IDs (e.g. _ to -), no isolates
match, and prepare_sra_metadata() stops with an error. Make
the report’s Sample IDs match the file names, as in step 3,
and run it again.
6. Submit to NCBI
With the BioSample attributes table, the SRA metadata table and the FASTQ files ready, start a new submission at https://submit.ncbi.nlm.nih.gov/subs/sra/ and work through the wizard:
- Submitter and General info. Say whether the BioProject and BioSamples already exist (here, they do not) and set the release date.
- Project info. Describe the BioProject, if it is new.
-
BioSample type. Choose Microbe, the
package that
package = "microbe"targets. -
BioSample attributes. Upload
Microbe.1.0_biosample_attributes.tsv. The portal checks mandatory fields, organism names, controlled vocabularies (e.g.geo_loc_name) and duplicate attributes, and lists any errors to fix. -
SRA metadata. Upload
Microbe.1.0_sra_metadata.tsv. Each row is linked to its BioSample bysample_name. -
Files. Upload the FASTQ files listed in
filenameandfilename2. For more than a few files, use the FTP or Aspera preload option: the portal gives you an upload folder in your account, where you make a folder for this submission and put the files, with no subfolders, then select it in this step. Upload exactly the files in the SRA metadata table: here the 42 files of the 21 sequenced isolates, not theUndeterminedreads, and not the top-up pair ofS_241022_01625unless you combined or added it as above. The portal checks that each listed file is present. - Review and submit.
After processing, NCBI assigns accessions: a BioProject (PRJNA), a BioSample (SAMN) for each isolate and an SRA run (SRR) for each library, which can be cited in publications and data availability statements. Genome assemblies of the isolates can later be submitted to GenBank against the same BioSamples.
Next steps
-
Several sequencing runs. Run
prepare_sra_metadata()once per run folder, each with its ownoutput_dir, then combine the tables (e.g. withrbind()) into one submission, or submit each run separately. -
Other specimen types. Isolates cultured from
specimen types missing from
body_siteget a blankhost_tissue_sampled; add them to the mapping, and add any other non-host specimen types toenvironmental_sample_types(see?prepare_sra_metadatafor the defaults). -
Metagenomes. Specimens sequenced directly, without
culture, belong in the Metagenome or environmental package: use
package = "metagenome".