[Bioc-devel] R6 class v.s. S4 class

Charles Plessy charles-listes+bioc-devel at plessy.org
Fri Oct 20 03:24:05 CEST 2017


(Just sharing my thoughts as those days I am spending quite
some time preparing the upgrade of a Bioconductor package).

Le Fri, Oct 20, 2017 at 12:50:48AM +0000, Ryan Thompson a écrit :
> 
> gene_client <- BioThingsClient("gene")
> query("CDK2", client=gene_client)

In addition, since the piping operator (%>%) of dplyr and magrittr is
gaining traction, I would recommend to carefully consider which will be
the first argument of the function:

With the client as first argument, one can then write things like:

    gene_client %>% query("CDK2")  # similar to query(gene_client, "CDK2")

With the gene symbol as first argument:

    "CDK2" %>% query(gene_client)  # similar to query("CDK2", gene_client)

If gene symbols may come as output from other commands and the query
function is able to work smartly with a vector of gene symbols as input,
then the second pattern might be useful.  Otherwise the first pattern
probably makes more sense.

See https://cran.r-project.org/web/packages/magrittr/vignettes/magrittr.html for details.

(Note however that the piped and non-piped functions are not exactly
equivalent, and that piped commands can be harder to debug; therefore
it may be better to only use them in interactive sessions.)

Have a nice day,

-- 
Charles Plessy



More information about the Bioc-devel mailing list