Empty RangedData with value columns?
1
0
Entering edit mode
Rob Scharpf ▴ 250
@rob-scharpf-1931
Last seen 10.2 years ago
Hi, Would it be possible to have a column (value) in a RangedData object persist even if it has zero length? For example, RangedData(IRanges(), id=character()) has 0 value columns, though I think it would be nice if the 'id' column could persist. Afterall, it is permissable to have a DataFrame with values that are of zero length values <- DataFrame(id=character()) colnames(values) But, these values disappear in the RangedData constructor: space <- Rle(factor()) values <- split(values, space) colnames(values) where the last line above returns NULL. Thanks- Rob > sessionInfo() R Under development (unstable) (2012-02-10 r58315) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.iso885915 LC_NUMERIC=C [3] LC_TIME=en_US.iso885915 LC_COLLATE=en_US.iso885915 [5] LC_MONETARY=en_US.iso885915 LC_MESSAGES=en_US.iso885915 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.iso885915 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices datasets utils methods base other attached packages: [1] IRanges_1.13.22 BiocGenerics_0.1.4 BiocInstaller_1.3.7 loaded via a namespace (and not attached): [1] tools_2.15.0
• 839 views
ADD COMMENT
0
Entering edit mode
@michael-lawrence-3846
Last seen 2.9 years ago
United States
On Fri, Feb 10, 2012 at 9:15 AM, Robert Scharpf <rscharpf@jhsph.edu> wrote: > Hi, > > Would it be possible to have a column (value) in a RangedData object > persist even if it has zero length? > > For example, > > RangedData(IRanges(), id=character()) > > has 0 value columns, though I think it would be nice if the 'id' column > could persist. Afterall, it is permissable to have a DataFrame with values > that are of zero length > > values <- DataFrame(id=character()) > colnames(values) > > But, these values disappear in the RangedData constructor: > > space <- Rle(factor()) > values <- split(values, space) > colnames(values) > > where the last line above returns NULL. > > Internally RangedData stores its values as a SplitDataFrameList. This is a DataFrameList that the columns of all of its elements have the same columns. The question is: what should happen when it does not have any elements? Should it somehow have a separately defined set of columns? There are two implementations of SplitDataFrameList: Compressed... and Simple.... The Simple implementation would have zero information about the columns, because it is just a list of DataFrame objects internally. The Compressed implementation has a single underlying DataFrame that *does* retain the columns. However, its colnames method, as you found, has been specially written to return NULL in the length zero case, for consistency with the Simple implementation. So while we could support this for the CompressedSplitDataFrameList, RangedData currently is agnostic to the implementation, so it will not work in general. Typically, we do not encounter this problem, because RangedData() is passed a factor with a level vector of non-zero length. That way, even though RangedData has zero rows, it has non-zero length and thus still has columns. RangedData has a few peculiarities like this. It was designed when the infrastructure was much different than it is today. Perhaps a GRanges object would better suit your needs? Michael > Thanks- > > Rob > > > sessionInfo() > R Under development (unstable) (2012-02-10 r58315) > Platform: x86_64-unknown-linux-gnu (64-bit) > > locale: > [1] LC_CTYPE=en_US.iso885915 LC_NUMERIC=C > [3] LC_TIME=en_US.iso885915 LC_COLLATE=en_US.iso885915 > [5] LC_MONETARY=en_US.iso885915 LC_MESSAGES=en_US.iso885915 > [7] LC_PAPER=C LC_NAME=C > [9] LC_ADDRESS=C LC_TELEPHONE=C > [11] LC_MEASUREMENT=en_US.iso885915 LC_IDENTIFICATION=C > > attached base packages: > [1] stats graphics grDevices datasets utils methods base > > other attached packages: > [1] IRanges_1.13.22 BiocGenerics_0.1.4 BiocInstaller_1.3.7 > > loaded via a namespace (and not attached): > [1] tools_2.15.0 > > _______________________________________________ > Bioconductor mailing list > Bioconductor@r-project.org > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: > http://news.gmane.org/gmane.science.biology.informatics.conductor > [[alternative HTML version deleted]]
ADD COMMENT

Login before adding your answer.

Traffic: 725 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6