Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix access to layer data for DietSeurat in V5. #8197

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

ddiez
Copy link
Contributor

@ddiez ddiez commented Dec 16, 2023

This fixes #8054 which is caused by a change in satijalab/seurat-object@d6aa9af that changed the behavior of brakets.

@ddiez
Copy link
Contributor Author

ddiez commented May 11, 2024

I want to nudge this PR given that it has been a long time since submitted, several patches to Seurat V5 have been released and recently version 5.1.0 came out without a fix, and people are still having problems as indicated by all the imaginative ways used to overcome this in #8054. Tagging @mojaveazure since the issue was caused by a change in SeuratObject. This shows the problem with the latest version of Seurat. Using DietSeurat on pbmc_small dataset drops the dimensionality reduction objects but all the data objects remain.

> pbmc_small
An object of class Seurat
230 features across 80 samples within 1 assay
Active assay: RNA (230 features, 20 variable features)
 3 layers present: counts, data, scale.data
 2 dimensional reductions calculated: pca, tsne

> DietSeurat(pbmc_small)
An object of class Seurat
230 features across 80 samples within 1 assay
Active assay: RNA (230 features, 20 variable features)
 3 layers present: counts, data, scale.data

Specifying which layers to remove also does not work:

> DietSeurat(pbmc_small, layers="counts")
An object of class Seurat
230 features across 80 samples within 1 assay
Active assay: RNA (230 features, 20 variable features)
 3 layers present: counts, data, scale.data

Internally DietSeurat tries to remove the layers using object[[assay]][[lyr]] <- NULL but this does not work and there is no error, the request is silently ignored:

> pbmc_small[["RNA"]][["scale.data"]] <- NULL
> pbmc_small
An object of class Seurat
230 features across 80 samples within 1 assay
Active assay: RNA (230 features, 20 variable features)
 3 layers present: counts, data, scale.data
 2 dimensional reductions calculated: pca, tsne

The right way to accomplish this given the changes in SeuratObject is to use single brakets:

> pbmc_small[["RNA"]]["scale.data"] <- NULL
> pbmc_small
An object of class Seurat
230 features across 80 samples within 1 assay
Active assay: RNA (230 features, 20 variable features)
 2 layers present: counts, data
 2 dimensional reductions calculated: pca, tsne

I hope this helps implementing a fix into the main tree. Perhaps there is some reason I cannot see that prevents this fix from working. In that case I apologize. Just wanted to get this from my mind if possible!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant