Skip to content

Commit 3191860

Browse files
committed
rename convert_gt to convert_bgen_gt
1 parent 56b775a commit 3191860

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/wrapper.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ function cross_validate(
327327
end
328328

329329
"""
330-
convert_gt(t::Type{T}, b::Bgen)
330+
convert_bgen_gt(t::Type{T}, b::Bgen)
331331
332332
Imports BGEN genotypes and chr/sampleID/pos/snpID/ref/alt into numeric arrays.
333333
Genotypes are centered and scaled to mean 0 variance 1. Missing genotypes will
@@ -340,7 +340,7 @@ be replaced with the mean. Assumes every variant is biallelic (ie only 1 alt all
340340
# Output
341341
- `G`: matrix of genotypes with type `T`.
342342
"""
343-
function convert_gt(t::Type{T}, b::Bgen) where T <: Real
343+
function convert_bgen_gt(t::Type{T}, b::Bgen) where T <: Real
344344
n = n_samples(b)
345345
p = n_variants(b)
346346

@@ -428,7 +428,7 @@ will be stored in double precision matrices (64 bit per entry).
428428
"""
429429
function parse_genotypes(tgtfile::AbstractString, dosage=false)
430430
if (endswith(tgtfile, ".vcf") || endswith(tgtfile, ".vcf.gz"))
431-
f = dosage ? VCFTools.convert_ds : VCFTools.convert_gt
431+
f = dosage ? convert_ds : convert_gt
432432
X, X_sampleID, X_chr, X_pos, X_ids, X_ref, X_alt =
433433
f(Float64, tgtfile, trans=false,
434434
save_snp_info=true, msg = "Importing from VCF file...")
@@ -443,7 +443,7 @@ function parse_genotypes(tgtfile::AbstractString, dosage=false)
443443
tgtfile[1:end-5] * ".sample" : nothing
444444
indexfile = isfile(tgtfile * ".bgi") ? tgtfile * ".bgi" : nothing
445445
bgen = Bgen(tgtfile; sample_path=samplefile, idx_path=indexfile)
446-
X, X_sampleID, X_chr, X_pos, X_ids, X_ref, X_alt = MendelIHT.convert_gt(Float64, bgen)
446+
X, X_sampleID, X_chr, X_pos, X_ids, X_ref, X_alt = MendelIHT.convert_bgen_gt(Float64, bgen)
447447
elseif isplink(tgtfile)
448448
dosage && error("PLINK files detected but dosage = true!")
449449
X = SnpArrays.SnpData(tgtfile)

test/wrapper_test.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ end
173173
rm("cviht.summary.txt", force=true)
174174
rm("iht.summary.txt", force=true)
175175
rm("iht.beta.txt", force=true)
176+
rm("iht.cov.txt", force=true)
176177
catch
177178
println("Unsuccessful deletion of intermediate files generated in" *
178179
" unit tests! Windows users can remove these files manually " *
@@ -183,14 +184,14 @@ end
183184
@testset "read BGEN and VCF" begin
184185
cd(normpath(MendelIHT.datadir()))
185186
xtrue = convert(Matrix{Float64}, SnpArray("normal.bed"), center=true, scale=true, impute=true)
186-
@time xbgen, _ = MendelIHT.convert_gt(Float64, Bgen("normal.bgen"))
187+
@time xbgen, _ = MendelIHT.convert_bgen_gt(Float64, Bgen("normal.bgen"))
187188
@test all(xbgen .≈ xtrue)
188189
# BGEN wrapper
189190
@time xbgen, X_sampleID, X_chr, X_pos, X_ids, X_ref, X_alt = MendelIHT.parse_genotypes("normal.bgen")
190191
@test all(xbgen .≈ xtrue)
191192
# VCF wrapper
192-
@time xbgen, X_sampleID, X_chr, X_pos, X_ids, X_ref, X_alt = MendelIHT.parse_genotypes("normal.vcf.gz")
193-
@test all(xbgen .≈ xtrue)
193+
@time xvcf, X_sampleID, X_chr, X_pos, X_ids, X_ref, X_alt = MendelIHT.parse_genotypes("normal.vcf.gz")
194+
@test all(xvcf .≈ xtrue)
194195
# Run IHT on wrapper
195196
result_plink = iht("normal", 10, Normal, phenotypes="phenotypes.txt", verbose=true)
196197
result_vcf = iht("normal.vcf.gz", 10, Normal, phenotypes="phenotypes.txt", verbose=true)

0 commit comments

Comments
 (0)