This helper function queries BioMart for lengths of genes by adding up all exon lengths after reducing overlaps.
h_get_size_biomart(gene_ids, id_var, mart)
(character
)
gene IDs, e.g. 10329
, i.e. already
without the Entrez GeneID
prefix, or ENSG00000241644
for Ensembl gene ID.
(string
)
corresponding gene ID variable name in BioMart,
i.e. entrezgene_id
or ensembl_gene_id
.
(Mart
)
given biomaRt::Mart
object.
Named integer vector indicating the gene lengths.
if (interactive()) {
mart <- biomaRt::useMart("ensembl", dataset = "hsapiens_gene_ensembl")
h_get_size_biomart("11185", "entrezgene_id", mart)
h_get_size_biomart("ENSG00000215417", "ensembl_gene_id", mart)
h_get_size_biomart(c("11185", "10677"), "entrezgene_id", mart)
h_get_size_biomart(c("ENSG00000135407", "ENSG00000215417"), "ensembl_gene_id", mart)
}