Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
VEBER Philippe
codepi
Commits
c39f81c7
Commit
c39f81c7
authored
Feb 26, 2021
by
Louis Duchemin
Browse files
In-house LMM x Gemma : fixes not positive-definite matrix
parent
23f9cbc2
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
72 additions
and
8 deletions
+72
-8
app/lmm_benchmark.ml
app/lmm_benchmark.ml
+24
-4
lib/r_console.ml
lib/r_console.ml
+22
-0
lib/r_console.mli
lib/r_console.mli
+18
-0
lib/tk/inhouse_lmm.ml
lib/tk/inhouse_lmm.ml
+8
-4
No files found.
app/lmm_benchmark.ml
View file @
c39f81c7
...
...
@@ -43,7 +43,7 @@ let orthomam_echolocation = {
Orthomam
.
tree_of_db
~
branch_length_unit
:
`Amino_acid
~
convergent_species
:
Orthomam
.
species_with_echolocation
(
Codepitk
.
Orthomam_db
.
make
"omm"
)
(
Codepitk
.
Orthomam_db
.
make
"
/home/louis/Data/
omm"
)
)
;
rooted
=
false
;
branch_scale
=
1
.
;
...
...
@@ -60,12 +60,12 @@ let meth ?(requires_rooted_tree = false) f label =
{
f
;
label
;
requires_rooted_tree
}
let
methods
=
Pipeline
.[
meth
tdg09
"tdg09"
;
meth
pcoc
"pcoc"
;
(*
meth tdg09 "tdg09" ;
meth pcoc "pcoc" ;
*)
(* meth pcoc_v2 ~col:3 "pcoc v2" ; *)
meth
(
gemma
~
lmm_test
:
`Score
~
relatedness_mode
:
`Standardized
)
"gemma"
;
meth
inhouse_lmm
"LMM"
;
meth
(
lmm_with_gemma_matrix
~
relatedness_mode
:
`
Standardiz
ed
)
"LMM_Gemma"
;
meth
(
lmm_with_gemma_matrix
~
relatedness_mode
:
`
Center
ed
)
"LMM_Gemma"
;
meth
multinomial_asymptotic_lrt
"multinomial"
;
meth
topological
"topological"
~
requires_rooted_tree
:
true
;
]
...
...
@@ -89,6 +89,7 @@ let benchmark_rds ?(seed = 42) { tree = t ; rooted ; ne_s ; branch_scale ; _ } =
let
()
=
let
open
Bistro_utils
.
Repo
in
let
datasets
=
[
besnard2009
;
rubisco
;
oneline_rodent
;
orthomam_echolocation
]
in
(* let datasets = [ besnard2009 ] in *)
let
repo
=
List
.
map
datasets
~
f
:
(
fun
d
->
item
[
d
.
label
^
".rds"
]
(
benchmark_rds
d
)
...
...
@@ -96,3 +97,22 @@ let () =
in
let
loggers
=
[
Bistro_utils
.
Console_logger
.
create
()
]
in
build_main
~
loggers
~
np
:
4
~
mem
:
(
`GB
4
)
repo
~
outdir
:
"res"
(* module Top = Bistro_utils.Toplevel_eval.Make(struct
let np = 10
let mem = 8
end)() *)
(*
let () =
let q =
Pipeline.query ~seed:42 ~tree:(NHX besnard2009.tree) ~branch_scale:1. ~ne_s:(1., 1.)
~profiles:"example/aa_fitness/263SelectedProfiles.tsv"
~n_h0:90 ~n_ha:10 ()
in
(* Gemma.calculate_relatedness_matrix
~mode:`Standardized
~genotype:(Gemma.genotype_of_fasta (Pipeline.amino_acid_alignment q))
~phenotype:(Gemma.phenotype_of_tree (Pipeline.tree ~branch_length_unit:`Amino_acid q)) *)
Pipeline.lmm_with_gemma_matrix q ~relatedness_mode:`Standardized
|> Top.path
|> print_endline *)
\ No newline at end of file
lib/r_console.ml
0 → 100644
View file @
c39f81c7
open
Core_kernel
open
Bistro
type
assignment
=
|
Path
:
string
*
_
path
workflow
->
assignment
module
type
Toplevel
=
sig
val
eval
:
'
a
workflow
->
'
a
end
let
path
var_id
w
=
Path
(
var_id
,
w
)
let
rconsole
(
module
T
:
Toplevel
)
code
assignments
=
let
paths
=
List
.
map
assignments
~
f
:
(
fun
(
Path
(
_
,
w
))
->
Workflow
.
path
w
)
|>
Workflow
.
list
|>
T
.
eval
in
print_endline
code
;
List
.
iter2_exn
assignments
paths
~
f
:
(
fun
(
Path
(
var_id
,
_
))
path
->
Printf
.
printf
"%s <- '%s'
\n
"
var_id
path
)
lib/r_console.mli
0 → 100644
View file @
c39f81c7
open
Bistro
type
assignment
module
type
Toplevel
=
sig
val
eval
:
'
a
workflow
->
'
a
end
val
path
:
string
->
_
path
workflow
->
assignment
val
rconsole
:
(
module
Toplevel
)
->
string
->
assignment
list
->
unit
lib/tk/inhouse_lmm.ml
View file @
c39f81c7
...
...
@@ -109,8 +109,8 @@ let phenotypes_of_tree t =
correlation matrix, provided in sparse representation, [n] being
the dimension of the (square) matrix and [cors] the list of non-zero coefficients *)
let
transform_matrix
n
cors
=
let
sigma
()
=
matrix_of_correlations
n
cors
in
let
mat_C
=
in_place
(
L
.
potrf
~
up
:
false
)
(
sigma
()
)
in
let
sigma
=
matrix_of_correlations
n
cors
in
let
mat_C
=
in_place
(
L
.
potrf
~
up
:
false
)
sigma
in
for
i
=
1
to
L
.
Mat
.
dim1
mat_C
do
for
j
=
i
+
1
to
L
.
Mat
.
dim2
mat_C
do
mat_C
.
{
i
,
j
}
<-
0
.
...
...
@@ -123,7 +123,11 @@ let load_relatedness_matrix filename =
In_channel
.
read_lines
filename
|>
List
.
mapi
~
f
:
(
fun
i
row
->
String
.
split
row
~
on
:
'\t'
|>
List
.
mapi
~
f
:
(
fun
j
value
->
i
,
j
,
(
float_of_string
value
))
|>
List
.
mapi
~
f
:
(
fun
j
value
->
(* small addition on the diagonal to ensure eigen values are strictly positive *)
let
m_ij
=
float_of_string
value
+.
if
i
=
j
then
0
.
000001
else
0
.
in
i
,
j
,
m_ij
)
)
in
transform_matrix
(
List
.
length
rowwise_matrix
)
(
List
.
concat
rowwise_matrix
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment