PageRenderTime 55ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/genomics/sequencing/exome/analyses/candidate-snps.clj

https://github.com/jandot/bavs
Clojure | 49 lines | 44 code | 4 blank | 1 comment | 3 complexity | 6a0438f706e19075ef6a2f74795dff46 MD5 | raw file
  1. (require '[exome core])
  2. (in-ns 'exome.core)
  3. (defn in-any-candidate-gene?
  4. [snp gene-list]
  5. (contains? (set gene-list) (:gene snp)))
  6. (defn overview-causative-snps
  7. [ind]
  8. (let [vnnlh (variants-nsssi-novel-lof-highqual ind)
  9. vnnlh-for-homnonref (filter #(homnonref? % ind) vnnlh)
  10. genes-w-homnonref (map #(:gene %) vnnlh-for-homnonref)
  11. g-homnonref genes-w-homnonref
  12. causative-snps-homnonref
  13. (reduce conj []
  14. (map #(assoc {}
  15. :group "homnonref"
  16. :gene (:gene %)
  17. :locus (:locus %)
  18. :vartype (:vartype %)
  19. :consequence (:consequence %))
  20. (filter #(in-any-candidate-gene? % g-homnonref) vnnlh-for-homnonref)))
  21. vnnlh-for-het (filter #(het? % ind) vnnlh)
  22. genes-w-hets (map #(:gene %) (filter #(het? % ind) vnnlh))
  23. m-het (group-by (set genes-w-hets) genes-w-hets)
  24. c-het (zipmap (keys m-het) (map #(count %) (vals m-het)))
  25. g-het (keys (filter #(> (val %) 1) c-het))
  26. causative-snps-comphet
  27. (reduce conj []
  28. (map #(assoc {}
  29. :group "comphet"
  30. :gene (:gene %)
  31. :locus (:locus %)
  32. :vartype (:vartype %)
  33. :consequence (:consequence %))
  34. (filter #(in-any-candidate-gene? % g-het) vnnlh-for-het)))]
  35. (flatten (conj causative-snps-homnonref causative-snps-comphet))))
  36. ;; diseaseA
  37. (clojure.contrib.duck-streams/with-out-writer "analyses/candidate-snps-diseaseA.txt"
  38. (doseq [ind diseaseA-individuals]
  39. (println "==========")
  40. (println ind)
  41. (doseq [gene (group-by :gene (overview-causative-snps ind))]
  42. (println "---")
  43. (println (first gene))
  44. (doseq [snp (sort-by :gene (second gene))]
  45. (println (clojure.string/join "\t" ["" (:group snp) (:vartype snp) (:locus snp) (:consequence snp)]))))))