andygxzeng / BoneMarrowMap

A single cell RNA-seq reference map of human hematopoietic development in the bone marrow, with balanced representation of hematopoietic stem and progenitor cells and differentiated populations
GNU General Public License v3.0
18 stars 3 forks source link

Map Query Error - slightly different #5

Closed KristianTeichert closed 5 months ago

KristianTeichert commented 7 months ago

Hello,

I hope you're doing well! I'm trying to use the Bone Marrow Reference Map projection, and I'm currently going through the tutorial. Thus far, I've been completely successful in loading the example data, but when I try to load in my own data, I see a similar error as was reported previously:

query <- readRDS(paste0(projection_path, 'KO.rds')) query

batch variable to correct in the query data, set as NULL if no batches in query

batchvar <- 'sampleID'

Map query dataset using Symphony (Kang et al 2021)

query <- map_Query( exp_query = query@assays$RNA@counts, metadata_query = query@meta.data, ref_obj = ref, vars = batchvar )

Error in Seurat::CreateSeuratObject(counts = exp_query, meta.data = metadata_query, : no slot of name "counts" for this object of class "Assay5

I saw it was noted that this could be a result of using Seurat v5.0.1, and should be resolved but I seem to still be seeing this error.

Thanks in advance for any help you can provide!

andygxzeng commented 7 months ago

Hi Kristian,

Thanks for your message. I updated the package to be able to handle Seurat V5 effectively, however I think the issue is in the tutorial code that you are copying.

Your own data is likely a Seurat V5 object, so using query@assays$RNA@counts will not work to access the gene expression count matrix in your Seurat V5 object, instead, you may want to try query[[“RNA”]$counts for that particular line of code.

Let me know if that works, I will try to update the tutorial to make sure others are not tripped up by this.

Andy

KristianTeichert commented 7 months ago

Hi Andy,

Thank you so much for the help! That helped me to get past that error, but in the next line I seem to be hitting a new error on the next line. Are there any other changes I need to make in order to be compatible with loading in a Seurat V5 object?

Normalizing Scaling and synchronizing query gene expression Found 2160 reference variable genes in query dataset Project query cells using reference gene loadings Clustering query cells to reference centroids Correcting query batch effects Error in [.data.frame(droplevels(metadata_query), , vars) : undefined columns selected

I really appreciate all of your help, and sorry in advance if these questions are naive - I'm a novice, but finding the tutorial incredibly helpful!

Kristian

andygxzeng commented 7 months ago

Hi Kristian

No problem and sorry to hear you ran into another error so quickly. Does query@meta.data successfully return a data frame for you? And is the batch key column name present within the data frame?

The mapquery function from harmony simply requires a matrix with the gene expression data and a dataframe with the annotations for this cells, and of course the column specifying the batch (eg donor) that you want to correct for also needs to be present within the dataframe. So the function input is really just a matrix and a dataframe rather than a Seurat object.

Hopefully that helps, if you figure it out from there please let me know what worked for you so I can clarify within the tutorial

Best Andy

KristianTeichert commented 7 months ago

Hi Andy,

With your help/clarification, I found the problem: my Seurat Object did not have a column dedicated to "sampleID" as it was one sample. I changed:

batchvar <- 'sampleID' to batchvar <- 'orig.ident'

and it's working!

Thanks again for your help! Kristian

andygxzeng commented 7 months ago

great to hear and good luck!