PediatricOpenTargets / OpenPedCan-api

2 stars 7 forks source link

📫Implement `/tpm/gene-disease-gtex/json` and `/tpm/gene-disease-gtex/plot` API endpoints #11

Closed logstar closed 3 years ago

logstar commented 3 years ago

Pull Request Template

Description

Implemented the HTTP GET methods of /tpm/gene-disease-gtex/plot and /tpm/gene-disease-gtex/plot endpoints. These two endpoints handle HTTP requests for OpenPedCan-analysis cancer_group and gtex_subgroup boxplot and summary table, according to the API specifications in https://nih.box.com/s/5cq2jwi6bhg0mgnowad3e6e4i60hwbnr.

The /tpm/gene-all-cancer/json and /tpm/gene-all-cancer/plot endpoints are placeholders, which will be implemented next. More development action items are described in the "API Development roadmap" section of README.md.

Type of change

Please delete options that are not relevant.

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

Test Configuration:

# working directory is the project directory (the directory that contains .git of this git repo)
bash tests/run_r_lintr.sh

docker build -t open-ped-can-api . && docker run -p 8082:80 -e DEBUG=1 open-ped-can-api

bash tests/curl_test_endpoints.sh

tests/curl_test_endpoints.sh sends multiple HTTP requests to localhost:8082 by default, with the following steps.

  • Send an HTTP request using curl.
  • Output the HTTP response body to tests/http_response_output_files/png or tests/http_response_output_files/json.
  • Print HTTP response status code, content type, and run time.
  • If response body content type is JSON, convert the JSON file to TSV file in tests/results.

Terminal returns:

$ bash tests/run_r_lintr.sh
$ rm tests/http_response_output_files/json/*.json && rm tests/http_response_output_files/png/*png && bash tests/curl_test_endpoints.sh 

# ... 20 blank lines to separate from previous commands

GET http://localhost:8082/tpm/gene-disease-gtex/json?ensemblId=ENSG00000213420&efoId=EFO_0000621
http_code: 200
content_type: application/json
time_total: 0.563885 seconds

GET http://localhost:8082/tpm/gene-disease-gtex/plot?ensemblId=ENSG00000213420&efoId=EFO_0000621
http_code: 200
content_type: image/png
time_total: 1.895809 seconds

GET http://localhost:8082/tpm/gene-disease-gtex/json?ensemblId=ENSG00000213420&efoId=EFO_0005543
http_code: 200
content_type: application/json
time_total: 0.698099 seconds

GET http://localhost:8082/tpm/gene-disease-gtex/plot?ensemblId=ENSG00000213420&efoId=EFO_0005543
http_code: 200
content_type: image/png
time_total: 2.106211 seconds

GET http://localhost:8082/tpm/gene-all-cancer/json?ensemblId=ENSG00000213420
http_code: 200
content_type: application/json
time_total: 0.005078 seconds

GET http://localhost:8082/tpm/gene-all-cancer/plot?ensemblId=ENSG00000213420
http_code: 200
content_type: image/png
time_total: 0.374200 seconds

GET http://localhost:8082/tpm/gene-disease-gtex/json?ensemblId=ENSG00000157764&efoId=EFO_0000621
http_code: 200
content_type: application/json
time_total: 0.825260 seconds

GET http://localhost:8082/tpm/gene-disease-gtex/plot?ensemblId=ENSG00000157764&efoId=EFO_0000621
http_code: 200
content_type: image/png
time_total: 1.898828 seconds

GET http://localhost:8082/tpm/gene-disease-gtex/json?ensemblId=ENSG00000157764&efoId=EFO_0005543
http_code: 200
content_type: application/json
time_total: 0.548490 seconds

GET http://localhost:8082/tpm/gene-disease-gtex/plot?ensemblId=ENSG00000157764&efoId=EFO_0005543
http_code: 200
content_type: image/png
time_total: 1.915610 seconds

GET http://localhost:8082/tpm/gene-all-cancer/json?ensemblId=ENSG00000157764
http_code: 200
content_type: application/json
time_total: 0.005904 seconds

GET http://localhost:8082/tpm/gene-all-cancer/plot?ensemblId=ENSG00000157764
http_code: 200
content_type: image/png
time_total: 0.361900 seconds

Note for reviewers

This PR may not need to be converted to multiple stepwise PRs, because all files are required for test running this PR.

There are also only 888 lines of implementation code, and nearly half of them are comments and assertions.

$ wc -l src/*R
   29 src/add_gene_tpm_box_group.R
   81 src/get_gene_tpm_boxplot.R
   49 src/get_gene_tpm_boxplot_summary_tbl.R
   60 src/get_gene_tpm_boxplot_tbl.R
  231 src/get_gene_tpm_tbl.R
   40 src/ggplot2_publication_theme.R
  115 src/plumber.R
  283 src/tpm_data_lists.R
  888 total

Checklist

logstar commented 3 years ago

Note for reviewers: This PR is going to be closed. Another PR will be opened with the same code/file changes from a PediatricOpenTargets/OpenPedCan-api branch, in order to deploy the code changes on https://openpedcan-api-dev.d3b.io/__docs__/.

logstar commented 3 years ago

Closed with https://github.com/PediatricOpenTargets/OpenPedCan-api/pull/12 opened.

kelseykeith commented 1 year ago

Code and Results Review

Coming back to add comments here since I skipped over this one when reviewing TPM pull requests. This looks good! The database builds correctly and integration tests function correctly