Skip to content

Seurat3 and subsetting features with dashes (-) in the name #1212

Closed
@jeremycfd

Description

Hello,

I've found that I'm unable to use the subset() function to subset based on features that have dashes in their name.

`Aggreg.data <- Read10X(data.dir = "./filtered_feature_bc_matrix/")
test <- CreateSeuratObject(counts = Aggreg.data, min.cells = 50, min.features = 0)

This works fine:

summary(test@assays$RNA@data["CD8A",])
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.000 0.000 0.000 3.556 3.000 94.000

test2 <- subset(x = test, subset = CD8A > 0)
summary(test2@assays$RNA@data["CD8A",])
Min. 1st Qu. Median Mean 3rd Qu. Max.
1.00 3.00 6.00 9.81 14.00 94.00 `

However, this does not work:

test3 <- subset(x = test, subset = MT-CO3 > 0)
Error in FetchData(object = object, vars = expr.char[vars.use], cells = cells) :
None of the requested variables were found:
test3 <- subset(x = test, subset = 'MT-CO3' > 0)
Error in FetchData(object = object, vars = expr.char[vars.use], cells = cells) :
None of the requested variables were found:

What I find more troubling is that if a single requested variable is found, Seurat will not warn you that the "missing" variables were not used in the subset:

test4 <- subset(x = test, subset = 'MT-CO3' > 0 & nFeature_RNA > 500)
summary(test4@assays$RNA@data["MT-CO3",])
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.00 28.00 50.00 81.78 102.00 1506.00

This is kind of strange to me because Seurat will specifically convert underscores to dashes in feature names, so I assume this is not intended. Does anyone know if there is a workaround for this, or should I replace all underscores and dashes in the features tsv file before reading in the data?

Thanks!

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions