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

Inconsistent behavior around single-cell objects #191

Open
bbimber opened this issue Mar 24, 2024 · 0 comments
Open

Inconsistent behavior around single-cell objects #191

bbimber opened this issue Mar 24, 2024 · 0 comments

Comments

@bbimber
Copy link
Contributor

bbimber commented Mar 24, 2024

I and others have posted about issues related to V5 assays that have a single cell. While an assay with one cell is probably a fringe case and usually not very useful, there are valid situations where they could arise. Someone posted about uses of pseudobulking. We've found these when we iterate a lot of seurat objects with some kind of subset operation with the goal for merging the resulting objects. I dont really see a good argument for why a single-cell object is inherently invalid, outside of R making it inconvenient by converting a matrix to a vector if the code doesnt account for that. The earlier Assay object, SingleCellExperiment, etc., don't have this limitation.

Below is one more example of what I'd argue is inconsistent Seurat behavior around this. You'll see you can easily start with a valid object, but after subset end up with an object that is basically non-functional with no errors in seurat:

# Example matrix with two cells
mat <- matrix(rep(1, 10), ncol = 2)
colnames(mat) <- c('Cell1', 'Cell2')
rownames(mat) <- LETTERS[1:5]

# Make object, which is valid
seuratObj <- Seurat::CreateSeuratObject(mat)

# Subset to one cell. Seurat doesnt complain about this. If a one-cell object is invalid, it should error here:
seuratObj <- subset(seuratObj, cells = 'Cell1')

# But a very basic operation fails on that object:
GetAssayData(seuratObj, layer = 'counts')

Error in methods::slot(object = object, name = "layers")[[layer]][features,  : 
  incorrect number of dimensions

The purpose of posting is to ask your team to consider re-enabling this case with V5 assays. While on the fact of it a one cell assay might not seem useful, the inability to support it does cause headaches when using a seurat object to handle data.

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

No branches or pull requests

1 participant