Skip to content

Commit

Permalink
Added LPR example report
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Jun 18, 2024
1 parent 3c6e73d commit ca54662
Show file tree
Hide file tree
Showing 12 changed files with 176 additions and 17 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ An example vignette for the dichotomous (binary) data is located [here](./vignet
Example data for dichotomous and light photomotor response data can be found [here](./data/).

### Example Report
A sample for the generated report output can be found [here](https://github.com/PNNL-CompBio/bmdrc/blob/main/example_report/Benchmark%20Dose%20Curves.md)
A sample for the generated report for dichotomous (binary) data can be found [here](https://github.com/PNNL-CompBio/bmdrc/blob/main/example_report/binary_class/Benchmark%20Dose%20Curves.md)

A sample for the generated report for light photomotor response data can be found [here](https://github.com/PNNL-CompBio/bmdrc/blob/main/example_report/lpr_class/Benchmark%20Dose%20Curves.md)
File renamed without changes.
File renamed without changes
127 changes: 127 additions & 0 deletions example_report/lpr_class/Benchmark Dose Curves.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# Benchmark Dose Curves

## Input Data

A **lpr class** object was created. The following column names were set:

|Parameter|Column Name|
|---------|-----------|
|Chemical|chemical.id|
|Plate|plate.id|
|Well|well|
|Concentration|conc|
|Time|variable|
|Value|value|
|Cycle Length|20.0|
|Cycle Cooldown|10.0|
|Starting Cycle|light|

## Pre-Processing

#### **Combine & Make New Endpoints**
New endpoints were made using existing endpoints using 'or', which means that if there is any endpoints with a '1', this new endpoint will also have a '1', regardless of how many zeroes there are in the other endpoints. See a summary table of added endpoints below:

|New Endpoint Name|Combined Existing Endpoints|
|---|---|
|ANY_MOV|MOV1, MOV2, MOV3, MOV4|
|ANY_AUC|AUC1, AUC2, AUC3, AUC4|

#### **Set Invalid Wells to NA**

In some cases, like when a sample fish dies, many affected endpoints need to be set to NA. Here, the 'Endpoint Name' column denotes the specific endpoint that sets this rule. In this example, it could be MORT for mortality. Then, the endpoint value needs to be set, which in this case would be a 1 to indicate sample fish that did die. All endpoints would then be set to NA except for cases where the endpoint should not be affected, which are referred to as 'Endpoint Exceptions.'

This step was not conducted.

#### **Remove Invalid Endpoints**

This step was not conducted.

## Filtering

#### **Negative Control Filter**

Plates with unusually high responses in negative control samples were filtered. The response threshold was set to **50.0**. See a summary below:

|Response|Number of Plates|Filter|
|---|---|---|
|0.0|6|Keep|
|8.3333|8|Keep|
|16.6667|5|Keep|
|25.0|4|Keep|
|33.3333|2|Keep|
|41.6667|1|Keep|
|50.0|2|Filter|
|75.0|2|Filter|

And here is the plot:
![Filter Negative Control](./filter_negative_control.png)

#### **Minimum Concentration Filter**

Endpoints with too few concentration measurements (non-NA) to model are removed. The minimum was set to **3**. See a summary below:

|Number of Concentrations|Number of Endpoints|Filter|
|---|---|---|
|8|10|Keep|

And here is the plot:
![Filter Minimum Concentration](./filter_minimum_concentration.png)

#### **Correlation Score Filter**

Endpoints with little to no positive correlation with dose are unexpected and should be removed. The correlation threshold was set to **0.2**. See a summary below:

|Correlation Score Bin|Number of Endpoints|
|---|---|
|-1.0|0.0|
|-0.8|0.0|
|-0.6|2.0|
|-0.4|1.0|
|-0.2|2.0|
|0.0|3.0|
|0.2|2.0|
|0.4|0.0|
|0.6|0.0|
|0.8|0.0|

And here is the plot:
![Filter Correlation Score](./filter_correlation_score.png)

## Model Fitting & Output Modules

#### **Filter Summary**

Overall, 10 endpoint and chemical combinations were considered. 2 were deemed eligible for modeling, and 8 were not based on filtering selections explained in the previous section.

#### **Model Fitting Selections**

The following model fitting parameters were selected.

|Parameter|Value|Parameter Description|
|---|---|---|
|Goodness of Fit Threshold|0.1|Minimum p-value for fitting a model. Default is 0.1|
|Akaike Information Criterion (AIC) Threshold|2.0|Any models with an AIC within this value are considered an equitable fit. Default is 2.
|Model Selection|lowest BMDL|Either return one model with the lowest BMDL, or combine equivalent fits|

#### **Model Quality Summary**

Below is a summary table of the number of endpoints with a high quality fit (a flag of 1, meaning that the BMD10 value is within the range of measured doses) and those that are not high quality (a flag of 0).

|Flag|Count|
|---|---|
|0|0|
|1|2|

#### **Output Modules**

Below, see a table of useful methods for extracting outputs from bmdrc.

|Method|Description|
|---|---|
|.bmds|Table of fitted benchmark dose values|
|.bmds_filtered|Table of filtered models not eligible for benchmark dose calculations|
|.output_res_benchmark_dose|Table of benchmark doses for all models, regardless of whether they were filtered or not|
|.p_value_df|Table of goodness of fit p-values for every eligible endpoint|
|.aic_df|Table of Akaike Information Criterion values for every eligible endpoint|
|.response_curve|Plot a benchmark dose curve for an endpoint|

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/bmdrc/BinaryClass.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ def output_benchmark_dose(self, path = None):
benchmark_dose(self, path)

@abstractmethod
def report(self, out_folder, report_name = "Benchmark Dose Curves", max_curve_plots = 5):
report_binary(self, out_folder, report_name, max_curve_plots)
def report(self, out_folder, report_name = "Benchmark Dose Curves"):
report_binary(self, out_folder, report_name)



Expand Down
49 changes: 35 additions & 14 deletions src/bmdrc/output_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def BMD_Range_Flag(id, BMD):

self.output_res_benchmark_dose = BMDS_Final

def report_binary(self, out_folder, report_name, max_curve_plots):
def report_binary(self, out_folder, report_name):

if os.path.isdir(out_folder) == False:
os.mkdir(out_folder)
Expand All @@ -58,19 +58,40 @@ def report_binary(self, out_folder, report_name, max_curve_plots):
## PULL INPUT DATA CHARACTERISTICS ##
#####################################

out_string = "# " + str(report_name) + "\n\n" + \
"## Input Data\n\n" + \
"A **binary class** object was created using data in **" + str(self.format) + "** format." + \
" The following column names were set:\n\n" + \
"|Parameter|Column Name|\n" + \
"|---------|-----------|\n" + \
"|Chemical|" + str(self.chemical) + "|\n" + \
"|Plate|" + str(self.plate) + "|\n" + \
"|Well|" + str(self.well) + "|\n" + \
"|Concentration|" + str(self.concentration) + "|\n" + \
"|Endpoint|" + str(self.endpoint) + "|\n" + \
"|Value|" + str(self.value) + "|\n\n" + \
"## Pre-Processing\n\n#### **Combine & Make New Endpoints**\n"
if str(type(self)) != "<class 'bmdrc.LPRClass.LPRClass'>":

out_string = "# " + str(report_name) + "\n\n" + \
"## Input Data\n\n" + \
"A **binary class** object was created using data in **" + str(self.format) + "** format." + \
" The following column names were set:\n\n" + \
"|Parameter|Column Name|\n" + \
"|---------|-----------|\n" + \
"|Chemical|" + str(self.chemical) + "|\n" + \
"|Plate|" + str(self.plate) + "|\n" + \
"|Well|" + str(self.well) + "|\n" + \
"|Concentration|" + str(self.concentration) + "|\n" + \
"|Endpoint|" + str(self.endpoint) + "|\n" + \
"|Value|" + str(self.value) + "|\n\n" + \
"## Pre-Processing\n\n#### **Combine & Make New Endpoints**\n"

else:

out_string = "# " + str(report_name) + "\n\n" + \
"## Input Data\n\n" + \
"A **lpr class** object was created." + \
" The following column names were set:\n\n" + \
"|Parameter|Column Name|\n" + \
"|---------|-----------|\n" + \
"|Chemical|" + str(self.chemical) + "|\n" + \
"|Plate|" + str(self.plate) + "|\n" + \
"|Well|" + str(self.well) + "|\n" + \
"|Concentration|" + str(self.concentration) + "|\n" + \
"|Time|" + str(self.time) + "|\n" + \
"|Value|" + str(self.value) + "|\n" + \
"|Cycle Length|" + str(self.cycle_length) + "|\n" + \
"|Cycle Cooldown|" + str(self.cycle_cooldown) + "|\n" + \
"|Starting Cycle|" + str(self.starting_cycle) + "|\n\n" + \
"## Pre-Processing\n\n#### **Combine & Make New Endpoints**\n"

############################
## PRE-PROCESSING RESULTS ##
Expand Down
9 changes: 9 additions & 0 deletions vignettes/LPR Class Example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,15 @@
"response = LPR.output_res_benchmark_dose\n",
"response"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
"LPR.report(out_folder = \"/Users/degn400/Downloads/LPR_Out\")"
]
}
],
"metadata": {
Expand Down

0 comments on commit ca54662

Please sign in to comment.