Skip to content

Commit

Permalink
add q value test
Browse files Browse the repository at this point in the history
  • Loading branch information
bvenn committed Jan 18, 2022
1 parent b62743d commit 7ba8c4a
Show file tree
Hide file tree
Showing 3 changed files with 23,918 additions and 10 deletions.
1 change: 1 addition & 0 deletions tests/FSharp.Stats.Tests/FSharp.Stats.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<ItemGroup>
<EmbeddedResource Include="data/benjaminiHochberg_Input.csv" CopyToOutputDirectory="PreserveNewest"/>
<EmbeddedResource Include="data/benjaminiHochberg_AdjustedWithR.csv" CopyToOutputDirectory="PreserveNewest"/>
<EmbeddedResource Include="data/qvaluesWithR.csv" CopyToOutputDirectory="PreserveNewest"/>
</ItemGroup>

<ItemGroup />
Expand Down
42 changes: 32 additions & 10 deletions tests/FSharp.Stats.Tests/Testing.fs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ let readEmbeddedRessource (name:string) =

| _ -> failwithf "could not embedded ressources, check package integrity"

let readCsv path =
readEmbeddedRessource path
|> fun s -> s.Split("\r\n")
|> Array.skip 1
|> Array.map (fun x ->
x.Split(", ") |> fun ([|a;b|]) -> a, float b
)

[<Tests>]
let testPostHocTests =
Expand Down Expand Up @@ -283,22 +290,13 @@ let pearsonTests =
[<Tests>]
let benjaminiHochbergTests =

let readCsv path =
readEmbeddedRessource path
|> fun s -> s.Split("\r\n")
|> Array.skip 1
|> Array.map (fun x ->
printfn "%s" x
x.Split(", ") |> fun ([|a;b|]) -> a, float b
)

let largeSetWithIds = readCsv @"benjaminiHochberg_Input.csv"
let largeSet = largeSetWithIds |> Array.map snd

let largeSetWithIds_Expected = readCsv @"benjaminiHochberg_AdjustedWithR.csv"
let largeSet_Expected = largeSetWithIds_Expected |> Array.map snd

testList "Testing.PValueAdjust.BenjaminiHochberg" [
testList "Testing.MultipleTesting.BenjaminiHochberg" [

testCase "testBHLarge" (fun () ->
Expect.sequenceEqual
Expand Down Expand Up @@ -347,4 +345,28 @@ let benjaminiHochbergTests =
"adjusted pValues with keys should be equal to the reference implementation, ignoring nan."
)

]



[<Tests>]
let qValuesTest =

let largeSetWithIds = readCsv @"benjaminiHochberg_Input.csv"
let largeSet = largeSetWithIds |> Array.map snd

let largeSetWithIds_Expected = readCsv @"benjaminiHochberg_AdjustedWithR.csv"//@"qvaluesWithR.csv"
let largeSet_Expected = largeSetWithIds_Expected |> Array.map snd

testList "Testing.MultipleTesting.Qvalues" [

testCase "ofPValuesBy" (fun () ->
let pi0 = 0.48345
Expect.sequenceEqual
(largeSet |> MultipleTesting.Qvalues.ofPValuesBy pi0 id |> Seq.map (fun x -> Math.Round(x,9)))
(largeSet_Expected |> Seq.map (fun x -> Math.Round(x,9)))
"qValues should be equal to the reference implementation."
)


]
Loading

0 comments on commit 7ba8c4a

Please sign in to comment.