The R API is a script that allows access to your MOLGENIS data via the R-Project statistical package. It is available on every MOLGENIS on the URL http://molgenis.mydomain.example/molgenis.R.
NOTE: The MOLGENIS R-api client supports up to R-version 3.2.x
As an example, let's create a plot for publicly available ASE data available on https://molgenis56.target.rug.nl/. For a description of the data, take a look at http://molgenis.org/ase.
The ASE data from the previous example is publicly available. To access private data, you can log in using
molgenis.login("your username", "your password")
This will create a molgenis token on the server and set it in the molgenis.token variable in your R workspace.
When you're done, you can log out using
molgenis.logout()
Retrieving more rows
By default, molgenis.get will retrieve up to 1000 rows only.
If you need more rows, you can request up to 10000 rows by adding the num parameter:
molgenis.get("ASE", num=2000)
will retrieve the top 2000 rows from the ASE entity.
Pagination
You can retrieve the data page-by-page.
molgenis.get("ASE", num=5)
will retrieve a first page of 5 rows and
molgenis.get("ASE", num=5, start=5)
will retrieve the second page of 5 rows.
Cross server scripting
By default, the MOLGENIS R API retrieves its data from the server you retrieved it from, so if you want to retrieve data from a different server, simply source the molgenis.R from that server.
But if you want to combine data from multiple server, you can specify a different REST API URL to use by setting molgenis.api.url in the molgenis.env environment. For example: