Skip to content

Commit

Permalink
Merge pull request #50 from Durbadal0/main
Browse files Browse the repository at this point in the history
Updated export functions
  • Loading branch information
GregFa authored Aug 2, 2024
2 parents 3c83aaa + 51a2712 commit 2836217
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
13 changes: 8 additions & 5 deletions src/io/export_to_type.jl
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,11 @@ function get_geno(filename::String)
val = [Matrix{Int}(undef, length(samples), length(marker[i])) for i in 1:length(chr)]
for i in 1:length(chr)
for j in 1:length(marker[i])
uni = unique(Vector(df_geno[findfirst(x -> x == marker[i][j], marker[i]), 2:end]))
map = Dict(uni[1] => 1, uni[2] => 2, uni[3] => 0)
val[i][:, j]=[map[v] for v in Vector(df_geno[findfirst(x -> x == marker[j], marker), 2:end])]
#uni = unique(Vector(df_geno[findfirst(x -> x == marker[i][j], marker[i]), 2:end]))
#map = Dict(uni[1] => 1, uni[2] => 2, uni[3] => 0)
map=get_genotype(filename).label

val[i][:, j]=[map[v] for v in Vector(df_geno[findfirst(x -> x == marker[i][j], marker[i]), 2:end])]
end

end
Expand Down Expand Up @@ -339,8 +341,9 @@ function get_chromosome(gmapfile::String, genofile::String, number::Int)
# values
val = Matrix{Int}(undef, length(samples), length(marker))
for j in 1:length(marker)
uni = unique(Vector(df_geno[findfirst(x -> x == marker[j], marker), 2:end]))
map = Dict(uni[1] => 1, uni[2] => 2, uni[3] => 0)
#uni = unique(Vector(df_geno[findfirst(x -> x == marker[j], marker), 2:end]))
#map = Dict(uni[1] => 1, uni[2] => 2, uni[3] => 0)
map=get_genotype(filename).label
val[:, j]=[map[v] for v in Vector(df_geno[findfirst(x -> x == marker[j], marker), 2:end])]
end

Expand Down
6 changes: 3 additions & 3 deletions test/datastruc_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Generate Data for testing #
#############################


#=
gmap = Gmap(["chr1", "chr2"], [["m1", "m2"], ["m3"]], [[1.0, 2.0], [3.0]])
cross_info = CrossInfo(["sample1", "sample2"], [1, 0])
cross_type = CrossType("risib")
Expand All @@ -18,8 +18,8 @@ geno = Geno(
GenoType(Dict("A" => 1)),
GenoTranspose(false)
)

pheno = Pheno(["individual1", "individual2"], ["trait1", "trait2"], [1.0 2.0; nothing 3.0])
=#
#pheno = Pheno(["individual1", "individual2"], ["trait1", "trait2"], [1.0 2.0; nothing 3.0])


# Testing the Gmap type
Expand Down

0 comments on commit 2836217

Please sign in to comment.