Created
September 5, 2014 04:38
-
-
Save jmuhlich/cf71ba9f44edc3ad0ebf to your computer and use it in GitHub Desktop.
Parametrizing perturbagen dose-response relationships
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import String | |
import Array | |
import Graphics.Input (Input, input) | |
import Graphics.Input.Field as Field | |
logistic : Float -> Float -> Float -> Float -> Float -> Float | |
logistic x emin emax mid slope = | |
( (emin-emax) / (1 + ((x/mid)^slope) ) ) + emax | |
lcurve : Float -> Float -> Float -> Path | |
lcurve emax mid slope = | |
let | |
is = [0..100] | |
xs = map (\n -> (n/10-5)) is | |
lfunc = (\x -> (logistic (10^x) 1 emax mid slope) * 100) | |
in | |
path (zip is (map lfunc xs)) | |
emax = input Field.noContent | |
mid = input Field.noContent | |
slope = input Field.noContent | |
main : Signal Element | |
main = lift3 scene emax.signal mid.signal slope.signal | |
scene : Field.Content -> Field.Content -> Field.Content -> Element | |
scene emaxContent midContent slopeContent = | |
flow down | |
[ plainText "e_max:" | |
, Field.field Field.defaultStyle emax.handle id "0" emaxContent | |
, plainText "mid:" | |
, Field.field Field.defaultStyle mid.handle id "1" midContent | |
, plainText "slope:" | |
, Field.field Field.defaultStyle slope.handle id "1" slopeContent | |
, collage 400 400 | |
[ traced (solid red) | |
(lcurve | |
(maybe 0 id (String.toFloat emaxContent.string)) | |
(maybe 1 id (String.toFloat midContent.string)) | |
(maybe 1 id (String.toFloat slopeContent.string)) | |
) | |
, move (50, 50) (outlined (dotted blue) (square 100)) | |
] | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment