This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Some cells in meta.data not present in provided counts matrix.

Hello, I am using Seurat for single cell RNA-seq analysis of drosophila data. After I did cell level filtering, I tried gene level filtering as below. However, there was an error message "Some cells in meta.data not present in provided counts matrix" and there were a lot of "N/A" in the meta.data of filtered_fly9. I would appreciate it if someone could let me know how to fix this.

#Cell level filtering
filtered_fly9 <- subset(x = fly9, subset= log10GenesPerUMI > 0.80)

I confirmed that the metadata of the filtered_fly9 after the cell level filtering was filled in numbers.

#Gene level filtering
counts9 <- GetAssayData(object = filtered_fly9, slot = "counts")
nonzero9 <- counts9 > 0
keep_genes9 <- Matrix::rowSums(nonzero9) >= 10
filtered_counts9 <- counts[keep_genes9, ]
filtered_fly9 <- CreateSeuratObject(filtered_counts9, meta.data = filtered_fly9@meta.data)

There were a lot of "N/A" in the meta.data of the filtered_fly9.

seurat scrna-seq createseuratobject

Hello Dr. tomas4482, thank you so much for your message. Now I understand why there were a lot of N/A... I appreciate your taking time.

Why did you delete your posts? Who's Dr. tomas4482?

I think my original answer should be something like:

filtered_fly9 is the original matrix, but filtered_counts9 is a filtered matrix. The meta.data will be definitely less in filtered_counts9. That's why you gets so many NA.

But later I found that the count assay seems to subset genes only. The answer may be incorrect. Without an test sample, I'm not able to find out the reason. Therefore, I deleted the original answer.

I see. I think it was done pretty quickly, as moderators such as myself are able to view deleted posts for a while. I'll delete this thread in a bit.

1 answer

You can check that colnames(counts) match rownames(filtered_fly9@meta.data) -- but more generally you do not need to create an entirely new Seurat object to do this. You can go with:

filtered_fly9 <- subset(fly9, ...)
filtered_fly9 <- filtered_fly9[rowSums(GetAssayData(filtered_fly9, 'counts') > 0) > 10,]

which should eliminate the error.

Log in to answer this question.