Skip to content

Commit

Permalink
memory efficiency
Browse files Browse the repository at this point in the history
  • Loading branch information
biona001 committed Nov 1, 2024
1 parent 64dd82d commit 5009398
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/make_hdf5.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ function estimate_sigma(X::AbstractMatrix, C::AbstractMatrix;

# pan-ukb routine
Xc = StatsBase.zscore(X, mean(X, dims=1), std(X, dims=1))
Mc = size(C, 2) > 1 ? I - C * inv(Symmetric(C' * C)) * C' : Diagonal(ones(n))
Xadj = Mc * Xc
Sigma = Xadj' * Xadj / n
if size(C, 2) > 1
Xc .-= C * inv(Symmetric(C' * C)) * (C' * Xc)
end
Sigma = Xc' * Xc / n

# numerical stability
if enforce_psd
Expand Down

0 comments on commit 5009398

Please sign in to comment.