Skip to content

Commit

Permalink
document HillCurve.rmsd in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jbloom committed Mar 25, 2024
1 parent 68d2598 commit 394335b
Showing 1 changed file with 119 additions and 65 deletions.
184 changes: 119 additions & 65 deletions notebooks/hillcurve_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@
"execution_count": 1,
"metadata": {
"execution": {
"iopub.execute_input": "2023-12-25T15:23:59.496495Z",
"iopub.status.busy": "2023-12-25T15:23:59.496192Z",
"iopub.status.idle": "2023-12-25T15:24:01.463409Z",
"shell.execute_reply": "2023-12-25T15:24:01.462274Z",
"shell.execute_reply.started": "2023-12-25T15:23:59.496467Z"
"iopub.execute_input": "2024-03-25T00:16:10.313359Z",
"iopub.status.busy": "2024-03-25T00:16:10.312974Z",
"iopub.status.idle": "2024-03-25T00:16:17.050633Z",
"shell.execute_reply": "2024-03-25T00:16:17.049017Z",
"shell.execute_reply.started": "2024-03-25T00:16:10.313325Z"
}
},
"outputs": [],
Expand All @@ -91,11 +91,11 @@
"execution_count": 2,
"metadata": {
"execution": {
"iopub.execute_input": "2023-12-25T15:24:01.472497Z",
"iopub.status.busy": "2023-12-25T15:24:01.472109Z",
"iopub.status.idle": "2023-12-25T15:24:01.476785Z",
"shell.execute_reply": "2023-12-25T15:24:01.475930Z",
"shell.execute_reply.started": "2023-12-25T15:24:01.472464Z"
"iopub.execute_input": "2024-03-25T00:16:17.063376Z",
"iopub.status.busy": "2024-03-25T00:16:17.062854Z",
"iopub.status.idle": "2024-03-25T00:16:17.068135Z",
"shell.execute_reply": "2024-03-25T00:16:17.067334Z",
"shell.execute_reply.started": "2024-03-25T00:16:17.063333Z"
}
},
"outputs": [],
Expand All @@ -121,11 +121,11 @@
"execution_count": 3,
"metadata": {
"execution": {
"iopub.execute_input": "2023-12-25T15:24:01.481096Z",
"iopub.status.busy": "2023-12-25T15:24:01.480654Z",
"iopub.status.idle": "2023-12-25T15:24:01.485640Z",
"shell.execute_reply": "2023-12-25T15:24:01.484960Z",
"shell.execute_reply.started": "2023-12-25T15:24:01.481054Z"
"iopub.execute_input": "2024-03-25T00:16:17.071840Z",
"iopub.status.busy": "2024-03-25T00:16:17.071520Z",
"iopub.status.idle": "2024-03-25T00:16:17.075348Z",
"shell.execute_reply": "2024-03-25T00:16:17.074582Z",
"shell.execute_reply.started": "2024-03-25T00:16:17.071817Z"
}
},
"outputs": [],
Expand All @@ -138,11 +138,11 @@
"execution_count": 4,
"metadata": {
"execution": {
"iopub.execute_input": "2023-12-25T15:24:01.489752Z",
"iopub.status.busy": "2023-12-25T15:24:01.489457Z",
"iopub.status.idle": "2023-12-25T15:24:01.517264Z",
"shell.execute_reply": "2023-12-25T15:24:01.516549Z",
"shell.execute_reply.started": "2023-12-25T15:24:01.489726Z"
"iopub.execute_input": "2024-03-25T00:16:17.079066Z",
"iopub.status.busy": "2024-03-25T00:16:17.078720Z",
"iopub.status.idle": "2024-03-25T00:16:17.107888Z",
"shell.execute_reply": "2024-03-25T00:16:17.107223Z",
"shell.execute_reply.started": "2024-03-25T00:16:17.079038Z"
}
},
"outputs": [
Expand Down Expand Up @@ -284,11 +284,11 @@
"execution_count": 5,
"metadata": {
"execution": {
"iopub.execute_input": "2023-12-25T15:24:01.521396Z",
"iopub.status.busy": "2023-12-25T15:24:01.520995Z",
"iopub.status.idle": "2023-12-25T15:24:01.529641Z",
"shell.execute_reply": "2023-12-25T15:24:01.528847Z",
"shell.execute_reply.started": "2023-12-25T15:24:01.521363Z"
"iopub.execute_input": "2024-03-25T00:16:17.111916Z",
"iopub.status.busy": "2024-03-25T00:16:17.111686Z",
"iopub.status.idle": "2024-03-25T00:16:17.118923Z",
"shell.execute_reply": "2024-03-25T00:16:17.118202Z",
"shell.execute_reply.started": "2024-03-25T00:16:17.111894Z"
}
},
"outputs": [],
Expand All @@ -309,11 +309,11 @@
"execution_count": 6,
"metadata": {
"execution": {
"iopub.execute_input": "2023-12-25T15:24:01.533698Z",
"iopub.status.busy": "2023-12-25T15:24:01.533124Z",
"iopub.status.idle": "2023-12-25T15:24:01.538339Z",
"shell.execute_reply": "2023-12-25T15:24:01.537341Z",
"shell.execute_reply.started": "2023-12-25T15:24:01.533672Z"
"iopub.execute_input": "2024-03-25T00:16:17.123353Z",
"iopub.status.busy": "2024-03-25T00:16:17.123020Z",
"iopub.status.idle": "2024-03-25T00:16:17.127871Z",
"shell.execute_reply": "2024-03-25T00:16:17.127123Z",
"shell.execute_reply.started": "2024-03-25T00:16:17.123326Z"
}
},
"outputs": [
Expand Down Expand Up @@ -355,11 +355,11 @@
"execution_count": 7,
"metadata": {
"execution": {
"iopub.execute_input": "2023-12-25T15:24:01.542463Z",
"iopub.status.busy": "2023-12-25T15:24:01.542065Z",
"iopub.status.idle": "2023-12-25T15:24:01.552644Z",
"shell.execute_reply": "2023-12-25T15:24:01.551763Z",
"shell.execute_reply.started": "2023-12-25T15:24:01.542428Z"
"iopub.execute_input": "2024-03-25T00:16:17.131390Z",
"iopub.status.busy": "2024-03-25T00:16:17.131080Z",
"iopub.status.idle": "2024-03-25T00:16:17.139788Z",
"shell.execute_reply": "2024-03-25T00:16:17.138992Z",
"shell.execute_reply.started": "2024-03-25T00:16:17.131365Z"
}
},
"outputs": [
Expand Down Expand Up @@ -403,11 +403,11 @@
"execution_count": 8,
"metadata": {
"execution": {
"iopub.execute_input": "2023-12-25T15:24:01.553918Z",
"iopub.status.busy": "2023-12-25T15:24:01.553601Z",
"iopub.status.idle": "2023-12-25T15:24:01.558469Z",
"shell.execute_reply": "2023-12-25T15:24:01.557582Z",
"shell.execute_reply.started": "2023-12-25T15:24:01.553890Z"
"iopub.execute_input": "2024-03-25T00:16:17.141011Z",
"iopub.status.busy": "2024-03-25T00:16:17.140692Z",
"iopub.status.idle": "2024-03-25T00:16:17.145309Z",
"shell.execute_reply": "2024-03-25T00:16:17.144530Z",
"shell.execute_reply.started": "2024-03-25T00:16:17.140985Z"
}
},
"outputs": [
Expand Down Expand Up @@ -446,11 +446,11 @@
"execution_count": 9,
"metadata": {
"execution": {
"iopub.execute_input": "2023-12-25T15:24:01.559816Z",
"iopub.status.busy": "2023-12-25T15:24:01.559500Z",
"iopub.status.idle": "2023-12-25T15:24:01.565449Z",
"shell.execute_reply": "2023-12-25T15:24:01.564069Z",
"shell.execute_reply.started": "2023-12-25T15:24:01.559791Z"
"iopub.execute_input": "2024-03-25T00:16:17.146608Z",
"iopub.status.busy": "2024-03-25T00:16:17.146265Z",
"iopub.status.idle": "2024-03-25T00:16:17.150767Z",
"shell.execute_reply": "2024-03-25T00:16:17.150014Z",
"shell.execute_reply.started": "2024-03-25T00:16:17.146585Z"
}
},
"outputs": [
Expand Down Expand Up @@ -484,11 +484,11 @@
"execution_count": 10,
"metadata": {
"execution": {
"iopub.execute_input": "2023-12-25T15:24:01.567122Z",
"iopub.status.busy": "2023-12-25T15:24:01.566762Z",
"iopub.status.idle": "2023-12-25T15:24:01.572287Z",
"shell.execute_reply": "2023-12-25T15:24:01.571332Z",
"shell.execute_reply.started": "2023-12-25T15:24:01.567094Z"
"iopub.execute_input": "2024-03-25T00:16:17.152404Z",
"iopub.status.busy": "2024-03-25T00:16:17.152081Z",
"iopub.status.idle": "2024-03-25T00:16:17.157138Z",
"shell.execute_reply": "2024-03-25T00:16:17.156321Z",
"shell.execute_reply.started": "2024-03-25T00:16:17.152379Z"
}
},
"outputs": [
Expand Down Expand Up @@ -528,11 +528,11 @@
"execution_count": 11,
"metadata": {
"execution": {
"iopub.execute_input": "2023-12-25T15:24:01.573693Z",
"iopub.status.busy": "2023-12-25T15:24:01.573324Z",
"iopub.status.idle": "2023-12-25T15:24:02.167031Z",
"shell.execute_reply": "2023-12-25T15:24:02.166146Z",
"shell.execute_reply.started": "2023-12-25T15:24:01.573665Z"
"iopub.execute_input": "2024-03-25T00:16:17.158441Z",
"iopub.status.busy": "2024-03-25T00:16:17.158117Z",
"iopub.status.idle": "2024-03-25T00:16:17.779460Z",
"shell.execute_reply": "2024-03-25T00:16:17.778697Z",
"shell.execute_reply.started": "2024-03-25T00:16:17.158415Z"
}
},
"outputs": [
Expand Down Expand Up @@ -570,11 +570,11 @@
"execution_count": 12,
"metadata": {
"execution": {
"iopub.execute_input": "2023-12-25T15:24:02.168582Z",
"iopub.status.busy": "2023-12-25T15:24:02.168173Z",
"iopub.status.idle": "2023-12-25T15:24:02.388597Z",
"shell.execute_reply": "2023-12-25T15:24:02.387854Z",
"shell.execute_reply.started": "2023-12-25T15:24:02.168557Z"
"iopub.execute_input": "2024-03-25T00:16:17.781246Z",
"iopub.status.busy": "2024-03-25T00:16:17.780860Z",
"iopub.status.idle": "2024-03-25T00:16:17.980355Z",
"shell.execute_reply": "2024-03-25T00:16:17.979647Z",
"shell.execute_reply.started": "2024-03-25T00:16:17.781219Z"
}
},
"outputs": [
Expand All @@ -600,7 +600,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Quantifying goodness of fit\n",
"We can quantify the goodness of fit by the [coefficient of determination](https://en.wikipedia.org/wiki/Coefficient_of_determination) ($R^2$) using `HillCurve.r2`, which will be one if the curve perfectly fits the data and less than one otherwise.\n",
"Essentially, this corresponds to the fraction of the variation in the data explained by the curve.\n",
"A value of <0 means the fit is worse than just drawing a straight line through the data:"
]
},
Expand All @@ -609,11 +611,11 @@
"execution_count": 13,
"metadata": {
"execution": {
"iopub.execute_input": "2023-12-25T15:24:02.389972Z",
"iopub.status.busy": "2023-12-25T15:24:02.389625Z",
"iopub.status.idle": "2023-12-25T15:24:02.395258Z",
"shell.execute_reply": "2023-12-25T15:24:02.394557Z",
"shell.execute_reply.started": "2023-12-25T15:24:02.389949Z"
"iopub.execute_input": "2024-03-25T00:16:17.981777Z",
"iopub.status.busy": "2024-03-25T00:16:17.981546Z",
"iopub.status.idle": "2024-03-25T00:16:17.986876Z",
"shell.execute_reply": "2024-03-25T00:16:17.986270Z",
"shell.execute_reply.started": "2024-03-25T00:16:17.981755Z"
}
},
"outputs": [
Expand All @@ -631,6 +633,58 @@
"source": [
"round(curve.r2, 3)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can also quantify how well each data point is fit on average with the root mean square deviation (the square root of the mean residual)\n",
"A value of zero means the curve perfectly fits the data.\n",
"This is returned by `HillCurve.rmsd`:"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {
"execution": {
"iopub.execute_input": "2024-03-25T00:16:17.988494Z",
"iopub.status.busy": "2024-03-25T00:16:17.988229Z",
"iopub.status.idle": "2024-03-25T00:16:17.993775Z",
"shell.execute_reply": "2024-03-25T00:16:17.993054Z",
"shell.execute_reply.started": "2024-03-25T00:16:17.988469Z"
}
},
"outputs": [
{
"data": {
"text/plain": [
"0.028"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"round(curve.rmsd, 3)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In general, you might consider a curve fit to be \"good\" if **either** the `r2` is close to one, or the `rmsd` is close to zero.\n",
"Usually they will be correlated, but if the data essentially fall on a flat line (no or complete neutralization at all tested concentrations), then you could have a poor `r2` close to zero but still a small `rmsd` because in this case the curve would fit the data well (small `rmsd`) but would not be much better than a line (so poor `r2`) simply because the data are basically linear."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down

0 comments on commit 394335b

Please sign in to comment.