PediatricOpenTargets / OpenPedCan-api

2 stars 7 forks source link

Add CNV Evidence Plot plot and table API endpoints #82

Open kelseykeith opened 1 year ago

kelseykeith commented 1 year ago

Add CNV evidence plot and JSON table creation code to the API using the database schema and tables build in PedatricOpenTargets/OpenPedCan-api#81. This ticket is heavily based off the thorough example @logstar wrote for building the methylation database plots and tables in PedatricOpenTargets/OpenPedCan-api#70.

For the CNV evidence plot view, 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_cnv_evidence plot and table endpoints:

source("src/get_cnv_evidence_tbl.R")
source("src/get_cnv_evidence_plot_tbl.R")
source("src/get_cnv_evidence_plot_summary_tbl.R")
#* Get a single-gene single-disease CNV table
#*
#* @tag "CNV"
#* @param ensemblId:str one gene ENSG ID.
#* @param efoId:str one EFO ID.
#* @serializer json
#* @get /cnv/evidence/json
function(ensemblId, efoId) {
  cnv_evidence_table <- get_cnv_evidence_tbl(
    ensg_id = ensemblId, efo_id = efoId)

  cnv_evidence_summary_table <- get_cnv_evidence_plot_summary_tbl(
    cnv_evidence_table)

  return(cnv_evidence_summary_table)
}

#* Get a single-gene single-disease CNV plot
#*
#* @tag "CNV"
#* @param ensemblId:str one gene ENSG ID.
#* @param efoId:str one EFO ID.
#* @serializer png list(res = 300, width = 6000, height = 2700)
#* @get /cnv/evidence/plot
function(ensemblId, efoId) {
 cnv_evidence_table <- get_cnv_evidence_tbl(
    ensg_id = ensemblId, efo_id = efoId)

  cnv_evidence_plot <- get_cnv_evidence_plot(
    cnv_evidence_table)

  print(get_cnv_evidence_plot)
}