This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to select data from assays list in SummarizedExperiment to plot

I am using DEP Bioconductor package https://bioconductor.org/packages/release/bioc/vignettes/DEP/inst/doc/DEP.html I want to visualize normal distribution of data using fitdistrplus pakage's descdist function

However I get an error. How can I select data from assays list in SummarizedExperiment to plot?

 # Normalize the data
 data_norm <- normalize_vsn(data_filt)

 data_for_dist <- data_filt@assays$`.->data`@listData %>%as.data.frame() %>% na.omit() %>% gather(sample,value)

 descdist(data_for_dist$value)

Error

Error in h(simpleError(msg, call)) :    error in evaluating the argument 'object' in selecting a method for function 'na.omit': error in evaluating the argument 'x' in selecting a method for function 'as.data.frame': $ operator not defined for this S4 class
r bioconductor dep summarizedexperiment

I think the correct syntax should be :

data_for_dist <- data_filt@assays@data@listData %>%as.data.frame() %>% na.omit() %>% gather(sample,value)

Check the structure of data_filt@assays, because .->data sounds me strange

Thank you this works.

1 answer

The SummarizedExperiment format, like (almost) every Bioconductor data structure has setter and getter functions that access slots and assays. Here that is:

assay(data_filt, assayName)

assayName is the name of the assay but can be omitted if it only holds a single assay, then the first one is used. Use assayNames to see all assays in the SE. Disagree here with the comment to manually access slots as this structure might change in future releases and break code while getter functions are constant. See the SummarizedExperiment vignette at Bioconductor for extensive documentation on all relevant getters and setters.

Log in to answer this question.