Skip to content

Fix naming of layers of CreateAssay5Object() function and allow assay and layer names to be modified after creation #7432

@ScreachingFire

Description

@ScreachingFire

Hello!

I came across a problem where I could not change the names of assays and layers after the creation of a Seurat Object. For example:

Assays(scdata) <- c("ASSAY1","ASSAY2")
Layers(scdata[["RNA"]]) <- c("LAYER1", "LAYER2")

These return the following errors:

Error in Assays(scdata) <- c("RNA1", "SCT1") : 
  could not find function "Assays<-"

Error in Layers(scdata[["RNA"]]) <- c("counts", "scale.data") : 
  could not find function "Layers<-"

I realize that if a default assay has its name modified then DefaultAssay() would also have to have its name changed, but layers would not have this issue at least so it might be worth it to focus on layers hopefully.
I am trying to read in an assay stored as a named list and unfortunately the CreateAssay5Object() function prepends the string "counts." to each layer name, which I am trying to avoid. Would it be possible to allow assay or at least layer names to be modified after their creation and fix CreateAssay5Object() so that if a named list of multiple data matrices is supplied, the layer names do not have "counts." added before the name. E.g:

> CreateAssay5Object(named_list_of_data) # named_list_of_data was created with list(counts = datamat1, scale.data = datamat2)
 Assay (v5) data with 21703 features for 22058 cells
 First 10 features:
 RP11-34P13.7, FO538757.2, AP006222.2, RP4-669L17.10, RP11-206L10.9, FAM87B, LINC00115, FAM41C, RP11-54O7.1, SAMD11 
 Layers:
 counts.counts, counts.scale.data # These should be counts, scale.data

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions