Skip to content

Commit

Permalink
Merge pull request #117 from zhaotianjing/master
Browse files Browse the repository at this point in the history
add error message for categorial trait
  • Loading branch information
reworkhow authored Mar 28, 2022
2 parents 1af7765 + b079bda commit af4defe
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ function categorical_censored_traits_setup!(mme,df)
thresholds_all[t] = [tmin; 0; range(1,length=ncategories[t]-1,stop=tmax)]
end
end
# check whether the categories are 1,2,3...; otherwise it will cause indexing error
category_obs_t = category_obs[:,t]
user_categories = sort(unique(category_obs_t))
correct_categories = collect(1:ncategories[t])
if user_categories != correct_categories
trait_name = mme.lhsVec[trait_index]
error("For categorical trait $trait_name, the categories should be ",correct_categories," ; instead of ",user_categories)
end
end
# update lower_bound and upper_bound
update_bounds_from_threshold!(lower_bound,upper_bound,category_obs,thresholds_all,categorical_trait_index)
Expand Down
5 changes: 4 additions & 1 deletion src/3.GWAS/src/GWAS.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,14 @@ function GWAS(mme,map_file,marker_effects_file::AbstractString...;
end

window_size_bp = map(Int64,parse(Float64,split(window_size)[1])*1_000_000)
mapfile = (header == true ? readdlm(map_file,',',header=true)[1] : readdlm(map_file,','))
mapfile = CSV.read(map_file, DataFrame, header = header, types=Dict(1 => String)) #the 1st column (markerID) must be string
#remove SNPs in mapfile that are not used in Bayesian analysis (e.g., removed in QC)
snpID = mme.M[1].markerID
in_snpID = findall(x -> x snpID, mapfile[:,1])
mapfile = mapfile[in_snpID,:]
if length(in_snpID)==0
error("Please check the 1st column of the mapfile (i.e., marker ID)")
end

chr = map(string,mapfile[:,2])
pos = map(Int64,mapfile[:,3])
Expand Down

0 comments on commit af4defe

Please sign in to comment.