Skip to content

Commit

Permalink
fix calls to _ishet
Browse files Browse the repository at this point in the history
  • Loading branch information
pdimens committed Oct 29, 2021
1 parent 09e9b79 commit b8dfe9e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/Heterozygosity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ Given a `GenoArray`, count the number of times `allele` appears in the
homozygous state.
"""
function counthom(geno::T, allele::U) where T<:GenoArray where U <: Signed
mapreduce(i -> ishom(i, allele), +, skipmissing(geno))
mapreduce(i -> _ishom(i, allele), +, skipmissing(geno))
end

function counthom(geno::T, allele::AbstractVector{U}) where T<:GenoArray where U<:Integer
tmp = skipmissing(geno)
isempty(tmp) && return fill(0, length(allele))
map(_allele -> mapreduce(i -> ishom(i, _allele), +, tmp), allele)
map(_allele -> mapreduce(i -> _ishom(i, _allele), +, tmp), allele)
end

"""
Expand Down
12 changes: 7 additions & 5 deletions src/PopGen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,19 @@ module PopGen
using Reexport
using PopGenCore
@reexport module PopGenCore
export PopData, PopDataInfo, GenoArray, Genotype, SNP, Msat, genodata, sampleinfo, locusinfo
export PopData, PopDataInfo, GenoArray, Genotype, SNP, Msat
export genodata, metadata, info
export isbiallelic, ishom, ishet
export delimited, csv, genepop, vcf, bcf, @nancycats, @gulfsharks
export sampleinfo, locusinfo, samplenames, loci
export sampleinfo, sampleinfo!, locusinfo, locusinfo!, samplenames, loci
export copy, size, sort, dropmonomorphic, dropmonomorphic!
export dropmultiallelic, dropmultiallelic!
export locations, locations!
export locationdata, locationdata!
export locidataframe, locimatrix
export genotypes, genotypes, genotype
export genotypes, genotypes
export populations, populations!
export exclude, remove, omit, exclude!, remove!, omit!, keep, keep!, filter, filter!
export exclude, remove, omit, exclude!, remove!, omit!, keep, keep!
export filter, filter!
end
@reexport import PopGenCore: read, write

Expand Down
4 changes: 2 additions & 2 deletions test/heterozygosity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ testarray = cats.genodata.genotype[1:10]
end

@testset "het obs/exp" begin
@test PopGen._hetero_obs(testarray) == 0.6
@test PopGen._hetero_obs(testarray) == 0.75
@test PopGen._hetero_exp(testarray) == 0.6015625
end

Expand All @@ -43,7 +43,7 @@ testarray = cats.genodata.genotype[1:10]
tmp = heterozygosity(cats, by = "population")
@test tmp isa DataFrame
@test size(tmp) == (17,4)
@test samplehet(cats, "N215") == 1/3
@test samplehet(cats, "N215") == 3/8
@test_throws ArgumentError samplehet(cats, "M115")
end
end
Expand Down

0 comments on commit b8dfe9e

Please sign in to comment.