-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
function _onehot_biallelic(data::PopData) | ||
data.metadata.biallelic == false && throw(ArgumentError("Data must be biallelic. If practical to do so, use dropmultiallelic() to remove non-biallelic loci")) | ||
gmtx = locimatrix(data) | ||
mapreduce(hcat, eachcol(gmtx)) do locus | ||
alle = uniquebialleles(locus) | ||
d = Dict{Union{Missing, NTuple{2, eltype(alle)}}, Int8}( | ||
(alle[1], alle[1]) => Int8(0), | ||
(alle[1], alle[2]) => Int8(1), | ||
(alle[2], alle[2]) => Int8(2), | ||
missing => Int8(-1) | ||
) | ||
Int8[d[i] for i in locus] | ||
end | ||
end | ||
|
||
function randomforest(data::PopData) | ||
missing ∈ data.genodata.genotype && throw(error("Unfortunately, random forest analysis cannot work with missing data. You may try to filter out loci and/or samples with missing data or use a genotype inputation method (e.g. fastPhase, BEAGLE).")) | ||
input = _onehot_biallelic(data) | ||
|
||
|
||
end |
a2beea7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register()
a2beea7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/65281
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: