Commit 625c0855 authored by Philippe Veber's avatar Philippe Veber

Run: report for multinomial

parent b2a45e9a
......@@ -56,7 +56,7 @@ open File_formats
module New_API = struct
type t = {
tree : nhx file ;
nucleotide_alignments : nucleotide_fasta file list ;
nucleotide_alignments : (string * nucleotide_fasta file) list ;
convergent_species : string list workflow ;
}
......@@ -107,14 +107,20 @@ module New_API = struct
module Query = struct
type dataset = t
type t = dataset * nucleotide_fasta file
type t = {
dataset : dataset ;
alignment_descr : string ;
alignment : nucleotide_fasta file ;
}
let nucleotide_alignment = snd
let nucleotide_alignment q = q.alignment
let tree ~branch_length_unit:_ (d, fa) =
clip_tree_on_alignment d.tree fa
let tree ~branch_length_unit:_ q =
clip_tree_on_alignment q.dataset.tree q.alignment
end
let queries d =
List.map d.nucleotide_alignments ~f:(fun al -> d, al)
let queries dataset =
List.map dataset.nucleotide_alignments ~f:(fun (alignment_descr, alignment) ->
{ Query.dataset ; alignment_descr ; alignment }
)
end
......@@ -2,6 +2,31 @@ open Core
open Bistro
open Bistro_utils
let candidate_site_report sites =
let f = fun%workflow dest ->
let module N = Codepitk.Note in
let module DF = Codepitk.Dataframe in
let module CS = Codepitk.Candidate_site in
let sites = Array.of_list [%eval sites] in
let df =
DF.make [
"Alignment ID", DF.String_opts (Array.map sites ~f:(fun s -> s.CS.alignment_id)) ;
"Position", DF.Int_opts (Array.map sites ~f:(fun s -> s.CS.pos)) ;
"Score", DF.Float_opts (Array.map sites ~f:(fun s -> s.CS.score)) ;
]
|> Rresult.R.failwith_error_msg
in
let index = N.make ~title:"Candidate sites" N.[
dataframe df ;
]
in
let path fn = Filename.concat dest fn in
Unix.mkdir_p dest ;
N.to_html index (path "index.html")
|> Rresult.R.failwith_error_msg
in
Workflow.path_plugin ~descr:"codepi.run.candidate_site_report" f
module Dataset = Dataset.New_API
type t = {
......@@ -21,19 +46,29 @@ let dataset run =
Sys.readdir run.alignment_dir
|> Array.to_list
|> List.map ~f:(fun ali ->
ali,
Workflow.input (Filename.concat run.alignment_dir ali)
)
in
let convergent_species = convergent_species_workflow run in
{ Dataset.tree ; nucleotide_alignments ; convergent_species }
Dataset.make ~tree ~nucleotide_alignments ~convergent_species
module Pipeline = Detection_pipeline.Make(Dataset.Query)
let repo run =
let d = dataset run in
let q = d, List.hd_exn d.nucleotide_alignments in
let q = List.hd_exn (Dataset.queries d) in
let multinomial_ranking =
Pipeline.ranking
~query_descr:(fun q -> Some q.Dataset.Query.alignment_descr)
~meth:Pipeline.multinomial_asymptotic_lrt
~column_label:"Multinomial_1mp"
~convergent_species:d.convergent_species
(Dataset.queries d)
in
Repo.[
item ["multinomial.cpt"] (Pipeline.multinomial_asymptotic_lrt q) ;
item ["multinomial_report"] (candidate_site_report multinomial_ranking) ;
]
let main
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment