tidySummarizedExperiment
tidySummarizedExperiment copied to clipboard
Warning:The assays in your SummarizedExperiment have row names, but they don't agree with the row names of the SummarizedExperiment object itself
Reposting from Slack.
When creating a new column in a tse
object, I get Warning: tidySummarizedExperiment says: the assays in your SummarizedExperiment have row names, but they don't agree with the row names of the SummarizedExperiment object itself. It is strongly recommended to make the assays consistent, to avoid erroneous matching of features.
For example, running
animal_tse <-
tse |>
mutate(animal_id = substr(sample_name, 1, 10))
get me Error: 67 specified rows can't be found
. I have 67 species in rowData
. I confirmed that the rownames
of the assay and the tse
object itself are identical/
I was not able to reproduce the issue on the test pasilla
data.
@HelenaLC suggested running
. <- lapply(assays(tse, withDimnames=FALSE), rownames)
sapply(.[-1], identical, .[[1]])
That gave me
sapply(.[-1], identical, .[[1]])
#> named list()
sapply(., identical, rownames(tse))
#> counts
FALSE
The code that checks for warning is here.
If I run if
checks individually, they all give me TRUE
, thus the warning.
@HelenaLC said that
If they are all TRUE, I guess the problematic line is
all(rownames(assays(se, withDimnames = FALSE)[[1]]) %in% rownames(se))
... in your original post, you did not specifywithDimnames
, so this went unnoticed.withDimnames=TRUE
(default) will basically set these on the fly, so they always appear to match. Simply overwriting the assay might fix it, e.g.,assay(tsne) <- assay(tsne)
(since the accessor sets the row names according to rownames(tsne)) ...but I'm not sure
So, doing
assay(tse) <- assay(tse)
solved the problem.
tagging @csoneson, for interest, as she worked previously on this matter.