Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F102274317
ReferenceComputer.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Feb 19, 00:08
Size
2 KB
Mime Type
text/x-c
Expires
Fri, Feb 21, 00:08 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
24320440
Attached To
R8820 scATAC-seq
ReferenceComputer.cpp
View Options
#include <ReferenceComputer.hpp>
#include <Matrix2D.hpp>
#include <Matrix4D.hpp>
// some typdef
#include <typedef.hpp>
ReferenceComputer
::
ReferenceComputer
(
const
Matrix2D
<
int
>&
data
,
const
Matrix4D
<
double
>&
posterior_prob
,
size_t
n_threads
)
:
EMEngine
(
data
,
posterior_prob
.
get_dim
()[
1
],
1
,
posterior_prob
.
get_dim
()[
2
],
posterior_prob
.
get_dim
()[
3
]
==
2
,
EMEngine
::
seeding_codes
::
RANDOM
,
""
,
n_threads
)
{
// copy the data
this
->
data
=
matrix2d_i
(
this
->
n_row
,
v_i
(
this
->
n_col
))
;
for
(
size_t
i
=
0
;
i
<
this
->
n_row
;
i
++
)
{
for
(
size_t
j
=
0
;
j
<
this
->
n_col
;
j
++
)
{
this
->
data
[
i
][
j
]
=
data
(
i
,
j
)
;
}
}
// compute window means
this
->
window_mean
=
matrix2d_d
(
this
->
n_row
,
v_d
(
this
->
n_shift
,
0.
))
;
this
->
compute_window_means
()
;
// initialise, copy and compute probs
this
->
post_prob
=
matrix4d_d
(
this
->
n_row
,
matrix3d_d
(
this
->
n_class
,
matrix2d_d
(
this
->
n_shift
,
v_d
(
this
->
n_flip
,
0.
))))
;
this
->
class_prob
=
matrix3d_d
(
this
->
n_class
,
matrix2d_d
(
this
->
n_shift
,
v_d
(
this
->
n_flip
,
0.
)))
;
this
->
class_prob_tot
=
v_d
(
this
->
n_class
,
0.
)
;
this
->
post_prob_class
=
v_d
(
this
->
n_class
,
0.
)
;
for
(
size_t
i
=
0
;
i
<
this
->
n_row
;
i
++
)
{
for
(
size_t
j
=
0
;
j
<
this
->
n_class
;
j
++
)
{
for
(
size_t
s
=
0
;
s
<
this
->
n_shift
;
s
++
)
{
for
(
size_t
f
=
0
;
f
<
this
->
n_flip
;
f
++
)
{
double
p
=
posterior_prob
(
i
,
j
,
s
,
f
)
;
this
->
post_prob
[
i
][
j
][
s
][
f
]
=
p
;
this
->
post_prob_class
[
j
]
+=
p
;
this
->
post_prob_tot
+=
p
;
}
}
}
}
this
->
compute_class_prob
()
;
// compute the references
this
->
references
=
matrix2d_d
(
this
->
n_class
,
v_d
(
this
->
l_slice
,
0.
))
;
this
->
compute_references
()
;
}
ReferenceComputer
::~
ReferenceComputer
()
{
;
}
Matrix2D
<
double
>
ReferenceComputer
::
get_references
()
const
{
// add a 1st column with the class probabilities
Matrix2D
<
double
>
references
(
this
->
n_class
,
this
->
l_slice
+
1
,
0.
)
;
for
(
size_t
i
=
0
;
i
<
this
->
n_class
;
i
++
)
{
// class prob
references
(
i
,
0
)
=
this
->
class_prob_tot
[
i
]
;
// signal
for
(
size_t
j
=
0
;
j
<
this
->
l_slice
;
j
++
)
{
references
(
i
,
j
+
1
)
=
this
->
references
[
i
][
j
]
;
}
}
return
references
;
}
Event Timeline
Log In to Comment