RGLab / openCyto

A package that provides data analysis pipeline for flow cytometry.
GNU Affero General Public License v3.0
77 stars 29 forks source link

Export as.data.table.gatingTemplate #200

Closed DillonHammill closed 5 years ago

DillonHammill commented 5 years ago

Hi @mikejiang & @jacobpwagner,

Would it be possible to to export as.data.table.gatingTemplate?

I can see it in the NAMESPACE as an exported S3 method.

This becomes apparent when you try to use this function:

gt <- gatingTemplate("Test.csv")
openCyto::as.data.table.gatingTemplate(gt)

Error: 'as.data.table.gatingTemplate' is not an exported object from 'namespace:openCyto'

Thanks, Dillon

DillonHammill commented 5 years ago

Sorry, I wasn't thinking - this is obviously adding a new method to the as.data.table generic in the data.table package. I am assuming that it cannot be directly accessed from openCyto because the generic is defined in the data.table package. As long as data.table and openCyto are loaded a call to as.data.table on objects of class gatingTemplate will work as expected. Just out of curiosity, is there a reason why this was not written as a standalone function (e.g. gatingTemplate_to_datatable) in the openCyto package?

jacobpwagner commented 5 years ago

Mike may be able to answer this a bit better as he wrote the code, but adding a method to the generic provided by data.table seems like a reasonable approach, rather than having another method name to remember/pollute the namespace. What's the use case? Do you need to be able to call it without data.table being attached? It's not ideal, but you could always explicitly call the method with openCyto:::as.data.table.gatingTemplate(gt).

DillonHammill commented 5 years ago

I am just using it to manipulate gatingTemplate entries. ::: generates R CMD CHECK NOTEs and importing into my package means I have to import a lot of other internal openCyto functions. It would be much simpler if it was a standalone function - but importing as.data.table from data.table will do the trick for now. At the moment I don't see a case where data.table and openCyto will not be loaded together but something for me to keep in mind going forward.