Skip to content

Commit

Permalink
Update to README.md for methodology, only partially complete.
Browse files Browse the repository at this point in the history
  • Loading branch information
davids60 committed Jun 18, 2024
1 parent 4a705a7 commit 5c8e6d8
Showing 1 changed file with 37 additions and 8 deletions.
45 changes: 37 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,20 @@ The input data file must be in .xls format **NOT .XLSX**. Additionally, the file
| Positive Reaction Threshold | 0.9 |
| False Positive Threshold | 0.2 |

Finally, the number of replicates will be set at 4.
Finally, the number of replicates will be set at 4:
| Parameter | Value |
|:---:|:---:|
| Number of Replicates | 4 |
| Instrument Saturation/Maximum Intensity | 140000 |
| Positive Threshold Percentage | 0.1 |

The thresholds above will be used to the time at which the reactThe ion enters and exits the Exponential and Plateau phases, respectively. For a reaction to be considered a complete reaction, the plateau phase must occur after the exponential phase.
The thresholds above are presently non-functional, but are retained for potential future use. Reaction time is determined as the maximum of the second derivative of the intensity over time.


To use custom weightings, execute the following line of code with the given arguments.

```
PrimerScoring.initialize(set_weights, set_thresholds, set_replicates.)
PrimerScoring.initialize(set_weights, set_thresholds, set_replicates, set_instrumentMax, set_threshold_perc)
```
The arguments in the above expression are defined as:
- set_weights: An array containing weights for the following metrics in the following order:
Expand All @@ -73,13 +78,12 @@ The arguments in the above expression are defined as:
- Avg. Reaction Time
- Number of False Positives
- **THE ARRAY MUST CONTAIN WEIGHTS FOR ALL OF THE ABOVE METRICS.**
- set_thresholds: An array contianing weights for the threshold tolerances of the exponential and plateau phases, positive reaction threshold, and false positive threshold, respectively.
- **THE ARRAY MUCH CONTAIN THRESHOLDS FOR BOTH PHASES AND BOTH THRESHOLDS**
- set_thresholds: An array contianing weights for the threshold tolerances of the exponential and plateau phases, positive reaction threshold, and false positive threshold, respectively. Whereas this value can be set, it is currently not in use.
- set_replicates: An integer value greater than 3 for the number of replicates. **Must be the same for all primer sets scored.**

An example to initialize to default settings as above would be as follows:
```
PrimerScoring.intialize([5,5,10,20,60], [3000, 200, 0.9, 0.2], 4)
PrimerScoring.intialize([5,5,10,20,60], [3000, 200, 0.9, 0.2], 4, 140000, 0.1)
```

### Scoring
Expand All @@ -105,7 +109,32 @@ The arguments in the above line of code are defined as follow:
- Intensity_StdDev: Calculated maximum intensity standard deviation.
- RxnTime_Avg: Calculated average reaction time.
- RxnTime_StdDev: Calculated reaction time standard deviation.
- False_Positives: Number of false positives.
- False_Positives: Number of total false positives.
- FP_...: There will be a false positive column for each replicate containing the contribution of that false positive to the overall score.
- Overall Score: Calculated overall score for each primer set.


# Methodology

## Positive amplification detection
LAMP amplification reactions typically produce a sigmoidal amplification; however, given fluorometric methods typically have some background auto-flourescence or variable response over time, it is not sufficient to simply check for an increase in signal over time. To this end, the following methodology was used to determine a "positive amplification", regardless of designation (true positive or No Template Control (NTC)):

1. The series containing the fluorometric reads over time was duplicated and reversed.
2. The intersection of the series and the reversed series was determined by the time point at which the forward time-series first exceeded the reverse time-series.
3. Two vectors were created, one for the forward time series and one for the reverse, using the following definition:
- $\overrightarrow{\text{Forward/Reverse Data Vector}} = <\text{Time of Intersection }, y_{Intersection} - y_0>$
4. The cosine between to two vectors was calculated
- $\theta = \arccos(\frac{\overrightarrow{\text{Forward}}\cdot\overrightarrow{\text{Reverse}}}{\|\overrightarrow{\text{Forward}}\| \| \overrightarrow{\text{Reverse}}\|})$
5. Using the understanding that $\cos(x) \approx 1$ if $x \approx 0 $, we check that the $\cos{\theta} > 0.95$ assuming a 95% error in the approximatation. Essentially, these steps are checking to see if our data is "flat" or relatively constant within error.
- If it is, we will return that this reaction is not a positive amplification
- If it is not, continue to step 6.
6. Check if the maximum of the time series is above some threshold percentage of the maximum fluorescent intensity of the instrument, and if it does return a positive amplification.
- Default parameters for maximum fluorescent intensity taken on an Analytik-Jena qTower 3G is approximately 140000 Relative Fluorescence Units.
- Default threshold percentage is 10%.

## Reaction time
Reaction time is determined as the maximum of the 2nd derivative of the fluorescent time series data. This is implemented using [`numpy.gradient`](https://numpy.org/devdocs/reference/generated/numpy.gradient.html).

## Weighting of False Positives
False positives are undesireable in the context of the developed diagnostics and hence are weighted very strongly to filter out primer sets that produce false positives. Additionally, it is possible to have a one-off or rare occurrence false positive due to operator error or contamination, rather than an inherent interaction of the primers in the primer set, which should be strongly discouraged.

To this end, a "progressive" penalty for increasing occurrence of false positives was implemented to select for primer sets with less "persistent" false positives.

0 comments on commit 5c8e6d8

Please sign in to comment.