[Bioc-devel] inconsistent metadata when deleting a column from a DataFrame

Michael Lawrence lawrence.michael at gene.com
Mon Nov 13 14:55:49 CET 2017


This is a bug. I a fix into devel.

It involved some refactoring. Basically moved code that already handled
this case from [[<-,CompresedList to [[<-,List and added a
setListElement,CompressedList. This tightens the role of setListElement():
it just sets list elements (no removal, no names, no metadata handling).
Should make it easier to implement new List derivatives.

Michael


On Sun, Nov 12, 2017 at 1:55 PM, Alejandro Reyes <
alejandro.reyes.ds at gmail.com> wrote:

> Hello,
>
> I noticed that when I delete a column from a DataFrame by assigning it to
> NULL, the column is deleted from the DataFrame but the corresponding
> element-wise metadata is not deleted.
>
> > library(S4Vectors)
> !> df <- DataFrame(A=1:10, B=1:10 )
>  > mcols( df )$colNum <- sprintf( "col num %d", seq_len( ncol( df ) ) )
>  > df[["B"]] <- NULL
>  > ncol(df)
>  [1] 1
>  > nrow(mcols(df))
>  [1] 2
>
> After doing this, I get the following error when I try to assign new
> columns:
>
> > df$C <- 1:10
>  Error in V_recycle(value, x, x_what = "value", skeleton_what = "x") :
>    'NROW(value)' is greater than 'length(x)'
>
> Is this behavoir intended? or am I missing something?
>
> > sessionInfo()
>  R version 3.4.2 (2017-09-28)
>  Platform: x86_64-apple-darwin15.6.0 (64-bit)
>  Running under: macOS High Sierra 10.13.1
>
>  Matrix products: default
>  BLAS: /Library/Frameworks/R.framework/Versions/3.4/
> Resources/lib/libRblas.0.dylib
>  LAPACK: /Library/Frameworks/R.framework/Versions/3.4/
> 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] SummarizedBenchmark_0.99.0 data.table_1.10.4-3        stringr_1.2.0
>  [4] rlang_0.1.4                UpSetR_1.3.3
>  SummarizedExperiment_1.8.0
>  [7] DelayedArray_0.4.1         matrixStats_0.52.2         Biobase_2.38.0
> [10] GenomicRanges_1.30.0       GenomeInfoDb_1.14.0        IRanges_2.12.0
> [13] S4Vectors_0.16.0           BiocGenerics_0.24.0        tidyr_0.7.2
>
> loaded via a namespace (and not attached):
>  [1] Rcpp_0.12.13            XVector_0.18.0          magrittr_1.5
>   zlibbioc_1.24.0
>  [5] munsell_0.4.3           colorspace_1.3-2        lattice_0.20-35
>    plyr_1.8.4
>  [9] tools_3.4.2             grid_3.4.2              gtable_0.2.0
>   lazyeval_0.2.1
> [13] tibble_1.3.4            Matrix_1.2-11           gridExtra_2.3
>    GenomeInfoDbData_0.99.1
> [17] purrr_0.2.4             ggplot2_2.2.1           bitops_1.0-6
>   RCurl_1.95-4.8
> [21] glue_1.2.0              stringi_1.1.5           compiler_3.4.2
>   scales_0.5.0
>
>
>
> Best regards,
>> Alejandro Reyes, Ph.D.
> Research Fellow, Irizarry Lab
> Dana-Farber Cancer Institute
> Harvard T.H. Chan School of Public Health
> Boston, USA
>
> _______________________________________________
> Bioc-devel at 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