Skip to content

Commit 6cfcad4

Browse files
committed
Update to FSharp.Stats 0.6.0, fix phylogenetic tree generation
1 parent a03c83f commit 6cfcad4

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

src/BioFSharp.Stats/BioFSharp.Stats.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
<ItemGroup>
1616
<PackageReference Include="BioFSharp" Version="2.0.0-preview.3" />
17-
<PackageReference Include="FSharp.Stats" Version="0.4.11" />
17+
<PackageReference Include="FSharp.Stats" Version="0.6.0" />
1818
</ItemGroup>
1919

2020
</Project>

src/BioFSharp.Stats/PhylTree.fs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
open BioFSharp
44
open FSharp.Stats.ML.Unsupervised
5+
open Priority_Queue
56

67
module PhylTree =
78

@@ -26,20 +27,27 @@ module PhylTree =
2627
/// <parameter name="distanceFunction">a function that determines the distance between two sequences e.g. evolutionary distance based on a substitution model</parameter>
2728
/// <parameter name="linker">the linker function to join clusters with</parameter>
2829
/// <parameter name="sequences">the input TaggedSequences</parameter>
29-
let ofTaggedSequencesWithLinker (branchTag:'T) (distanceConverter: float -> 'Distance) (distanceFunction: seq<'S> -> seq<'S> -> float) linker (sequences: seq<TaggedSequence<'T,'S>>) =
30-
sequences
31-
|> HierarchicalClustering.generate
32-
(fun a b -> distanceFunction a.Sequence b.Sequence)
33-
linker
34-
|> ofHierarchicalCluster (TaggedSequence.create branchTag Seq.empty) distanceConverter
30+
let ofTaggedSequencesWithLinker (branchTag:'T) (distanceConverter: float -> 'Distance) (distanceFunction: seq<'S> -> seq<'S> -> float) linker (sequences: TaggedSequence<'T,'S> array) =
31+
let dist = (fun (a: TaggedSequence<'T,'S>) (b: TaggedSequence<'T,'S>) -> distanceFunction a.Sequence b.Sequence)
32+
let clustering =
33+
HierarchicalClustering.generate<TaggedSequence<'T,'S>>
34+
dist
35+
linker
36+
sequences
37+
|> Seq.item 0
38+
|> (fun x -> x.Key)
39+
clustering
40+
|> ofHierarchicalCluster
41+
(TaggedSequence.create branchTag Seq.empty<'S>)
42+
distanceConverter
3543

3644

3745
/// <summary>
3846
/// Performs hierarchical clustering of the input TaggedSequences using the provided distance function. Returns the result as a Phylogenetic tree.</summary>
3947
/// </summary>
4048
/// <parameter name="distanceFunction">a function that determines the distance between two sequences e.g. evolutionary distance based on a substitution model</parameter>
4149
/// <parameter name="sequences">the input TaggedSequences</parameter>
42-
let ofTaggedBioSequences (distanceFunction: seq<#IBioItem> -> seq<#IBioItem> -> float) (sequences: seq<TaggedSequence<string,#IBioItem>>) : PhylogeneticTree<TaggedSequence<string,#IBioItem>*float>=
50+
let ofTaggedBioSequences (distanceFunction: seq<#IBioItem> -> seq<#IBioItem> -> float) (sequences: TaggedSequence<string,#IBioItem> array) : PhylogeneticTree<TaggedSequence<string,#IBioItem>*float> =
4351
sequences
4452
|> ofTaggedSequencesWithLinker
4553
"Ancestor"

0 commit comments

Comments
 (0)