reworkhow / JWAS.jl

Julia for Whole-genome Analysis Software
http://QTL.rocks
GNU General Public License v2.0
96 stars 44 forks source link

mkmat_incidence_factor #138

Closed zhaotianjing closed 1 year ago

zhaotianjing commented 1 year ago

old:

get an incidence matrix Z to reorder uID to yID by yID = Z*uID

function mkmat_incidence_factor(yID,uID) Z = spzeros(length(yID),length(uID))

uIDdict = Dict()
for (index,id) in enumerate(uID)
    uIDdict[id]=index
end

rowi = 1
for id in yID
    if haskey(uIDdict,id)
        index = uIDdict[id]
    else
        error(id, " is not found!")
    end
    Z[rowi,index]=1
    rowi = rowi+1
end
return Z

end