Skip to content

Commit

Permalink
#1 : Add CP Heatmap Plot
Browse files Browse the repository at this point in the history
  • Loading branch information
kMutagene committed Sep 4, 2020
1 parent 9fc3ed0 commit 1be3084
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 3 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
```
Expand Down
3 changes: 3 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 9 additions & 0 deletions TMEA.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Binary file added docs/img/cpHeatmap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions src/TMEA/Playground.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ open FSharpAux
#load "Frames.fs"
#load "Plots.fs"



open TMEA.IO
open TMEA.SurprisalAnalysis
open TMEA.MonteCarlo
Expand Down Expand Up @@ -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

Expand Down
41 changes: 40 additions & 1 deletion src/TMEA/Plots.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 / k<sub>b</sub>T"
|> Chart.withTitle "Free Energy Landscape"

Expand All @@ -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

0 comments on commit 1be3084

Please sign in to comment.