0

I'm trying to use the getBM() function of bioconductor to retrieve the sequences of some gene. Here's my script:

setwd(".")
options(stringsAsFactors = FALSE)
cat("\014")


if (!requireNamespace("BiocManager", quietly = TRUE))
    install.packages("BiocManager")
listOfBiocPackages <- c("annotate", "GEOquery", "biomaRt")

bioCpackagesNotInstalled <- which( !listOfBiocPackages %in% rownames(installed.packages()) )
cat("package missing listOfBiocPackages[", bioCpackagesNotInstalled, "]: ", listOfBiocPackages[bioCpackagesNotInstalled], "\n", sep="")

# check there's still something left to install
if( length(bioCpackagesNotInstalled) ) {
    BiocManager::install(listOfBiocPackages[bioCpackagesNotInstalled])
}

library("easypackages")
libraries(listOfBiocPackages)  

mart <- useMart("ENSEMBL_MART_ENSEMBL")
mart <- useDataset("hsapiens_gene_ensembl", mart)

thisAnnotLookup <- getBM(mart=mart, attributes=c("affy_hg_u133a", "ensembl_gene_id", "gene_biotype", "external_gene_name", "gene_flank"), filter=c("affy_hg_u133a", "upstream_flank"), values=list(affyid=c("203423_at",   "204088_at",   "204511_at",   "204911_s_at", "205234_at")), uniqueRows=TRUE, checkFilters=FALSE)

print(thisAnnotLookup)

This script gives the me following error:

  'names' attribute [2] must be the same length as the vector [1]

which I cannot understand.

Can anyone help me solve this issue? Thanks!

DavideChicco.it
  • 3,318
  • 13
  • 56
  • 84

1 Answers1

0

You need to provide a list of 2 elements if you have two filters. However the larger problem is that upstream_flank is may not be available depending on your connection, see this problem cropping up for many users. For me, I last used the asia mirror and it worked:

library(biomaRt)

mart <- useEnsembl(biomart = "ensembl", 
                   dataset = "hsapiens_gene_ensembl", 
                   mirror = "asia")

Then:

S = getSequence(id=c("203423_at","204088_at","204511_at","204911_s_at","205234_at"),
type="affy_hg_u133a",seqType="gene_flank",upstream = 20,mart = mart)

thisAnnotLookup <- getBM(mart=mart, 
attributes=c("affy_hg_u133a", "ensembl_gene_id", "gene_biotype", "external_gene_name"), 
filter="affy_hg_u133a", 
values=c("203423_at","204088_at","204511_at","204911_s_at","205234_at"), 
uniqueRows=TRUE, checkFilters=FALSE)

merge(thisAnnotLookup,S)
  affy_hg_u133a ensembl_gene_id   gene_biotype external_gene_name
1     203423_at ENSG00000114115 protein_coding               RBP1
2     204088_at ENSG00000135124 protein_coding              P2RX4
3     204511_at ENSG00000006607 protein_coding              FARP2
4   204911_s_at ENSG00000110171 protein_coding              TRIM3
5     205234_at ENSG00000168679 protein_coding            SLC16A4
            gene_flank
1 CTCCTCTTCCTTTGTAGGGG
2 GATTCCTCTCACCTCGGCCT
3 CGCGGGGGCTGCCGGCGGGC
4 CACCTTTCTACCCCTTAACT
5 GCCTGAGATGACATCAAATC

Seems super finicky to me. I think you are better off using getting the sequence directly off the genome.

StupidWolf
  • 45,075
  • 17
  • 40
  • 72