summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Bedo <cu@cua0.org>2022-09-29 09:30:22 +1000
committerJustin Bedo <cu@cua0.org>2022-09-29 09:34:09 +1000
commit21a9f128d5bbbd1faa8571fd0233907a470acedf (patch)
tree04fddbe73a266a461e126756e019d9e18a149f3d
parent0d55380acb3af5391714b89666a1c008c9c720f4 (diff)
simplify puCorrection
-rw-r--r--src/scrape.hs15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/scrape.hs b/src/scrape.hs
index 1cccb67..c9ff8e1 100644
--- a/src/scrape.hs
+++ b/src/scrape.hs
@@ -78,7 +78,7 @@ normalise xs =
let ord = sort [(s, (h, notTer h)) | (h, s) <- xs]
(hgvs, y) = unzip $ map snd ord
y' = pava y
- in M.fromList . zip hgvs . map pure <$> puCorrection hgvs y'
+ in M.fromList . zip hgvs . map pure <$> puCorrection y y'
notTer str = if (T.reverse . T.take 3 $ T.reverse str) == "Ter" then 0 else 1 :: Double
@@ -89,10 +89,9 @@ weightedMean w0 w1 xs =
n0 = fromIntegral (length xs) - n1
in w1 * n1 / (w1 * n1 + w0 * n0)
-puCorrection hgvs ys =
- let lab = map notTer hgvs
- in M.fromListWith (++) (zip lab $ map pure ys) ^. at 0 <&> \nonsc ->
- let cf = 1 - mean nonsc -- NB: reversed due to dms score being lower when Ter
- w0 = 2 / cf
- w1 = 1 / mean lab
- in pava' (weightedMean w0 w1) lab
+puCorrection lab ys =
+ M.fromListWith (++) (zip lab $ map pure ys) ^. at 0 <&> \nonsc ->
+ let cf = 1 - mean nonsc -- NB: reversed due to dms score being lower when Ter
+ w0 = 2 / cf
+ w1 = 1 / mean lab
+ in pava' (weightedMean w0 w1) lab