Skip to content

Commit

Permalink
support ghostbasil on custom LD data (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
biona001 committed Jun 25, 2024
1 parent 779b855 commit 162fdcc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/ghostbasil_parallel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ function ghostknockoffgwas(
t21, t22, t23, t24 = 0.0, 0.0, 0.0, 0.0# some timers
start_t = time()
γ_mean = 0.0 # keeps track of LD shrinkage across regions
df = DataFrame(rsid=String[], AF=Float64[], chr=Int[],
ref=String[], alt=String[], pos_hg19=Int[], pos_hg38=Int[])
headers = ["rsid", "AF", "chr", "ref", "alt", "pos_hg$(hg_build)"]
df = DataFrame([String[], Float64[], Int[], String[], String[], Int[]], headers)

# assemble knockoff results across regions
nregions, nsnps, nknockoff_snps = 0, 0, 0
Expand Down Expand Up @@ -155,7 +155,7 @@ function ghostknockoffgwas(
# save matching snps info
LD_keep_idx = indexin(shared_snps, LD_pos)
GWAS_keep_idx = indexin(shared_snps, GWAS_pos)
append!(df, Sigma_info[LD_keep_idx, :])
append!(df, @view(Sigma_info[LD_keep_idx, headers]))
if length(LD_keep_idx) == 0 || length(GWAS_keep_idx) == 0
nregions += 1
if verbose
Expand Down Expand Up @@ -294,7 +294,7 @@ function ghostknockoffgwas(
end

# sort by chr and pos
sort!(df, [:chr, :pos_hg19])
sort!(df, [:chr, Symbol("pos_hg$(hg_build)")])

# write to output
CSV.write(joinpath(outdir, outname * ".txt"), df)
Expand Down

0 comments on commit 162fdcc

Please sign in to comment.