-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
Hi!
I noticed that trying to subset SE with factors lead to error that might be hard to solve. This problematic scenario can occur, for instance, if user has run some method that returns feature names as factors instead of characters (for example, table including results and feature names).
If user tries to select specified features based on factor, it leads to ambiguous error.
library(SummarizedExperiment)
counts <- matrix(
1:4,
nrow = 2,
ncol = 2,
dimnames = list(c("gene1", "gene2"), c("sample1", "sample2")
)
)
se <- SummarizedExperiment(assays = list(counts = counts))
se["gene1", ]
se[factor("gene1"), ]
Error: cannot subset by character when rownames are NULL
Since SE converts factors to characters when setting row or column names, it may be reasonable to treat them as character variables also when subsetting.
-Tuomas
Metadata
Metadata
Assignees
Labels
No labels