Question: Error when merging SCESet objects
gravatar for NathL
14 months ago by
NathL0 wrote:

I am using R version 3.4.1, Bioconductor 3.5 and RStudio to use scater package. I have 7 single-cell RNA seq datasets (from a 10x Genomics experiment), each corresponding to a different time point. Each dataset is a SCESet object. I want to merge the data all together. I have found there is the mergeSCESet function. However, this works perfectly well on some pairs of datasets, but not all. If not, I got this error :

Error in Biobase::combine(exprs(x), exprs(y)) : 
  matrix shared row and column elements differ: Mean relative difference: 1.102234

What is this mean relative difference ? How could I fix this or bypass it ? 

Here is an example code of what my program is doing (there is no error when running this code - taken from ) :

pd <- new("AnnotatedDataFrame", data = sc_example_cell_info)
example_sceset <- newSCESet(countData = sc_example_counts, phenoData = pd)
a <- mergeSCESet(example_sceset[, 1:20], example_sceset[, 21:30])
ADD COMMENTlink modified 14 months ago by Aaron Lun21k • written 14 months ago by NathL0
gravatar for Aaron Lun
14 months ago by
Aaron Lun21k
Cambridge, United Kingdom
Aaron Lun21k wrote:

The combine step will identify entries of the exprs(x) and exprs(y) matrices that have the same row and column names. For these entries, the expression values need to be the same in order for the merge to succeed. Otherwise, the function doesn't know which ones to keep in the output matrix.

In your case, I'm willing to bet that some of the cell barcodes are repeated between 10X experiments (and obviously the gene annotation will be the same), resulting in some matrix entries that have the same row and column names across multiple experiments. This probably doesn't happen all the time, so the function may work fine in some data sets but not in others. The simplest solution is just to slap an experiment-specific prefix onto the column names, e.g., "Exp1-ACACTGCGACT-1" or something, prior to running the function.

Personally, I've hated mergeSCESet for a long time, and I'm happy to say that as we transition to the SingleCellExperiment class in the next release, you will be able to just cbind the individual objects together to obtain a merged object (assuming that the row order is the same across individual matrices). In your case, the cbind function may complain about duplicate column names, but that's a more informative error message than the one you get from mergeSCESet.

ADD COMMENTlink modified 14 months ago • written 14 months ago by Aaron Lun21k

 Ok, thank you for these very clear explanations. Do you actually have an idea when will be the next scater release ? 

ADD REPLYlink written 14 months ago by NathL0

The next scater release will come out with the next Bioconductor release... which should be soon-ish. Next month, maybe?

ADD REPLYlink written 14 months ago by Aaron Lun21k

I've been away for a while and just checked by adding sort of "Exp1-ACACTGCGACT-1" to each barcode, but another error appears : 

Error in data.frame(numeric(n), row.names = nms) : 
  duplicate row.names: Exp1

I checked the code of the read10xResults function on GitHub but cannot really figure out where this come from. Do you have any idea of where it might come from ? 

ADD REPLYlink written 13 months ago by NathL0

Where is this error coming from? mergeSCESet? read10XResults? The code below works for me:

a <- example_sceset
b <- example_sceset # Have the same colnames as 'a'
colnames(a) <- paste0("Exp1-", colnames(a))
colnames(b) <- paste0("Exp2-", colnames(b))
mergeSCESet(a, b)
ADD REPLYlink modified 13 months ago • written 13 months ago by Aaron Lun21k

Thank you, it finally works! The problem came from the fact that I used a bash command (with sed) to modify the barcodes names in the file barcodes.tsv. And when running read10XResults, this error appears and the SCESet object cannot be built. 

ADD REPLYlink written 13 months ago by NathL0
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.2.0
Traffic: 241 users visited in the last hour