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 ?
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.
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 ?
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)
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.
Ok, thank you for these very clear explanations. Do you actually have an idea when will be the next scater release ?
The next scater release will come out with the next Bioconductor release... which should be soon-ish. Next month, maybe?
I've been away for a while and just checked by adding sort of "Exp1-ACACTGCGACT-1" to each barcode, but another error appears :
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 ?
Where is this error coming from?
mergeSCESet
?read10XResults
? The code below works for me: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.