Skip to content

Commit

Permalink
start adding rf
Browse files Browse the repository at this point in the history
  • Loading branch information
pdimens committed Jul 28, 2022
1 parent 5bb24c9 commit a2beea7
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/RandomForest.jl
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

2 comments on commit a2beea7

@pdimens
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

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:

git tag -a v0.9.0 -m "<description of version>" a2beea79737ee994d69e60bd4581849feea8afa4
git push origin v0.9.0

Please sign in to comment.