mikemc / speedyseq

Speedy versions of phyloseq functions
https://mikemc.github.io/speedyseq/
Other
46 stars 6 forks source link

`as_tibble()` is masked when tibble is loaded after speedyseq #61

Closed mikemc closed 3 years ago

mikemc commented 3 years ago

Example shown below. I think maybe we don't want to export speedyseq's as_tibble, which is only defined to handle s4 classes...but how can we get tibble's s3 as_tibble to pay attention to phyloseq's s4 classes? can we declare them as s3 classes as well?

Also, if we load tibble then speedyseq, then as_tibble(df) won't work on a plain df - to solve this problem we could perhaps just define the default method of speedyseq's as_tibble to call tibble::as_tibble.

> library(speedyseq)
Loading required package: phyloseq

Attaching package: ‘speedyseq’

The following objects are masked from ‘package:phyloseq’:

    filter_taxa, plot_bar, plot_heatmap, plot_tree, psmelt, tax_glom,
    tip_glom, transform_sample_counts

> library(tibble)

Attaching package: ‘tibble’

The following object is masked from ‘package:speedyseq’:

    as_tibble

> data(GlobalPatterns)
> GlobalPatterns %>% as_tibble
Error in as.data.frame.default(value, stringsAsFactors = FALSE) : 
  cannot coerce class ‘structure("phyloseq", package = "phyloseq")’ to a data.frame
> 
mikemc commented 3 years ago

It seemed like the safest way to avoid confusion over which as_tibble method will get used is to just create a new S4 generic function ps_tibble()