Skip to content

Commit

Permalink
Merge pull request #244 from zieglerSe/developer
Browse files Browse the repository at this point in the history
Closes #243
  • Loading branch information
bvenn authored Feb 6, 2023
2 parents e7b81c1 + fb7316e commit 7113076
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/FSharp.Stats/Testing/SAM.fs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,15 @@ module SAM =
QValue : float
/// foldchange from condition to control
Foldchange : float
} with static member Create id ri si stats qv fc= {ID=id; Ri=ri; Si=si; Statistics=stats; QValue = qv;Foldchange = fc}
/// mean condition A
MeanA : float
/// standard deviation condition A
StDevA : float
/// mean condition B
MeanB : float
/// standard deviation condition B
StDevB : float
} with static member Create id ri si stats qv fc ma stdA mb stdB = {ID=id; Ri=ri; Si=si; Statistics=stats; QValue = qv;Foldchange = fc; MeanA = ma; StDevA = stdA;MeanB = mb; StDevB = stdB }


// Result after calculating SAM
Expand Down Expand Up @@ -128,6 +136,8 @@ module SAM =
// get average of one sample
let ma,mb = Array.average dataA,Array.average dataB
let fc = mb/ma
let stDevA = Seq.stDev dataA
let stDevB = Seq.stDev dataB
let ri = (fun x y -> x - y) mb ma
let si =
// length of arrays
Expand All @@ -148,7 +158,7 @@ module SAM =
let statistic = ri / (si + s0)


SAM.Create idOfBioitem ri si statistic nan fc
SAM.Create idOfBioitem ri si statistic nan fc ma stDevA mb stDevB

Array.map2 (fun a b -> calcStats a b) dataA dataB

Expand Down Expand Up @@ -243,7 +253,7 @@ module SAM =
shuffleTemplate
|> Array.map (fun si -> row.[si])
|> fun x ->
(id,x.[..replicateCount1-1]),(id,x.[replicateCount2..])
(id,x.[..replicateCount1-1]),(id,x.[replicateCount1..])
)
|> Array.unzip

Expand All @@ -261,7 +271,7 @@ module SAM =
|> JaggedArray.transpose
|> Array.map (fun tt ->
let (id',ri',si',di') = tt |> Array.fold (fun (id,ri,si,di) t -> t.ID,ri+t.Ri,si+t.Si,di + t.Statistics) ("",0.,0.,0.)
SAM.Create id' (ri' / float iterations) (si' / float iterations) (di' / float iterations) nan nan
SAM.Create id' (ri' / float iterations) (si' / float iterations) (di' / float iterations) nan nan nan nan nan nan
)

expAvgStats
Expand Down

0 comments on commit 7113076

Please sign in to comment.