GreenleafLab / ArchR

ArchR : Analysis of Regulatory Chromatin in R (www.ArchRProject.com)
MIT License
377 stars 133 forks source link

SOLUTION: addGeneExpressionMatrix / import10xFeatureMatrix issue #2199

Open juliabelk opened 1 month ago

juliabelk commented 1 month ago

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.

rcorces commented 1 month ago

Hi @juliabelk! Thanks for using ArchR! Lately, it has been very challenging for me to keep up with maintenance of this package and all of my other responsibilities as a PI. I have not been responding to issue posts and I have not been pushing updates to the software. We are actively searching to hire a computational biologist to continue to develop and maintain ArchR and related tools. If you know someone who might be a good fit, please let us know! In the meantime, your issue will likely go without a reply. Most issues with ArchR right not relate to compatibility. Try reverting to R 4.1 and Bioconductor 3.15. Newer versions of Seurat and Matrix also are causing issues. Sorry for not being able to provide active support for this package at this time.