Skip to content

plotDensities fails if logcounts is not of class numeric  #3

@michellemeier27

Description

@michellemeier27

Hi,

I've been playing around with your package and noticed that the plotDensities function failed on my SCE object because the logcounts assay is in dgCMatrix format instead of class numeric matrix.

I usually use Seurat, so I convert my seurat object like this:
sceObject <- as.SingleCellExperiment(seurat.object)

The getting everything ready for Cepo:
log2counts <- logcounts(sceObject) %>% as.matrix()
cellType <- sceObject$L1_Seurat_cluster_predicted_phenotype %>% as.vector()

Followed by running Cepo:
ds_res = Cepo(exprsMat = log2counts, cellType = cellType, prefilter_pzero = 0.7, computePvalue = 200, minCells = 10 )

Then finally, plotting:
plotDensities(x = sceObject, cepoOutput = ds_res, genes = 'lyve1b', assay = "logcounts", celltypeColumn = "L1_Seurat_cluster_predicted_phenotype")
Which gives me the following error:
Error in fix.by(by.x, x) : 'by' must specify a uniquely valid column

However, I can work around that by fixing the logcounts in sceObject:

sceObject_2 <-sceObject
log2counts <- logcounts(sceObject) %>% as.matrix()
class(log2counts) <- "numeric"
logcounts(sceObject_2) <- log2counts

And then plotDensities works fine.

I think when you subset the expression matrix on line 126, it results in a format that is then not compatible with line 134 reshape2::melt. Not sure if this is something you'd consider a bug, but as the community seems to move towards using sparse matrices whenever possible it could be worth making it compatible with them.

Cheers,
Michelle

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions