BPCells icon indicating copy to clipboard operation
BPCells copied to clipboard

dotplot error

Open jessicaliu70 opened this issue 2 years ago • 3 comments

can BPCells work with dotplot? I have the following error: dotplot<-DotPlot(object = obj, features = canonical_markers, group.by='seurat_clusters',cols = "Spectral") + theme(axis.text.x = element_text(angle = 45, size = 8), legend.text = element_text(size = 8), legend.title = element_text(size = 8))

Error in .rowNamesDF<-(x, value = value) : duplicate 'row.names' are not allowed In addition: Warning message: non-unique values when setting 'row.names':

jessicaliu70 avatar Jul 18 '23 02:07 jessicaliu70

Hi @jessicaliu70, Thanks for the question and sorry for the small delay getting back to you. It's hard to tell whether this specific question is an issue with BPCells or with how Seurat uses BPCells, so I'm hoping you can provide a bit more detail.

I'm able to run DotPlot on an demo project that contains a BPCells matrix just fine, e.g. with this code:

library(BPCells)
library(Seurat)
options(Seurat.object.assay.version = "v5")

pbmc3k_mat <- pbmc3k.SeuratData::pbmc3k@assays$RNA@counts
bpcells_mat <- as(pbmc3k_mat, "IterableMatrix")

proj <- CreateSeuratObject(bpcells_mat)
proj <- AddMetaData(proj, pbmc3k.SeuratData::[email protected]$seurat_annotations, "clusts")

DotPlot(proj, features = c("NKG7", "CD3E"), group.by = "clusts" )

Is there some way you might be able to provide a runnable example that reproduces your issue? Ideally you could reproduce it on one of the example datasets from the SeuratData package as I've done in my example above.

If this is not possible, you might try identifying a small subset of your data that can still reproduce the issue (email is OK if you can't post publicly, bparks [at] stanford.edu). I'd recommend using BPCells::write_matrix_memory() to save the data as an in-memory BPCells object, then save the whole Seurat object as an RDS file. It's fine if the data is randomized or subset down to a few dozen cells, just as long as you can provide code that still hits this issue.

bnprks avatar Jul 19 '23 22:07 bnprks

Hi, Thank you for reply. It worked after I convert the on-disk object to in-memory object.

Then my question is that you can't directly plot dot plot using the on-disk object? Since when I try to call dot plot, it always do: test<-DotPlot(obj, features = c("SNAP25-AS1", "CD3E"), group.by = "cell.type" )

Loading required package: BPCells Warning: Converting to a dense matrix may use excessive memory This message is displayed once every 8 hours.

So if I have a very large object, in-memory object is too big (out of memory), then I can't visualize the dot plot?

jessicaliu70 avatar Jul 26 '23 14:07 jessicaliu70

Hi Jessica,

As far as my testing goes, it works fine for me to directly run DotPlot with the on-disk object (see the example code I gave above, slightly updated to add a library(BPCells) call). And despite the warning, in this case there shouldn't be performance worries when running dot plots with on-disk objects even for very large datasets.

I know you're running into errors, but if you don't provide a runnable example for me allows me to also experience the bug I can't help much. What I would need to be able to help is:

  • Code that replicates your issue (including all the code to you need to run in a fresh R session prior to calling DotPlot)
  • Any data that code relies on
  • The exact Seurat version you're running, which can be found by running sessionInfo()

bnprks avatar Jul 26 '23 17:07 bnprks

Closing due to inactivity

immanuelazn avatar Oct 25 '24 21:10 immanuelazn