Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bamcalib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LBMC
Bernard
bamcalib
Commits
f23458c1
Verified
Commit
f23458c1
authored
Mar 10, 2023
by
Laurent Modolo
Browse files
Options
Downloads
Patches
Plain Diff
compte mean read count instead of read count
parent
bf53681f
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/pileup.rs
+13
-4
13 additions, 4 deletions
src/pileup.rs
src/stats.rs
+9
-9
9 additions, 9 deletions
src/stats.rs
with
22 additions
and
13 deletions
src/pileup.rs
+
13
−
4
View file @
f23458c1
...
...
@@ -2,9 +2,9 @@
//
// SPDX-License-Identifier: AGPL-3.0-or-later
use
crate
::
multimapping
::
MultiMappingReads
;
use
crate
::
utils
::{
open_bam
,
Chromosomes
};
use
create
::
multimapping
::
MultiMappingReads
;
use
bam
;
use
create
::
utils
::{
open_bam
,
Chromosomes
};
use
statrs
::
distribution
::{
ContinuousCDF
,
Normal
};
use
std
::
fs
::
File
;
use
std
::
rc
::
Rc
;
...
...
@@ -269,7 +269,7 @@ pub fn compute_depth(
prefix
:
&
str
,
thread_local
:
u16
,
no_bits
:
u16
,
)
->
(
Depth
,
u
64
,
u
64
,
Chromosomes
)
{
)
->
(
Depth
,
f
64
,
f
64
,
Chromosomes
)
{
let
(
multimap
,
chr
,
fragment_len
)
=
MultiMappingReads
::
init
(
file
,
prefix
,
thread_local
,
no_bits
);
let
mut
reader
=
open_bam
(
file
,
thread_local
);
...
...
@@ -278,6 +278,8 @@ pub fn compute_depth(
depth
.init
(
&
chr
);
let
mut
ref_count
:
u64
=
0
;
let
mut
calib_count
:
u64
=
0
;
let
mut
ref_size
:
u64
=
0
;
let
mut
calib_size
:
u64
=
0
;
let
mut
ref_depth
=
ColumnDepth
::
new
(
fragment_len
);
let
mut
calib_depth
=
ColumnDepth
::
new
(
fragment_len
);
for
column
in
pileup
{
...
...
@@ -287,8 +289,10 @@ pub fn compute_depth(
column
.ref_pos
(),
ref_depth
.depth
(
&
column
)
as
u64
,
);
ref_size
+=
1
;
}
else
{
calib_count
+=
calib_depth
.depth
(
&
column
)
as
u64
;
calib_size
+=
1
;
}
}
if
ref_count
==
0
{
...
...
@@ -297,5 +301,10 @@ pub fn compute_depth(
if
calib_count
==
0
{
panic!
(
"no read detected in the calibration genome (maybe the no_bits is filtering too stringent)"
)
}
return
(
depth
,
ref_count
,
calib_count
,
chr
);
return
(
depth
,
(
ref_count
as
f64
/
ref_size
as
f64
),
(
calib_count
as
f64
/
calib_size
as
f64
),
chr
,
);
}
This diff is collapsed.
Click to expand it.
src/stats.rs
+
9
−
9
View file @
f23458c1
...
...
@@ -2,21 +2,21 @@
//
// SPDX-License-Identifier: AGPL-3.0-or-later
use
crate
::
pileup
;
use
crate
::
utils
::
Chromosomes
;
use
cr
e
ate
::
pileup
;
use
cr
e
ate
::
utils
::
Chromosomes
;
use
std
::
sync
::
mpsc
;
use
std
::
thread
;
/// Store genome statistics necessary for normalization
#[derive(Debug,
Copy,
Clone)]
struct
GenomeStats
{
read_count
:
u
64
,
read_count
:
f
64
,
}
impl
GenomeStats
{
/// Create a new GenomeStats with read_count set to 0
pub
fn
new
()
->
GenomeStats
{
GenomeStats
{
read_count
:
0
}
GenomeStats
{
read_count
:
0
.0
}
}
}
...
...
@@ -93,7 +93,7 @@ impl ORStats {
self
.compute_depth
(
bam_ip
,
bam_wce
,
prefix
,
thread_local
,
no_bits
);
(
self
.pos_chr_id
,
self
.pos_chr_pos
)
=
match
self
.ip.chromosomes
.get_start_pos
(
true
)
{
Some
(
pos
)
=>
pos
,
None
=>
panic!
(
"init(): no valid
e
position in the reference genome"
),
None
=>
panic!
(
"init(): no valid position in the reference genome"
),
};
self
.compute_or
();
self
.compute_alpha
();
...
...
@@ -167,7 +167,7 @@ impl ORStats {
/// Function to compute the OR from the results of the compute_depth() function
pub
fn
compute_or
(
&
mut
self
)
{
self
.or
=
1.0e9
*
(
self
.wce.calibration.read_count
as
f64
)
self
.or
=
(
self
.wce.calibration.read_count
as
f64
)
/
((
self
.ip.calibration.read_count
as
f64
)
*
(
self
.wce.reference.read_count
as
f64
));
}
...
...
@@ -178,7 +178,7 @@ impl ORStats {
let
mut
chr_pos
;
(
chr_id
,
chr_pos
)
=
match
self
.ip.chromosomes
.get_start_pos
(
true
)
{
Some
(
pos
)
=>
pos
,
None
=>
panic!
(
"compute_alpha(): no valid
e
position in the reference genome"
),
None
=>
panic!
(
"compute_alpha(): no valid position in the reference genome"
),
};
loop
{
let
ip_depth
=
match
self
.ip_depth
.get
(
chr_id
,
chr_pos
)
{
...
...
@@ -198,7 +198,7 @@ impl ORStats {
}
}
self
.alpha
=
(
self
.alpha
/
(
self
.ip.reference.read_count
as
f64
))
*
(
(
self
.wce.calibration.read_count
as
f64
)
/
1.0e9
)
;
*
(
self
.wce.calibration.read_count
as
f64
);
}
/// Return the OR value to normalize the IP coverage
...
...
@@ -246,7 +246,7 @@ impl Iterator for ORStats {
#[cfg(test)]
mod
tests
{
use
crate
::
stats
::
*
;
use
cr
e
ate
::
stats
::
*
;
#[test]
fn
test_chromosomes
()
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment