Should work in devel, 1.99.20, as long as that object returns two
dimensions from dim(), we proceed through data.frame. Assumption is that 2D
things have an as.data.frame method.


On Sat, Jul 12, 2014 at 9:19 AM, Keith Hughitt <keith.hugh...@gmail.com>
wrote:

> Currently, IRanges does not play well with dplyr dataframes, e.g.:
>
> library(IRanges)
> library(dplyr)
>
> df = tbl_df(data.frame(
>     id=c(1,2,3),
>     group=c('a','b','c')
> ))
>
> > DataFrame(df)
>
> library(dplyr)
>
> > DataFrame(df)
> DataFrame with 2 rows and 1 column
> Error in `rownames<-`(`*tmp*`, value = c("id", "group")) :
>   length of 'dimnames' [1] not equal to array extent
> Calls: <Anonymous> -> <Anonymous> -> rownames<- -> rownames<-
>
> > sessionInfo()
> R version 3.1.0 (2014-04-10)
> Platform: x86_64-unknown-linux-gnu (64-bit)
>
> locale:
>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
> LC_TIME=en_US.UTF-8
>  [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8
>  LC_MESSAGES=en_US.UTF-8
>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C
>
> [10] LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8
> LC_IDENTIFICATION=C
>
> attached base packages:
> [1] parallel  stats     graphics  grDevices utils     datasets  methods
> base
>
> other attached packages:
> [1] dplyr_0.2           IRanges_1.99.18     S4Vectors_0.1.2
> BiocGenerics_0.11.3
> [5] vimcom_1.0-0        setwidth_1.0-3      colorout_1.0-3
>
> loaded via a namespace (and not attached):
> [1] assertthat_0.1 Rcpp_0.11.2    stats4_3.1.0   tools_3.1.0
>
> Any easy work-around to this is simply to cast the dplyr dataframes to a
> regular dataframe before passing them in to IRange constructors, etc.:
>
> > DataFrame(as.data.frame(df))
> DataFrame with 3 rows and 2 columns
>          id    group
>   <numeric> <factor>
> 1         1        a
> 2         2        b
> 3         3        c
>
> However, since tbl_df's are dataframes themselves, it seems like it should
> not be too difficult to support them natively, or at the very least, check
> for/cast them to data frames in IRanges.
>
> Is there any chance this can be supported in future versions of IRanges?
>
> Regards,
> Keith
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> Bioc-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/bioc-devel
>

        [[alternative HTML version deleted]]

_______________________________________________
Bioc-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/bioc-devel

Reply via email to