Hi:
Given processed ChIP-Seq peaks in `GRangesList`, I want to use the functions from `SummarizedExperiment` package to render succinct summary output. However, I looked into package vignette and tried to learn how to use this on `GRangesList`. My goal is, based on `GRangesList`, I want to let R print me out the short summary list (# of regions, metadata column, rows/columns, and others). I learned the features of `SummarizedExperiment` from package vignette how to do it, but I got an error. Here is my attempt:
lapply(seq_along(grs), function(x) { SummarizedExperiment(assays = NROW(x), rowRanges = x, colData=mcols(x)) })
the error message is:
Error in if (assays_nrow != rowData_nrow) { : argument is of length zero
why getting this error? How to fix that? How to apply `summarizedExperiment` method on `GRangesList` to render summary list? Can anyone direct me how to make this happen? Thanks in advance
Briefly, there is no simple approach to this. However, to get a working example:
library(GenomicRanges)
library(SummarizedExperiment)
example(GRangesList) # creates 'grl' in .GlobalEnv
colrep = function(x,n) matrix(x, nr=length(x), nc=n) # utility to create usable 'assay'
msel = lapply(grl, function(x) SummarizedExperiment(colrep(start(x),nrow(mcols(x))), rowRanges=x,
colData=mcols(x)))
> msel
$gr1
class: RangedSummarizedExperiment
dim: 1 1
metadata(0):
assays(1): ''
rownames: NULL
rowData names(2): score GC
colnames: NULL
colData names(2): score GC
$gr2
class: RangedSummarizedExperiment
dim: 2 2
metadata(0):
assays(1): ''
rownames: NULL
rowData names(2): score GC
colnames: NULL
colData names(2): score GC
$gr3
class: RangedSummarizedExperiment
dim: 2 2
metadata(0):
assays(1): ''
rownames: NULL
rowData names(2): score GC
colnames: NULL
colData names(2): score GC
Your attempt failed because you did not supply a matrix for "assay".
@Vincent: Dear Vincent, thanks for your help. BTW, I am expecting rather simple, intuitive solution to achieve my goal. What if I first flatten out
GRangesList
as one commonGRanges
, then useSummarizedExperiment
package to render simple statistics? Is that workable?@Vincent: Dear vincent, the problem I faced is printing out
GRangesList
is not favorable for me, while rendering summary of eachGRanges
would be good option aims to give clear output for the user, that's why I am trying to find the easy workaround for this problem. Hope you will direct me some useful solution. Thanks in advance :)