Skip to content

Develop DNA methylation plot and table API endpoints #70

Description

@logstar

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions