-
Notifications
You must be signed in to change notification settings - Fork 7
Description
Develop DNA methylation plot and table API endpoints using the database schema and tables built in #69.
Following is a brief introduction on how to develop the DNA methylation plot and table API endpoints. The implementation of these procedures may require further discussions and modifications, to coordinate with #69 and the MTP web page design and development.
For each type of DNA methylation plot designed by @afarrel, a plot API endpoint and a table API endpoint need to be developed. The endpoints and R functions can take any appropriate names that are not taken by existing endpoints or functions. Following are the steps to add example gene_disease_dna_methylation plot and table endpoints:
-
Install additionally required ubuntu and R packages in
Dockerfile. -
Add
src/get_dna_methylation_tbl.Rto define a function,get_dna_methylation_tbl(ensg_id, efo_id), to retrieve a dataframe like object from the database.src/get_gene_tpm_boxplot_tbl.Rcan be used as a reference for designing and implementingget_dna_methylation_tbl.- Query should be sent to the schema and table built in Build DNA methylation database schema and tables #69. If required data are absent, add a comment in Build DNA methylation database schema and tables #69 to describe what data are required.
-
Add
src/get_dna_methylation_plot.Rto define a function,get_dna_methylation_plot(dna_methylation_table), to use the table returned byget_dna_methylation_tblto generate a plot, which will be transferred to MTP. -
Add
src/get_dna_methylation_summary_table.Rto define a function,get_dna_methylation_summary_table(dna_methylation_table), to use the table returned byget_dna_methylation_tblto generate a summary table, which will be transferred to MTP. -
Add the following code to
main.Rtosourcethe defined functions in API HTTP server R runtime:source("src/get_dna_methylation_tbl.R") source("src/get_dna_methylation_plot.R") source("src/get_dna_methylation_summary_table.R")
-
Add the following code in
src/plumber.Rto define a plot endpoint and a table endpoint.#* Get a single-gene single-disease DNA methylation table #* #* @tag "DNA methylation" #* @param ensemblId:str one gene ENSG ID. #* @param efoId:str one EFO ID. #* @serializer json #* @get /dna-methylation/gene-disease/json function(ensemblId, efoId) { dna_methylation_table <- get_dna_methylation_tbl( ensg_id = ensemblId, efo_id = efoId) dna_methylation_summary_table <- get_dna_methylation_summary_table( dna_methylation_table) return(dna_methylation_summary_table) } #* Get a single-gene single-disease DNA methylation plot #* #* @tag "DNA methylation" #* @param ensemblId:str one gene ENSG ID. #* @param efoId:str one EFO ID. #* @serializer png list(res = 300, width = 6000, height = 2700) #* @get /dna-methylation/gene-disease/plot function(ensemblId, efoId) { dna_methylation_table <- get_dna_methylation_tbl( ensg_id = ensemblId, efo_id = efoId) dna_methylation_plot <- get_dna_methylation_plot( dna_methylation_table) print(dna_methylation_plot) }
-
Add the following code to
tests/r_test_scripts/test_endpoint_http.Rto add tests to the new endpoints:list( path = "/dna-methylation/gene-disease/plot", params = c("ensemblId", "efoId")), list( path = "/dna-methylation/gene-disease/json", params = c("ensemblId", "efoId")),
The newly added endpoints can be tested following the procedures described in README.md.