Introduction to remart

Overview

The remart package provides a possible replacement for biomaRt workflows. It keeps familiar function names and signatures while replacing the BioMart backend with the Ensembl REST API.

remart is not (yet?) a complete implementation of the BioMart query language. It currently supports a focused set of gene and transcript annotation queries, sequence retrieval, and orthologue queries. Interaction with non-Ensembl Marts should still be done with biomaRt.

remart should not only be more stable, faster, but also hopefully more user-friendly than biomaRt, as many arguments are no longer necessary. These arguments are silently accepted for compatibility, but they are ignored.

All annotation and sequence examples in this vignette query live Ensembl services. They require an internet connection, and results can change as Ensembl releases and annotations are updated.

Although they are different approaches and interface, there is some overlap in functionality between remart and ensembldb. EnsDb objects from ensembldb, available through AnnotationHub, give offline, release-pinned access to gene, transcript and protein annotation, and they do not depend on the availability of a web service at analysis time.

Beyond subjective preferences about interface, remart is mainly useful when:

  • existing code written against biomaRt should keep working with minimal changes,
  • orthologue queries are needed, through the Ensembl homology endpoint,

Finally, remart and ensembldb rely on different Ensembl APIs, which might have availability issues at different times. The option to use both packages in a complementary manner can help mitigate such issues.

Installation and loading

You can install remart from Bioconductor (after acceptance and release):

BiocManager::install("remart")

The development version can be installed from GitHub with:

BiocManager::install("Huber-group-EMBL/remart")

Load the package in an R session with:

library(remart)

Before anything else, we check if the Ensembl service is online using is_ensembl_online():

ensembl_online <- is_ensembl_online(version = "may2024")
if (!ensembl_online) {
  message(
    "Ensembl service is currently offline.",
    "The remart queries in this vignette will not be executed."
  )
}

Discover supported attributes

listAttributes() reports the attributes currently implemented by remart:

listAttributes()
#>  [1] "chromosome_name"       "description"           "end_position"         
#>  [4] "ensembl_gene_id"       "ensembl_peptide_id"    "ensembl_transcript_id"
#>  [7] "external_gene_name"    "gene_biotype"          "hgnc_symbol"          
#> [10] "start_position"        "strand"                "transcript_biotype"   
#> [13] "version"

The supported filters for getBM() are currently limited to ensembl_gene_id, ensembl_transcript_id and external_gene_name, and only one filter can be used per call.

Retrieve gene annotations

getBM() accepts the familiar attributes, filters, and values arguments. The following query retrieves basic annotations for two human Ensembl genes. The connection to Ensembl is handled internally, so a mart object is not required.

gene_ids <- c("ENSG00000157764", "ENSG00000004939")

gene_annotations <- getBM(
  attributes = c(
    "ensembl_gene_id",
    "external_gene_name",
    "chromosome_name",
    "start_position",
    "end_position"
  ),
  filters = "ensembl_gene_id",
  values = gene_ids,
  version = "may2024"
)

head(gene_annotations)
#>   ensembl_gene_id external_gene_name chromosome_name start_position
#> 1 ENSG00000157764               BRAF               7      140719327
#> 2 ENSG00000004939             SLC4A1              17       44248390
#>   end_position
#> 1    140924929
#> 2     44268141

Attributes are returned in the order requested. Duplicate identifiers are handled internally, while identifiers that Ensembl cannot find are omitted with a warning.

Retrieve transcript-level annotations

Transcript-level attributes can be requested using gene identifiers. Because a gene can have multiple transcripts, this may return multiple rows for one gene.

transcript_annotations <- getBM(
  attributes = c(
    "ensembl_gene_id",
    "ensembl_transcript_id",
    "ensembl_peptide_id",
    "transcript_biotype"
  ),
  filters = "ensembl_gene_id",
  values = "ENSG00000157764",
  version = "may2024"
)

head(transcript_annotations)
#>   ensembl_gene_id ensembl_transcript_id ensembl_peptide_id
#> 1 ENSG00000157764       ENST00000496384    ENSP00000419060
#> 2 ENSG00000157764       ENST00000644969    ENSP00000496776
#> 3 ENSG00000157764       ENST00000644120               <NA>
#> 4 ENSG00000157764       ENST00000642875               <NA>
#> 5 ENSG00000157764       ENST00000646891    ENSP00000493543
#> 6 ENSG00000157764       ENST00000644905               <NA>
#>               transcript_biotype
#> 1                 protein_coding
#> 2                 protein_coding
#> 3 protein_coding_CDS_not_defined
#> 4                retained_intron
#> 5                 protein_coding
#> 6                retained_intron

Alternatively, transcript identifiers can be used as the filter when the query is transcript-oriented:

getBM(
  attributes = c(
    "ensembl_transcript_id",
    "ensembl_gene_id",
    "ensembl_peptide_id"
  ),
  filters = "ensembl_transcript_id",
  values = "ENST00000357654",
  version = "may2024"
)
#>   ensembl_transcript_id ensembl_gene_id ensembl_peptide_id
#> 1       ENST00000357654 ENSG00000012048    ENSP00000350283

Use the getGene() compatibility wrapper

For workflows written around biomaRt::getGene(), getGene() provides a convenient gene-level interface:

getGene(
  id = c("ENSG00000157764", "ENSG00000004939"),
  type = "ensembl_gene_id",
  version = "may2024"
)
#>   ensembl_gene_id hgnc_symbol
#> 1 ENSG00000157764        BRAF
#> 2 ENSG00000004939      SLC4A1
#>                                                                                description
#> 1         B-Raf proto-oncogene, serine/threonine kinase [Source:HGNC Symbol;Acc:HGNC:1097]
#> 2 solute carrier family 4 member 1 (Diego blood group) [Source:HGNC Symbol;Acc:HGNC:11027]
#>   chromosome_name band strand start_position end_position
#> 1               7   NA     -1      140719327    140924929
#> 2              17   NA     -1       44248390     44268141

The returned columns include ensembl_gene_id, hgnc_symbol, genomic coordinates, strand, and description. Ensembl’s REST response does not provide the band field used by biomaRt, so remart returns band as NA with a warning.

Retrieve sequences

getSequence() retrieves sequences by Ensembl gene, transcript, or peptide identifier.

For example, a cDNA sequence can be retrieved for a transcript as follows:

cdna <- getSequence(
  seqType = "cdna",
  type = "ensembl_transcript_id",
  id = "ENST00000357654",
  version = "may2024"
)

summary(cdna)
#>    desc                 id          molecule       query           seq      
#>  Mode:logical   Length   : 1   Length   :1   Length   : 1   Length   :   1  
#>  NAs :1         N.unique : 1   N.unique :1   N.unique : 1   N.unique :   1  
#>                 N.blank  : 0   N.blank  :0   N.blank  : 0   N.blank  :   0  
#>                 Min.nchar:15   Min.nchar:3   Min.nchar:15   Min.nchar:7088  
#>                 Max.nchar:15   Max.nchar:3   Max.nchar:15   Max.nchar:7088  
#>                                                                             
#>     version 
#>  Min.   :9  
#>  1st Qu.:9  
#>  Median :9  
#>  Mean   :9  
#>  3rd Qu.:9  
#>  Max.   :9

Upstream and downstream bases can be requested for supported sequence queries:

extended_cdna <- getSequence(
  seqType = "cdna",
  type = "ensembl_transcript_id",
  id = "ENST00000357654",
  upstream = 100,
  downstream = 100,
  version = "may2024"
)

summary(extended_cdna)
#>    desc                 id          molecule       query           seq      
#>  Mode:logical   Length   : 1   Length   :1   Length   : 1   Length   :   1  
#>  NAs :1         N.unique : 1   N.unique :1   N.unique : 1   N.unique :   1  
#>                 N.blank  : 0   N.blank  :0   N.blank  : 0   N.blank  :   0  
#>                 Min.nchar:15   Min.nchar:3   Min.nchar:15   Min.nchar:7088  
#>                 Max.nchar:15   Max.nchar:3   Max.nchar:15   Max.nchar:7088  
#>                                                                             
#>     version 
#>  Min.   :9  
#>  1st Qu.:9  
#>  Median :9  
#>  Mean   :9  
#>  3rd Qu.:9  
#>  Max.   :9

Coordinate-based requests using chromosome, start, and end are not yet implemented.

Find orthologues

getLDS() retains the familiar biomaRt name, but its current implementation is specifically for orthology queries through Ensembl’s homology endpoint. The target species is supplied with speciesL; this replaces the linked martL connection used by biomaRt.

The following example searches for mouse orthologues of a human gene:

orthologues <- getLDS(
  attributes = c("ensembl_gene_id", "external_gene_name"),
  filters = "ensembl_gene_id",
  values = "ENSG00000157764",
  attributesL = c("ensembl_gene_id", "external_gene_name"),
  speciesL = "mouse",
  version = "may2024"
)

orthologues
#>   ensembl_gene_id external_gene_name  ensembl_gene_id.1 external_gene_name.1
#> 1 ENSG00000157764               BRAF ENSMUSG00000002413                 Braf

Only ensembl_gene_id and external_gene_name are currently supported as the source filter. Source and target attributes are gene-level attributes; transcript-level linked queries are not yet supported.

Supported functionality

The table below summarises what each function supports. Filters, attributes and seqType values not listed here are rejected with an error or, for arguments passed through ..., silently ignored.

Function Supported filters / type / seqType Supported attributes Differences from biomaRt Not yet supported (and where to go instead)
getBM() Filters (one at a time): ensembl_gene_id, ensembl_transcript_id, external_gene_name (requires species) ensembl_gene_id, ensembl_transcript_id, ensembl_peptide_id, external_gene_name, hgnc_symbol, description, chromosome_name, start_position, end_position, strand, gene_biotype, transcript_biotype, version (see listAttributes()) mart and other connection arguments are ignored; species replaces the species inferred from mart; version replaces the Ensembl release version inferred from mart Multiple filters, other filters, and other attributes (e.g. external database IDs such as entrezgene_id). Use biomaRt for non-Ensembl marts or for these queries.
getGene() type = "ensembl_gene_id" (default) or "external_gene_name" (requires species) Fixed set: ensembl_gene_id, hgnc_symbol, description, chromosome_name, band, strand, start_position, end_position band is always NA (not available from the REST API); mart is ignored; species and version are added Other biomaRt identifier types and band values. Use getBM() for other attributes, or biomaRt.
getSequence() type: ensembl_gene_id, ensembl_transcript_id, ensembl_peptide_id; seqType: gene_exon_intron, cdna, peptide; upstream / downstream in base pairs Not applicable (returns sequences) chromosome, start and end are not yet implemented (and throw an error) but are kept for positional compatibility; mart, useCache and verbose are ignored; version is added Coordinate-based retrieval (chromosome, start, end). Use biomaRt::getSequence() for now. Non-Ensembl type values (e.g. hgnc, refseq) are not yet supported.
getLDS() Source filters: ensembl_gene_id, external_gene_name (requires species); target filter filtersL: one gene-level attribute, or "" Gene-level attributes only, for both the source (attributes) and target (attributesL) species: ensembl_gene_id, external_gene_name, hgnc_symbol, description, chromosome_name, start_position, end_position, strand, gene_biotype, transcript_biotype, version. Transcript-level attributes (e.g. ensembl_transcript_id, ensembl_peptide_id) are not supported. Orthologue queries only (Ensembl homology/id); the target species is given with speciesL instead of martL; mart, martL, verbose, uniqueRows and bmHeader are ignored Transcript-level attributes, and general cross-database linking. Use biomaRt::getLDS() for these.
listAttributes() Not applicable Returns the attributes supported by getBM() and getLDS() Takes no arguments

Migrating common biomaRt code

A typical biomaRt workflow creates a connection before calling getBM():

# A biomaRt workflow.
# This example is not actually run as the biomart service is unstable.
gene_ids <- c("ENSG00000157764", "ENSG00000004939")
attrs <- c(
  "ensembl_gene_id",
  "external_gene_name",
  "chromosome_name",
  "start_position",
  "end_position"
)
mart <- biomaRt::useEnsembl(
  "ensembl",
  dataset = "hsapiens_gene_ensembl",
  version = 112
)
biomaRt::getBM(
  attributes = attrs,
  filters = "ensembl_gene_id",
  values = gene_ids,
  mart = mart
)

With remart, the connection setup is removed and the query can usually be adapted directly:

gene_ids <- c("ENSG00000157764", "ENSG00000004939")
attrs <- c(
  "ensembl_gene_id",
  "external_gene_name",
  "chromosome_name",
  "start_position",
  "end_position"
)
getBM(
  attributes = attrs,
  filters = "ensembl_gene_id",
  values = gene_ids,
  version = 112
)
#>   ensembl_gene_id external_gene_name chromosome_name start_position
#> 1 ENSG00000157764               BRAF               7      140719327
#> 2 ENSG00000004939             SLC4A1              17       44248390
#>   end_position
#> 1    140924929
#> 2     44268141

Several obsolete connection-related arguments are accepted through ... for source compatibility. Check listAttributes() and the function reference before migrating a workflow that uses less common filters or attributes.

Roadmap and future direction

We aim to implement additional filters and attributes, but we do not have full visibility on how biomaRt is currently used in workflows in production. If you have a specific use case that is not currently supported, please open an issue on GitHub.

Known gaps

The items below summarize known gaps in remart functionality. Closing these gaps will depend on the availability of the corresponding endpoints in the Ensembl REST API, and priority as described below the table. “REST support” indicates whether the Ensembl REST API exposes what is needed.

Gap Ensembl REST support Issue
Multiple filters in getBM() No single endpoint accepts arbitrary filter combinations. Requests are ID-based, so combining filters will need client-side filtering of results.
External-ID conversion (e.g. entrezgene_id) Yes, via the cross-reference endpoints (xrefs/id, xrefs/symbol).
Coordinate-based getSequence() Yes, via sequence/region.
Transcript-level getLDS() Partial. homology/id returns gene-level orthologues. Transcript-level attributes will need additional lookups.
listFilters() Not needed: the supported filters are fixed in remart, so the list can be returned locally. #17

After initial release, feature development will be prioritized (in order) based on:

  • Explicit feature requests from users in the Bioconductor support forum and GitHub issues.
  • Use cases in Bioconductor package currently using biomaRt, ordered by their number of monthly downloads.

Understanding errors from remart

Beyond currently unsupported features, there may sometimes be a network or server-related error when querying the Ensembl REST API:

  • HTTP 429: you have exceeded the rate limit for the Ensembl REST API. Please retry again after at least one hour. Rate limits are documented at https://github.com/Ensembl/ensembl-rest/wiki/Rate-Limits.
  • HTTP 5XX, or timeout: the upstream server may be temporarily unavailable. Please retry the request after some time (next day if possible).
  • HTTP 404: the requested resource could not be found on the Ensembl REST API. This may indicate an invalid ID or endpoint.

Session information

utils::sessionInfo()
#> R version 4.6.2 (2026-10-29)
#> Platform: x86_64-pc-linux-gnu
#> Running under: Ubuntu 26.04.1 LTS
#> 
#> Matrix products: default
#> BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
#> LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.32.so;  LAPACK version 3.12.0
#> 
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
#>  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
#>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
#> 
#> time zone: Etc/UTC
#> tzcode source: system (glibc)
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] remart_0.99.10   BiocStyle_2.41.0
#> 
#> loaded via a namespace (and not attached):
#>  [1] cli_3.6.6           knitr_1.52          rlang_1.3.0        
#>  [4] xfun_0.62           otel_0.3.0          jsonlite_2.0.0     
#>  [7] glue_1.8.1          buildtools_1.0.0    htmltools_0.5.9    
#> [10] maketools_1.3.2     sys_3.4.3           sass_0.4.10        
#> [13] rmarkdown_2.32      evaluate_1.0.5      jquerylib_0.1.4    
#> [16] fastmap_1.2.0       yaml_2.3.12         lifecycle_1.0.5    
#> [19] httr2_1.3.0         BiocManager_1.30.27 compiler_4.6.2     
#> [22] digest_0.6.39       R6_2.6.1            curl_8.1.0         
#> [25] magrittr_2.0.5      bslib_0.12.0        tools_4.6.2        
#> [28] cachem_1.1.0