[Bioc-devel] SummarizedExperiment: structure loss, when mixing matrix and data.frame data

Hervé Pagès hpages at fredhutch.org
Wed Nov 29 18:33:17 CET 2017


Hi Felix,

This should be addressed in S4Vectors 0.17.11. Thanks for the catch and
for the nice reproducible example.

Best,
H.


On 11/26/2017 04:09 AM, Felix Ernst wrote:
> Hi all,
>
> I got different results constructing a SummarizedExperiment in 3.6 and 3.7. My question is, whether this is intentional or a bug.
>
> library(GenomicRanges)
> library(SummarizedExperiment)
>
> nrows <- 200; ncols <- 6
> counts <- matrix(runif(nrows * ncols, 1, 1e4), nrows)
> colnames(counts) <- LETTERS[1:6]
> rownames(counts) <- 1:nrows
> counts2 <- counts-floor(counts)
> rowRanges <- GRanges(rep(c("chr1", "chr2"), c(50, 150)),
>                       IRanges(floor(runif(200, 1e5, 1e6)), width=100),
>                       strand=sample(c("+", "-"), 200, TRUE),
>                       feature_id=sprintf("ID%03d", 1:200))
> colData <- DataFrame(Treatment=rep(c("ChIP", "Input"), 3),
>                       row.names=LETTERS[1:6])
>
> se <- SummarizedExperiment(assays=list(counts=counts),
>                             rowRanges=rowRanges,
>                             colData=colData)
>
> str(assays(se)$counts)
> assays(se)$counts2 <- as.data.frame(counts2)
> str(assays(se)$counts)
>
> On a Windows 10 R3.4.2 Bioc 3.6 this produces:
> num [1:200, 1:6] 8815 6314 1945 6185 5935 ...
>   - attr(*, "dimnames")=List of 2
>    ..$ : chr [1:200] "1" "2" "3" "4" ...
>    ..$ : chr [1:6] "A" "B" "C" "D" ...
>   num [1:200, 1:6] 8815 6314 1945 6185 5935 ...
>   - attr(*, "dimnames")=List of 2
>    ..$ : chr [1:200] "1" "2" "3" "4" ...
>    ..$ : chr [1:6] "A" "B" "C" "D" ...
>
> On Ubuntu 17.10 R-devel r73779 Bioc3.7  this produces
> num [1:200, 1:6] 8636 7040 9275 4821 2475 ...
>   - attr(*, "dimnames")=List of 2
>    ..$ : chr [1:200] "1" "2" "3" "4" ...
>    ..$ : chr [1:6] "A" "B" "C" "D" ...
>   num [1:1200] 8636 7040 9275 4821 2475 ...
>
> Somehow the structure is lost.
>
> This happens, if I mix matrix and data.frame data, and doesn’t, if I use only matrices. The man page defines matrix-like objects,
> which a data.frame is (isn’t it?) and the behavior is different from Bioc3.6 to Bioc3.7.
>
> I can rule out that this is a Windows/Linux thing, because the Travis build error, which pointed to an difference in the first place,
> didn‘t occur with bioc-release, just with bioc-devel.
>
> Thanks for any advice and suggestions.
>
> Felix
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> Bioc-devel at r-project.org mailing list
> https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_bioc-2Ddevel&d=DwIGaQ&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=r0ReaWhkBHVdtwgDqm28L7sqt0X9ojrCFKYn2Q0gV-I&s=qmErsDhhNpyiprtwyB72UUXQr33EJH8nd4JupFmmSBA&e=
>

-- 
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpages at fredhutch.org
Phone:  (206) 667-5791
Fax:    (206) 667-1319



More information about the Bioc-devel mailing list