Biostar Beta. Not for public use.
struggling with an R command
0
Entering edit mode
16 months ago
European Union

I have established ensembl as my database but I can not get this code to work....

Any help?

results <- getBM(attributes = c("ensembl_gene_id", "hgnc_symbol"), filters = "hgnc_symbol", values = genes$hgnc, mart = mart) _Error in getBM(attributes = c( "ensembl_gene_id", "hgnc_symbol"), filters = "hgnc_symbol", : Values argument contains no data._  R • 1.9k views ADD COMMENTlink 1 Entering edit mode What is the output of head(genes$hgnc)?

0
Entering edit mode

this returns.... NULL. what do i have to do to give it a value

0
Entering edit mode

oh yes i have created a list of genes in a csv file and i have it in the right directory and i changed the "my file" to my csv title.

changing the values to tp53 and sry worked but my list is 200 genes long.... i'm hoping to get the requested info (specified in the code) on the whole list... is that possible that it will search ensembl for this info for all of the genes in my list with the right code?

0
Entering edit mode

If what you say regarding the CSV file is true then the value of genes$hgnc cannot be NULL. Check again. BioMart should have no issues with 200 genes; I routinely use query vectors with thousands of entries. ADD REPLYlink 0 Entering edit mode is this where u want me to post? yes the csv file is real and genes$hgnc just returns NULL.

the full code is as follows:

library(biomaRt)

mart <- useMart(biomart="ensembl", dataset="hsapiens_gene_ensembl")

results <- getBM(attributes = c("ensembl_gene_id", "hgnc_symbol"), filters = "hgnc_symbol", values = c("TP53", "SRY"), mart = mart)

And results returns:

results
ensembl_gene_id hgnc_symbol
1 ENSG00000184895 SRY
2 ENSG00000141510 TP53
3 LRG_321 TP53

0
Entering edit mode

what do the first few lines of chromatin.csv look like? (including the header row)

0
Entering edit mode

## TDRKH

CTCFL
PIWIL4
ASZ1
DNMT1
DNMT1
DNMT1
DNMT1

0
Entering edit mode

OK. First, that is not a CSV file - although read.csv() will still read it in just fine.

Second, the first row does not contain the value "hgnc". That is where genes$hgnc comes from. read.csv() assumes by default that the first row contains the column header, so what you have is genes$TDRKH.

There are lots of ways to fix this. One of them is to use read.csv() with the header = FALSE argument. Your column header will then be V1, so you would use genes$V1. But you should read the help pages or some online tutorials for read.csv() and read.table(), so you understand how to read data into R. ADD REPLYlink 0 Entering edit mode so does that mean that everywhere in the code that i have hgnc e.g. hgnc_symbol i should replace the hgnc with TDHRK? ADD REPLYlink 0 Entering edit mode No. That means that the first line of your file should be "hgnc", not "TDHRK". As I said, read.csv() assumes that the first line contains a header by default. If your first line is "TDHRK" and you don't specify header = FALSE, then R assumes that the column header is "TDHRK". ADD REPLYlink 1 Entering edit mode 2.9 years ago Kizuna • 780 France, Paris your vector genes$hgnc seems to contain no rows.. try length(genes$hgnc) ; class(genes$hgnc) ..

1
Entering edit mode
2.2 years ago
Neilfws 48k
Sydney, Australia

It seems that you have copied this code from my blog post.

In that post, you will note that the HGNC symbols are one column of a CSV file, which was read into R. You cannot expect copy/paste of the code to work unless you also have a CSV file, with a column headed "hgnc", containing HGNC symbols.

You can try values = c("TP53", "SRY") if you just want to see how the code works and what is returned by getBM(). Basically, you need to supply a vector of HGNC symbols as the value for values.