Skip to contents

Queries NCBI for every SRA run in a BioProject and returns one row per run (SRR, ERR or DRR accession), together with its experiment, library and sample metadata. The query runs [EDirect](https://www.ncbi.nlm.nih.gov/books/NBK179288/) inside the conda environment created by [setup_conda_sra()]:

Usage

get_bioproject_runs(bioproject, env_name = "sra_env")

Arguments

bioproject

BioProject accession, e.g. `"PRJNA123456"` (`PRJNA`, `PRJEB` and `PRJDB` accessions are accepted).

env_name

Name of the conda environment that has EDirect installed.

Value

A tibble with one row per SRA run. If the BioProject has no SRA runs, a tibble with no rows is returned with a warning.

Details

esearch -db sra -query <bioproject> | efetch -format xml

The columns are:

Run

`run_accession`, `run_alias`, `spots`, `bases`, `size` (bytes) and `published`.

Experiment

`experiment_accession`, `experiment_title` (the SRA metadata `title`), `library_name` (the SRA metadata `library_ID`), `library_strategy`, `library_source`, `library_selection`, `library_layout`, `platform` and `instrument_model`.

Study

`study_accession`, `bioproject` and `study_title`.

Sample

`sample_accession`, `biosample`, `organism` and `taxon_id`.

BioSample attributes

one column for each attribute given at BioSample submission, named as NCBI stores it, for example `sample_name`, `sample_title`, `host`, `isolation_source`, `collection_date`, `geo_loc_name`, `lat_lon` and `host_subject_id`. Samples without a given attribute get `NA`. An attribute whose name matches one of the columns above gets the suffix `_attribute`.

All columns are character, except `spots`, `bases` and `size`, which are numeric.

NCBI limits requests without an API key to 3 per second. EDirect uses the key in the `NCBI_API_KEY` environment variable when it is set, which helps with large BioProjects.

See also

[setup_conda_sra()] to create the environment.

Examples

if (FALSE) { # \dontrun{
runs <- get_bioproject_runs("PRJNA123456")
runs[, c("run_accession", "sample_name", "collection_date")]
} # }