@@ -16,13 +16,11 @@ open FSharp.Plotly.StyleParam
1616let header = [ " <b>RowIndex</b>" ; " A" ; " simple" ; " table" ]
1717let rows =
1818 [
19- [ " 0" ; " I" ; " am" ; " a" ]
19+ [ " 0" ; " I" ; " am" ; " a" ]
2020 [ " 1" ; " little" ; " example" ; " !" ]
2121 ]
2222
23- let table1 =
24- Chart.Table( header, rows)
25-
23+ let table1 = Chart.Table( header, rows)
2624
2725
2826(* **do-not-eval***)
@@ -39,29 +37,29 @@ let table2 =
3937 header,
4038 rows,
4139 //sets global header alignment
42- AlignHeader= [ HorizontalAlign.Center],
40+ AlignHeader = [ HorizontalAlign.Center],
4341 //sets alignment for each column separately
4442 //(The last alignment is applied to all potential following columns)
45- AlignCells= [ HorizontalAlign.Left; HorizontalAlign.Center; HorizontalAlign.Right],
43+ AlignCells = [ HorizontalAlign.Left; HorizontalAlign.Center; HorizontalAlign.Right],
4644 //sets global header color
47- ColorHeader= " #45546a" ,
48- //sets specific header color to each header column
45+ ColorHeader = " #45546a" ,
46+ //sets specific color to each header column
4947 //ColorHeader=["#45546a";"#deebf7";"#45546a";"#deebf7"],
5048 //sets global cell color
51- //ColorRows= "#deebf7",
49+ //ColorRows = "#deebf7",
5250 //sets cell column colors
53- ColorCells= [" #deebf7" ; " lightgrey" ; " #deebf7" ; " lightgrey" ],
51+ ColorCells = [ " #deebf7" ; " lightgrey" ; " #deebf7" ; " lightgrey" ],
5452 //sets cell row colors
5553 //ColorCells=[["#deebf7";"lightgrey"]],
5654 //sets font of header
57- FontHeader= Font.init( FontFamily.Courier_ New, Size= 12 , Color= " white" ),
55+ FontHeader = Font.init( FontFamily.Courier_ New, Size= 12 , Color= " white" ),
5856 //sets the height of the header
5957 HeightHeader= 30. ,
6058 //sets lines of header
61- LineHeader= Line.init( 2. , " black" ),
62- ColumnWidth= [70 ; 50 ; 100 ; 70 ],
59+ LineHeader = Line.init( 2. , " black" ),
60+ ColumnWidth = [ 70 ; 50 ; 100 ; 70 ],
6361 //defines order of columns
64- ColumnOrder= [ 1 ; 2 ; 3 ; 4 ]
62+ ColumnOrder = [ 1 ; 2 ; 3 ; 4 ]
6563 )
6664
6765(* **do-not-eval***)
@@ -88,11 +86,13 @@ let rowvalues =
8886
8987//map color from value to hex representation
9088let mapColor min max value =
91- let percentage = ( value - min) / ( max - min)
92- Colors.fromRgb 255 ( 255 - ( int ( 255. * percentage))) ( int ( 255. * percentage))
89+ let proportion =
90+ ( 255. * ( value - min) / ( max - min))
91+ |> int
92+ Colors.fromRgb 255 ( 255 - proportion) proportion
9393 |> Colors.toWebColor
9494
95- //assign a color to every cell seperately. Matrix must be transposed for correct orientation
95+ //Assign a color to every cell seperately. Matrix must be transposed for correct orientation.
9696let cellcolor =
9797 rowvalues
9898 |> Seq.map ( fun row ->
@@ -114,7 +114,7 @@ table3 |> Chart.Show
114114
115115
116116(**
117- Sequence representation
117+ Sequence representation:
118118
119119*)
120120
@@ -128,26 +128,26 @@ let sequence =
128128 ]
129129 |> String.concat " "
130130
131- let elementsperrow = 60
131+ let elementsPerRow = 60
132132
133133let headers =
134- [ 0 .. elementsperrow ]
134+ [ 0 .. elementsPerRow ]
135135 |> Seq.map ( fun x ->
136136 if x% 10 = 0 && x <> 0 then " |"
137137 else " "
138138 )
139139
140140let cells =
141141 sequence
142- |> Seq.chunkBySize elementsperrow
143- |> Seq.mapi ( fun i x -> Seq.append [ string ( i * elementsperrow )] ( Seq.map string x))
142+ |> Seq.chunkBySize elementsPerRow
143+ |> Seq.mapi ( fun i x -> Seq.append [ string ( i * elementsPerRow )] ( Seq.map string x))
144144
145145let cellcolors =
146146 cells
147147 |> Seq.map ( fun row ->
148148 row
149- |> Seq.map ( fun nucleotid ->
150- match nucleotid with
149+ |> Seq.map ( fun element ->
150+ match element with
151151 //colors taken from DRuMS
152152 //(http://biomodel.uah.es/en/model4/dna/atgc.htm)
153153 | " A" -> " #5050FF"
@@ -163,13 +163,21 @@ let cellcolors =
163163
164164let font = Font.init( FontFamily.Consolas, Size= 14 )
165165let line = Line.init( 0 , " white" )
166- let chartwidth = 50. + 10. * float elementsperrow
166+ let chartwidth = 50. + 10. * float elementsPerRow
167167
168168let table4 =
169169 Chart.Table(
170- headers, cells, LineCells= line, LineHeader= line, HeightCells= 20 ,
171- FontHeader= font, FontCells= font, ColumnWidth=[ 50 ; 10 ],
172- AlignCells=[ HorizontalAlign.Right; HorizontalAlign.Center], ColorCells= cellcolors)
170+ headers,
171+ cells,
172+ LineCells = line,
173+ LineHeader = line,
174+ HeightCells = 20 ,
175+ FontHeader = font,
176+ FontCells = font,
177+ ColumnWidth = [ 50 ; 10 ],
178+ AlignCells = [ HorizontalAlign.Right; HorizontalAlign.Center],
179+ ColorCells = cellcolors
180+ )
173181 |> Chart.withSize( chartwidth, nan)
174182 |> Chart.withTitle " Sequence A"
175183
0 commit comments