MarioniLab / scran

Clone of the Bioconductor repository for the scran package.
https://bioconductor.org/packages/devel/bioc/html/scran.html
40 stars 22 forks source link

error in running cyclone () #59

Closed crebli closed 4 years ago

crebli commented 4 years ago

assigned <- cyclone(sce, pairs=mm.pairs, gene.names=ensembl) Error in value[3L] : 'assay(, i="character", ...)' invalid subscript 'i' 'dimnames' only for display; sce was converted from Seurat object (3.1.5) by scran(1.14.6). Samples of data were from mice.

LTLA commented 4 years ago
  1. Consider using the latest version of scran (1.16.0). The older versions are frozen.
  2. You probably don't have the assays named correctly, see assay.type in ?cyclone.
crebli commented 4 years ago

Thanks. I tried scran (1.16.0) and unfortunately we encountered the same error. I think the problem maybe something wrong with the conversion of seurat object to singlecellexperiment object. But I don't know how.

LTLA commented 4 years ago

If you're using 1.16.0, you should also be using BioC 3.11, in which case the errors should be much more informative than what you're observing. For example,

library(scRNAseq)
sce <- ZeiselBrainData()
assay(sce, i="WHEE")
## Error in assay(sce, i = "WHEE") : 
##   'assay(<SingleCellExperiment>, i="character", ...)' invalid subscript 'i'
## 'WHEE' not in names(assays(<SingleCellExperiment>))

In your case, it is likely that your SCE object doesn't have the count matrix with the expected assay name, see ?cyclone for the default. So just change the assay.type= to point to the actual assay.

crebli commented 4 years ago

Thanks. as to assay.type= to point to the actual assay, I set "assay.type=Ld"(Ld: the file name of seurat object) or "assay.type=sce" , or "assay.type="counts" ". It still has this error. Sorry, I may not understand what you mean "to point to the actual assay".

LTLA commented 4 years ago

sce is a SingleCellExperiment. It stores multiple assays, e.g., count matrices, log-expression matrices. When you give cyclone() a SingleCellExperiment, you need to tell it which matrix to perform calculations on. For cyclone(), the default is assay.type="counts" as you can see from ?cyclone (1). If your sce does not have an assay named "counts", you will have to tell cyclone() which assay to use. You can see what assays are available by calling assayNames(sce), or just by typing sce at the command line and looking at the information summary.


(1): technically, ?cyclone only shows documentation for a SummarizedExperiment S4 method. But remember that a SingleCellExperiment is just a subclass of a SummarizedExperiment, so any method that works on the latter will also work on the former.

crebli commented 4 years ago

hello, I have checked the assays: assays(1): ''. There is no any name, see below. And "assayNames(sce)" is NULL. It seems that for Seurat objects after being converted into sce, the count names were lost.

sce class: SingleCellExperiment dim: 24810 22 metadata(0): assays(1): '' rownames(24810): 4933401J01Rik Gm1992 ... Gm20856 Gm29092 rowData names(0): colnames(22): GAGGTCCGGCTT_1 GAAAAACCACAG_1 ... AATCCACGATAT_1 ACTAGGAACTCA_1 colData names(0): reducedDimNames(0): altExpNames(0):

assayNames(sce) NULL

crebli commented 4 years ago

Hi, I found if I convert the seurat object into sce via as.SingleCellExperiment(seurat object) from scater package, it will works well: "assays(2): counts logcounts". There is something defect in scran package in converting seurat object into sce.

LTLA commented 4 years ago

Neither scran or scater has any functionality to convert seurat objects to SCEs. You must be doing the conversion using a function from some other package, so go complain to them.

In any case, even if you don't have assay names, you can just set assay.type=1 to use the first assay.

crebli commented 4 years ago

Thank you!

At 2020-06-19 14:44:18, "Aaron Lun" notifications@github.com wrote:

Neither scran or scater has any functionality to convert seurat objects to SCEs. You must be doing the conversion using a function from some other package, so go complain to them.

In any case, even if you don't have assay names, you can just set assay.type=1 to use the first assay.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.