What next after creating own custom function in DataSHIELD?

Dear Team,

I need a little support with regards to creating my own custom function and running it on the server side.

I was following the tutorial provided here on " How to upload a server-side function" (D2K Wiki)

After creating a simple function following the instructions, i have no idea on how to call this function in RStudio, for instance.

Can anyone please provide or point me to a tutorial on how to do this?

Thank you in advance.

Hi @ayisharuna

You need to create a client-side function that will call your server-side function. The call is done through the DSI function datashield.aggregate() if your server-side function is an aggregate function or datashield.assign() if your server-side is an assign one.

I suggest you to have a look on an existing pair of client/server functions that you can find on DataSHIELD repositories on github and see how the datashield.aggregate() and datashield.assign() functions are used from a dsBaseClient function. Probably a simple function that you can have a look is the pair ds.abs()/absDS() (this is an assign function) or the pair ds.levels()/levelsDS() (this is an aggregate function).

Please have a look and we can discuss further if you need any help.

Many thanks, Demetris

1 Like

Hello @ayisharuna ,

When I finally understood the esential basics of DataSHIELD development I wrote a very concise guide to help new developers understand easily what’s going on. You can find it here:

https://isglobal-brge.github.io/resource_bookdown/package-info.html#example-of-datashield-package-development

You will see that I focused on local development using the DSLite package, which emulates a server. If you are further interested or this document did not answer your questions let me know.

Cheers

2 Likes

@demetris.avraam thank you very much for the information and for your time. I will take a look as you suggested.

Best regards, Ayisha.

@xescriba This is very useful. Thank you so much. I will have a look at the link you provided and I will come back if I have any further questions.

Best regards, Ayisha.

Can you please also test your function using the testing framework.

https://data2knowledge.atlassian.net/wiki/spaces/DSDEV/pages/658505761/Testing

1 Like

@alexwesterberg can we link to this developer guide for DataSHIELD on the DataSHIELD wiki. I’m not sure if the developer tutorial was ever finished.

@xescriba So I finally got down to follow the instructions in the documentation you provided; thank you very much, it was very helpful. I tested my function with DSLite as suggested and I got the result I wanted.

However, I have my own Opal installation on a server, I am wondering how I can utilize the line below to include dsBase and dsX for my own server:

dslite.server ← newDSLiteServer(config = DSLite::defaultDSConfiguration(include=c(“dsBase”, “dsX”)))

Do i include it when I build the login dataframe? A short example will be very much appreciated.

Thank you in advance

@ayisharuna I’m really glad the documentation was helpful.

If you have your own Opal server, one option would be to install your dsX package using the UI (11 Setup | Orchestrating privacy-protected big data analyses of data from different resources with R and DataSHIELD).

Another option is to use opalr to comunicate with the Opal server using an R console. The following code for example:

library(opalr)
o <- opal.login(username = "user", password = "pass", url = "https://your-opal-URL.org")
opal.execute(o, script = 'devtools::install_github("user/dsX")', async = TRUE)
dsadmin.set_package_methods(o, "dsX")
opal.logout(o)

I hope this is solves your doubt.

1 Like

Hi,

There is an even better way to install a DataSHIELD package in Opal: with dsadmin.install_local_package no need to push your local changes in github.

o <- opal.login('administrator','password', url='https://opal-demo.obiba.org')
# build archive file from local package source (in current working folder)
dsadmin.install_local_package(o, devtools::build())
opal.logout(o)

See also the other dsadmin.* functions for managing packages.

Regards
Yannick

1 Like

Thank you for the information @xescriba and @yannick . I had started with the option to first push my local changes to github but ultimately I resolved for the option by @yannick that did not require this. Still it was reading your documentation @xescriba that prompted me to make sure I set the right working directory in RStudio before running “dsadmin.install_local_package(o, devtools::build())”. So thank you both for your time!