[Bioc-devel] DataFrame: replacement error

Michael Lawrence |@wrence@m|ch@e| @end|ng |rom gene@com
Tue Apr 2 02:36:11 CEST 2019


Thanks for the report. It should be fixed in S4Vectors 0.21.22.

On Mon, Apr 1, 2019 at 12:01 PM Ludwig Geistlinger <
Ludwig.Geistlinger using sph.cuny.edu> wrote:

> I have a SummarizedExperiment with putatively user-annoted rowData.
> I have a function that does computation on this SE and appends
> the results to the rowData.
> When (repeatedly) called on the SE, the function just overwrites /
> replaces already existing columns.
>
> In R release and S4Vectors_0.20.1
>
> > sessionInfo()
> R version 3.5.2 (2018-12-20)
> Platform: x86_64-apple-darwin15.6.0 (64-bit)
> Running under: macOS Mojave 10.14.3
>
> Matrix products: default
> BLAS:
> /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRblas.0.dylib
> LAPACK:
> /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib
>
> locale:
> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
>
> attached base packages:
> [1] parallel  stats4    stats     graphics  grDevices utils     datasets
> [8] methods   base
>
> other attached packages:
> [1] S4Vectors_0.20.1    BiocGenerics_0.28.0
>
> loaded via a namespace (and not attached):
> [1] compiler_3.5.2
>
> this works:
>
> # my rowData
> > d <- DataFrame(a=c(1,2), b=c(3,4), c=c(5,6))
> DataFrame with 2 rows and 3 columns
>           a         b         c
>   <numeric> <numeric> <numeric>
> 1         1         3         5
> 2         2         4         6
>
> # output of my function
> > d2 <- DataFrame(b=c(7,8), c=c(9,10), d=c(11,12))
> DataFrame with 2 rows and 3 columns
>           b         c         d
>   <numeric> <numeric> <numeric>
> 1         7         9        11
> 2         8        10        12
>
> # replace and simultaneously append
> > d[,colnames(d2)] <- d2
> > d
> DataFrame with 2 rows and 4 columns
>           a         b         c         d
>   <numeric> <numeric> <numeric> <numeric>
> 1         1         7         9        11
> 2         2         8        10        12
>
>
>
>
> However, using R-devel and S4Vectors_0.21.20
>
> > sessionInfo()
> R Under development (unstable) (2019-01-18 r75994)
> Platform: x86_64-apple-darwin18.2.0 (64-bit)
> Running under: macOS Mojave 10.14.3
>
> Matrix products: default
> BLAS: /Users/ludwig/Downloads/R-devel/lib/libRblas.dylib
> LAPACK: /Users/ludwig/Downloads/R-devel/lib/libRlapack.dylib
>
> locale:
> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
>
> attached base packages:
> [1] parallel  stats4    stats     graphics  grDevices utils     datasets
> [8] methods   base
>
> other attached packages:
> [1] S4Vectors_0.21.20   BiocGenerics_0.29.2
>
> loaded via a namespace (and not attached):
> [1] compiler_3.6.0
>
>
> The same replacement operation causes an error
>
> > d[,colnames(d2)] <- d2
> Error in names(x using listData) <- value :
>   'names' attribute [3] must be the same length as the vector [1]
>
>
> For data.frame, this still works in R-devel:
> > dd <- as.data.frame(d)
> > dd2 <- as.data.frame(d2)
> > dd[,colnames(dd2)] <- dd2
> > dd
>   a b  c  d
> 1 1 7  9 11
> 2 2 8 10 12
>
> How to best address this issue?
>
>
> --
> Dr. Ludwig Geistlinger
> CUNY School of Public Health
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> Bioc-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/bioc-devel
>
>

	[[alternative HTML version deleted]]



More information about the Bioc-devel mailing list