diff --git a/README.md b/README.md index 4312324..8094d93 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,15 @@ let SaRes = ![](./docs/img/cpTimeCourse.png) + - `TMEA.Plots.SurprisalAnalysis.plotPotentialHeatmap` is a more visually pleasing version of above plot (it omits the baseline state per default): + + ```F# + SaRes + |> TMEA.Plots.SurprisalAnalysis.plotPotentialHeatmap true + ``` + + ![](./docs/img/cpHeatmap.png) + - `Plots.SurprisalAnalysis.plotFreeEnergyLandscape` plots the free energy landscape of the given surprisal analysis result: ``` diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 294198e..2e281d9 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,3 +1,6 @@ +#### 0.0.3-alpha - Friday, September 4, 2020 (WIP) +- added Surprisal Analysis cp Heatmap Plot + #### 0.0.2-alpha - Wednesday, September 2, 2020 - added Plot functions for Surprisal Analysis results. - fixed Authors of the nuget package diff --git a/TMEA.sln b/TMEA.sln index 93c1a55..290cf1b 100644 --- a/TMEA.sln +++ b/TMEA.sln @@ -8,8 +8,10 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{B543D949-2FB1-4745-9FBF-703B61558E8E}" ProjectSection(SolutionItems) = preProject build.fsx = build.fsx + .config\dotnet-tools.json = .config\dotnet-tools.json fake.cmd = fake.cmd fake.sh = fake.sh + global.json = global.json paket.dependencies = paket.dependencies EndProjectSection EndProject @@ -20,6 +22,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Github", "Github", "{30F2F4 README.md = README.md EndProjectSection EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Project", "Project", "{55D52760-ACF5-47D0-81DF-BEABF78443CC}" + ProjectSection(SolutionItems) = preProject + LICENSE = LICENSE + README.md = README.md + RELEASE_NOTES.md = RELEASE_NOTES.md + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/docs/img/cpHeatmap.png b/docs/img/cpHeatmap.png new file mode 100644 index 0000000..ad32d1c Binary files /dev/null and b/docs/img/cpHeatmap.png differ diff --git a/src/TMEA/Playground.fsx b/src/TMEA/Playground.fsx index 8932989..ecd4f78 100644 --- a/src/TMEA/Playground.fsx +++ b/src/TMEA/Playground.fsx @@ -20,8 +20,6 @@ open FSharpAux #load "Frames.fs" #load "Plots.fs" - - open TMEA.IO open TMEA.SurprisalAnalysis open TMEA.MonteCarlo @@ -152,6 +150,9 @@ open FSharp.Plotly SaRes |> TMEA.Plots.SurprisalAnalysis.plotConstraintTimecourses true +SaRes +|> TMEA.Plots.SurprisalAnalysis.plotPotentialHeatmap true + SaRes |> TMEA.Plots.SurprisalAnalysis.plotFreeEnergyLandscape true data diff --git a/src/TMEA/Plots.fs b/src/TMEA/Plots.fs index 781cb89..a9a6778 100644 --- a/src/TMEA/Plots.fs +++ b/src/TMEA/Plots.fs @@ -9,6 +9,12 @@ module Plots = module Presets = + let colorscale = StyleParam.Colorscale.Custom([ + 0.,"SteelBlue"; + 0.45,"LavenderBlush"; + 1.,"Salmon" + ]) + let standardConfig = Config.init ( Responsive = true, @@ -80,7 +86,7 @@ module Plots = |> Chart.withConfig Presets.standardConfig else c - |> Chart.withX_AxisStyle "TP" + |> Chart.withX_AxisStyle "TimePoint" |> Chart.withY_AxisStyle "Free Energy / kbT" |> Chart.withTitle "Free Energy Landscape" @@ -89,3 +95,36 @@ module Plots = generateFreeEnergyLandscapePlot useStylePreset data saRes |> Chart.Show + + let generatePotentialHeatmap (useStylePreset:bool) (saRes:SurprisalAnalysis.SAResult) = + saRes.Potentials + |> Matrix.toArray2D + |> JaggedArray.ofArray2D + |> Array.tail + |> Array.rev + |> JaggedArray.map (fun x -> x*10.) + |> fun potentials -> + Chart.Heatmap( + potentials, + ColNames=[0 .. potentials.Length-1], + RowNames = ([1..potentials.Length-1] |> List.map (sprintf "Constraint_%i") |> List.rev), + Ygap=10, + Colorscale= Presets.colorscale,zSmooth=StyleParam.SmoothAlg.Best + ) + |> Chart.withColorBar (Colorbar.init(Title="Constraint Potential")) + |> Chart.withTitle("PotentialTimeCourse") + |> fun c -> + if useStylePreset then + c + |> Presets.applyPresetStyle "Time point" "Constraint index" + |> Chart.withSize (1500.,1000.) + |> Chart.withMargin (Margin.init(Left=100)) + |> Chart.withConfig Presets.standardConfig + else + c + + + + let plotPotentialHeatmap (useStylePreset:bool) (saRes:SurprisalAnalysis.SAResult) = + generatePotentialHeatmap useStylePreset saRes + |> Chart.Show \ No newline at end of file