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

Vincent Carey stvjc at channing.harvard.edu
Fri Oct 20 03:14:31 CEST 2017


The Biothings service looks interesting -- I had a look at the variant
API and noticed that GRASP information is returned.  We don't have that
in a convenient form.  However we do have plenty of variant and gene
annotation and object classes that are relevant to these.

We have had a discussion lately about R6 and one point was raised to
the effect that reference classes (?setRefClass) in methods is better
integrated with S4 and
is probably to be preferred.  Another comment raised the concern that
reference
semantics are generally unfamiliar to users and should be used only when
fully justified.

My question would be: Do you really need an object system to allow users
to make effective use of the Biothings service/API?  We can use httr and
rjson to
issue queries and translate their results.  I am commenting with very
superficial
acquaintance with your package and hope that we can continue the discussion.

On Thu, Oct 19, 2017 at 8:25 PM, Chunlei Wu <cwu at scripps.edu> wrote:

> Hello BioC-dev group,
>
>
>            We are working on a new R package right now and plan to submit
> it to Bioconductor soon.  It's a unified R client for the collection of
> BioThings APIs (http://biothings.io). Using R6 class, it makes a lot
> sense to me as I'm coming from Python's OOP experience. It will be used
> like this:
>
>
> library(biothings)
>
> gene_client <- BioThingsR6$new("gene")
> gene_client$query("CDK2")
>
>
> variant_client <- BioThingsR6$new("variant")
> gene_client$query("dbsnp.rsid:rs1000")
>
> Each "client" above is corresponding to a specific BioThings API, e.g. one
> for gene, and one for variant. And we will have more "clients" as we are
> expanding the number of BioThings API. The same R code should work with the
> future APIs.
>
> But if we use the traditional S4 class, it will be awkward as all
> functions/methods are not "namespaced", we will need to define new
> functions for each additional API. Something like this:
>
> library(biothings)
> geneQuery("CDK2")
> variantQuery("dbsnp.rsid:rs1000")
>
> I also want to mention that "query" is not the only method for each API
> client, there will be several other methods for each client. It will
> quickly make the function names messy if we go with the S4 option.
>
> Anyway, we think we like R6 class better, but just want to get some
> feedback here if the usage pattern using R6 class has been well-accepted in
> the R community. Will the users feel cumbersome if they have to instantiate
> the class first and then make the function calls? The majority of the
> existing BioC package are indeed S4 class based, which makes us feel
> hesitated.
>
> Thanks,
>
> Chunlei
>
>
>
>
>
>
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> 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