This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Problem with merge data while trying to convert gene names

Hey! This is a follow-up question to one where I asked for help coding (in R) a way to convert gene accession numbers to gene names. Here is my code, where charg is a character vector of the gene accession ID's of the data set resdata:

charg <- resdata$genes
head(charg)

ensembl = useMart("ensembl",dataset="hsapiens_gene_ensembl")

theBM <- getBM(attributes='ensembl_gene_id','hgnc_symbol', 
      filters = 'external_gene_name', 
      values = charg, 
      mart = ensembl)

resdata <- merge.data.frame(resdata, theBM, by.x="genes",by.y="ensembl_gene_id")

Here's some output (where I'm struggling):

> head(charg)
[1] "ENSG00000261150.2"  "ENSG00000164877.18" "ENSG00000120334.15"
[4] "ENSG00000100906.10" "ENSG00000182759.3"  "ENSG00000124145.6" 

> dim(theBM)
[1] 0 1

> head(theBM)
[1] ensembl_gene_id
<0 rows> (or 0-length row.names)

> dim(resdata)
[1] 20381    11
> resdata <- merge.data.frame(resdata, theBM, by.x="genes",by.y="ensembl_gene_id")
> dim(resdata) #after merge
[1]  0 11 #isn't correct -- just row names! where'd my genes go?

Thank you.

r rna-seq biomart genome gene

Hi,

You've opened a new post while asking for help on this exact problem in another post. That makes your statement on this post being a "follow-up" inaccurate. I'll be closing that older post now. Repeating this behavior in the future will get your account suspended.

So sorry about that! It won't happen again.

Hello equinox145111!

We believe that this post does not fit the main topic of this site.

Answered SE -Bioinfo.

For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.

If you disagree please tell us why in a reply below, we'll be happy to talk about it.

Cheers!

Sorry folks who contributed (and thanks for it!), but this OP has now cross-posted to two other communities and even opened another post here, this is unacceptable.

equinox145111 stop this behaviour. It is utterly disrespectful to cause such a hassle for a single question. You have almost a dozen people now involved in the same underlying problem. If this happens again I will suspend your account. I answered your question https://bioinformatics.stackexchange.com/questions/13603/problem-with-merge-data-while-trying-to-convert-gene-names-in-r/13614 please take time to review it and then apply it, it is really not that difficult. I will also close the other Biostars post related to this topic.

Not to mention that OP also asked on StackOverflow. This is quite the abuse of online forums for something OP should have used Google to figure out by themselves.

1 answer

Your merged data frame resdata has zero rows because theBM has zero rows. Your retrieval from Biomart failed to return any rows. I would focus on understanding why your ensembl query getBM(...) is failing. If your query had returned rows that matched any of the genes in resdata$genes, your merge(...) call as written would have returned those correctly.

Okay, I got my getBM to work, but my merge is still returning an empty matrix :(.

Log in to answer this question.