Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop DNA methylation plot and table API endpoints #70

Open
logstar opened this issue Apr 29, 2022 · 0 comments
Open

Develop DNA methylation plot and table API endpoints #70

logstar opened this issue Apr 29, 2022 · 0 comments
Labels

Comments

@logstar
Copy link
Contributor

logstar commented Apr 29, 2022

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.R to define a function, get_dna_methylation_tbl(ensg_id, efo_id), to retrieve a dataframe like object from the database.

  • Add src/get_dna_methylation_plot.R to define a function, get_dna_methylation_plot(dna_methylation_table), to use the table returned by get_dna_methylation_tbl to generate a plot, which will be transferred to MTP.

  • Add src/get_dna_methylation_summary_table.R to define a function, get_dna_methylation_summary_table(dna_methylation_table), to use the table returned by get_dna_methylation_tbl to generate a summary table, which will be transferred to MTP.

  • Add the following code to main.R to source the 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.R to 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.R to 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.

cc @afarrel @ewafula @chinwallaa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants