ArchR icon indicating copy to clipboard operation
ArchR copied to clipboard

SOLUTION: addGeneExpressionMatrix / import10xFeatureMatrix issue

Open juliabelk opened this issue 1 year ago • 1 comments
trafficstars

I just wanted to add some information about the addGeneExpressionMatrix and import10xFeatureMatrix functions in case anyone else is running into the same issue I had. The error message I kept getting was Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘seqnames’ for signature ‘"SummarizedExperiment"’

What I realized is - the addGeneExpressionMatrix really needs gene coordinates for every single gene in the matrix. I don't think this function can accept a SummarizedExperiment at all, it seems like it requires a RangedSummarizedExperiment (the documentation is not clear on this point). It will try to read in these coordinates from the h5 file, however if it doesn't find them, it will simply omit the ranges, return a SummarizedExperiment instead, and then fail to add the expression matrix.

You can check if the coordinates for each gene are present in the h5 file using features10x <- h5read(h5, "/matrix/features") and checking if interval is a key in the returned list.

As far as I can tell, if interval is not in the returned list, you will need to manually add your own gene coordinates to create a RangedSummarizedExperiment before calling addGeneExpressionMatrix. In my case, cellranger did not output the interval key into the h5 matrix, but I was able to find another 10X dataset that did have the interval key and copy it over by modifying import10xToSE. The documentation also suggests using something like genes(EnsDb.Hsapiens.v86::EnsDb.Hsapiens.v86) to get the gene coordinates, however I couldn't figure out how to make this work.

One other thing - the ArchR multiome tutorial that is commonly linked to does have interval in the h5 file. So if your code is running on the tutorial files but not on other samples, this could be why.

juliabelk avatar Aug 14 '24 07:08 juliabelk