satijalab / seurat-object

https://satijalab.github.io/seurat-object/
Other
24 stars 25 forks source link

Fix/subset stdassay #214

Closed dcollins15 closed 3 months ago

dcollins15 commented 4 months ago

Resolves:

The issue was introduced in:

Which was in turn resolving an issue with the way the feature-level metadata was being incorrectly handled.

When calling MatchCells to subset the feature level metadata, we need to make sure that:

  1. orig contains all of the feature names that were originally in x
  2. new contains only feature names that are still in the layers of x

Our first fix took care of the first point but failed to properly address the second, causing the following error if any features were being lost in the process of subsetting out the layers:

Error in .rowNamesDF<-(x, value = value) : invalid 'row.names' length
dcollins15 commented 3 months ago

You can reproduce the initial issue / validate the fix by running:

library(SeuratObject)

left <- SeuratData::LoadData("pbmc3k")
right <- SeuratData::LoadData("ifnb")
test_case <- merge(left, right)

features_to_keep <- Features(left)[!Features(left) %in% Features(right)]
result <- subset(test_case, features = features_to_keep)

print(result)