Error when merging SCESet objects
1
2
Entering edit mode
nlehmann ▴ 20
@nlehmann-13950
Last seen 17 months ago

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 https://rdrr.io/bioc/scater/man/mergeSCESet.html ) :

library(scater)
data("sc_example_counts")
data("sc_example_cell_info")
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])

scater single-cell • 1.5k views
2
Entering edit mode
Aaron Lun ★ 27k
@alun
Last seen 2 hours ago
The city by the bay

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.

0
Entering edit mode

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

1
Entering edit mode

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

0
Entering edit mode

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 ?

0
Entering edit mode

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

example(newSCESet)
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)

0
Entering edit mode

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.