This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Single Cell Experiment colData dimensions not matching with counts dimensions

I am trying to read in data downloaded from the EBI Expression Atlas into a SingleCellExperiment object. I'm using the filtered counts file as the counts, then using the experiment data tsv file as the colData. However, for some datasets, the dimensions of the colData does not match with the counts dimensions, and I get the following error:

Error in validObject(.Object) : 
invalid class “SummarizedExperiment” object: 
nb of cols in 'assay' (809) must equal nb of rows in 'colData' (867)

Does anyone know how to solve this problem? Any help would be greatly appreciated! If it helps, the shape of my counts is: 23598 by 809, and the shape of my experiment design is 867 by 25.

rna-seq r bioconductor

1 answer

As you are using filtered counts, some barcodes may have been filtered from the counts but not from the experiment data file. You can match the cells from the filtered counts to the annotation (colData) before creating your SingleCellExperiment:

experiment_data = experiment_data[match(colnames(counts), rownames(experiment_data) ), ]

Or

experiment_data = experiment_data[match(colnames(counts), experiment_data$barcode), ]

Depending on where is stored the barcode / cell name information in the experiement data tsv file.

Log in to answer this question.