This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Best practice for handling duplicate gene symbols when creating an edgeR DGEList object?

Hello Biostars community,

I am working with a public RNA-seq count dataset (GSE283652) and attempting to format the raw counts into an edgeR matrix to initialize a DGEList object.The dataset uses gene symbols in the first column. When I attempt to assign the symbol column to the data frame row names using the following code:

dat <- read.csv("GSE283652_counts.csv")
rownames(dat) <- dat$symbol

I encounter this error due to non-unique gene names in the file:

Error in `.rowNamesDF<-`(x, value = value) : 
duplicate 'row.names' are not allowed
In addition: Warning message:
non-unique values when setting 'row.names': ‘4930519F16Rik’, ‘Arfip1’, ‘Cplx2’, ‘Gm12238’, ‘Nnt’...

I understand that R requires unique row names, but I am looking for advice on the standard bioinformatics best practice to resolve this before running edgeR.

Any guidance on the standard pipeline conventions for this scenario would be greatly appreciated!

Thank you for your time.

edger dgelist r rnaseq

2 answers

Standard best practice is to use the unique gene IDs as row names. The file you refer to reads straight into edgeR without any pre-processing:

> library(edgeR)
> dat <- read.csv("GSE283652_counts.csv.gz", row.names=1)
> y <- DGEList(dat)
> head(y$genes)
                   symbol
ENSMUSG00000000001  Gnai3
ENSMUSG00000000003   Pbsn
ENSMUSG00000000028  Cdc45
ENSMUSG00000000031    H19
ENSMUSG00000000037  Scml2
ENSMUSG00000000049   Apoh

You cannot use gene symbols as row names because they are not unique and because many are in fact NA. And there is no need to do that anyway because edgeR stores the gene symbols in a separate annotation column, and automatically collates them into downstream tables of DE genes.

Theoretically, you could reset the row.names to gene symbols after subsetting the DGEList to genes with unique non-NA symbols. IMO, however, it is best practice to always use the original gene IDs, which definitively identify what the row corresponds to.

Thanks for replying to my query.

To clarify, the dataset I am working with only contains gene symbols in the counts table; there are no Ensembl or Entrez IDs included that I could use as alternative unique identifiers.

Given this limitation, would you recommend collapsing the duplicates by summing the counts, or should I proceed with making the names unique using make.unique()?

No, the GSE283652_counts.csv file refered to in your question does indeed contain Ensembl IDs, as my answer shows. Almost all GEO datasets include the original Ensembl or Entrez IDs.

If the Ensembl ID column has somehow been deleted from your copy of GSE283652_counts.csv, then just download the file again from https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE283652.

There is no standard best practice way of processing a file where the gene IDs have been removed, because this should never happen. You will need to make your own decision, depending on where the data is from and why there are duplicate symbols. The GSE2836652 dataset includes over 23,000 rows with missing symbols, so it would be pretty unsatisfactory if that was only row annotation.

The table also contains ensembl gene ids, so assuming x is your data.frame from GEO, simply do paste(x$symbol, x$gene, sep = "_") to get a unique identifier. Imo symbols alone should not be used anyway, for exactly this reason: They're not unique and not as standardized as ensembl gene ids. The id_underscore_symbol thing is handy because it is unique and you get the symbol anytime with a simple regex.

Log in to answer this question.