elink() offers direct access to the ELink API endpoint, which has many different
input and output formats depending on parameters. If you just want a one-to-one
mapping of neighbor links, use elink_map(), which handles this for you.
Usage
elink(
id_set,
db,
...,
retmode = "xml",
cmd = NA,
.paginate = 100L,
.process = NA,
.method = NA,
.multi = "explode",
.progress = TRUE,
.cookies = NA,
.path = NULL,
.call = current_env()
)
elink_map(id_set, db, ..., .cookies = NA, .path = NULL, .call = current_env())Arguments
- id_set
ID set object.
- db
target database name.
- ...
additional API parameters (refer to Entrez documentation). Any set to
NULLare removed.- retmode
response format.
- cmd
ELink command. If
NAeither"neighbor"or"neighbor_history"will be used based on the type of input.- .paginate
maximum number of UIDs to submit per request.
.paginateonly applies whenid_setis an explicit list. Set toFALSEto prevent batching.- .process
function that processes the API results. Can be a function or builtin processor as described in
process. Additional builtin processors are available:"sets"to get a data frame of ID set objects,"flat"to get a data frame of UIDs, orNAto use a sensible choice based on parameters.- .method
HTTP verb. For
"POST", any params with vector values (usually justid) are sent in the request body instead of the URL.- .multi
controls how repeated params are handled (see
httr2::req_url_query()).- .progress
controls progress bar; see the
progressargument ofhttr2::req_perform_iterative().path to persist cookies. If
NULL, cookies are not added to the request. For helper functions: whenNA, a temporary file is created (in this case only, the temporary file will be cleaned up once all requests are performed).- .path
path specification for saving raw responses. See
pathargument ofhttr2::req_perform_iterative().- .call
call environment to use in error messages/traces. See rlang::topic-error-call and the
callargument ofcli::cli_abort(). You only need to specify this in internal helper functions that don't need to be mentioned in error messages.
Value
concatenated output of .process.
For elink(.process = "sets") a data frame with columns
fromSource link set.
toTarget link set.
linknameLink name (see https://eutils.ncbi.nlm.nih.gov/entrez/query/static/entrezlinks.html or
einfo).
For elink_map() and elink(.process = "flat") a data frame with columns
db_fromSource database name.
id_fromSource identifier. Can be a list column depending on how
elinkwas called.db_toTarget database name.
linknameLink name (see https://eutils.ncbi.nlm.nih.gov/entrez/query/static/entrezlinks.html or
einfo).id_toTarget identifier. In general this will be a list column.
One-to-one mapping
Note that some ways of calling this API on multiple UIDs result in the one-to-one
association of the input and output sets getting lost. The way around this is to
specify each ID as a separate parameter rather than a single comma-separated param.
This is handled by the default choice of .multi = "explode". When using a web
history token as input, there is no corresponding way to ensure one-to-one mapping.
To ensure that the result is always one-to-one, use elink_map(), which may make
several API requests to achieve the result.