Skip to content

Converting Seurat fails when graphs don't have a DefaultAssay #368

@rcannood

Description

@rcannood

I encountered a Seurat object with the following content:

An object of class Seurat 
73202 features across 342178 samples within 2 assays 
Active assay: RNA (36601 features, 2000 variable features)
 4 layers present: counts.10x_3p_v3.1, counts.10x_5p_v2, data.10x_3p_v3.1, data.10x_5p_v2
 1 other assay present: sketch
 5 dimensional reductions calculated: pca, harmony, umap, harmony.full, umap.full

Calling as_AnnData() fails:

> adata <- as_AnnData(data, assay_name = "RNA")
Error in if (SeuratObject::DefaultAssay(graph) != assay_name) { : 
  argument is of length zero

On this line:

if (SeuratObject::DefaultAssay(graph) != assay_name) {

I can't share the data file, but I notice it has two graphs. I can read the graph just fine, but the assay.used seems to be empty for some reason, thus causing the exception above.

> SeuratObject::Graphs(data)
[1] "sketch_nn"  "sketch_snn"
> gr <- data[["sketch_nn"]]
> gr
A Graph object containing 55331 cells
> gr@assay.used
character(0)
> SeuratObject::DefaultAssay(gr)
NULL

I suppose that in this case the graph could be skipped, but it would be nice if as_AnnData didn't throw an error but a warning instead


In this case, I'm able to circumvent the issue by turning off the obsp_mapping for now until this issue is fixed.

adata <- as_AnnData(data, assay_name = "RNA", obsp_mapping = FALSE)

Metadata

Metadata

Assignees

No one assigned

    Labels

    SeuratIssues related to Seurat object conversion

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions