Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs #12

Merged
merged 1 commit into from
Mar 3, 2024
Merged

docs #12

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/bootstrap.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use rand::distributions::{Distribution, Uniform};
use rand::Rng;

/// Get a random uniform sample of `n` numbers in the range [0,n).
/// Duplicates are explicitly allowed. The numbers are returned in
/// sorted order.
pub fn get_sample_inds<R: Rng + ?Sized>(n: usize, rng: &mut R) -> Vec<usize> {
let dist = Uniform::new(0, n);
let mut inds: Vec<usize> = dist.sample_iter(rng).take(n).collect();
Expand Down
10 changes: 9 additions & 1 deletion src/em.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ fn m_step_par<'a>(
/// Then, `curr_counts` is computed by summing over the expected assignment
/// likelihood for all reads mapping to each target.
#[inline]
#[allow(dead_code)]
fn m_step<'a, I: Iterator<Item = (&'a [AlnInfo], &'a [f32], &'a [f64])>>(
eq_map_iter: I,
_tinfo: &[TranscriptInfo],
Expand Down Expand Up @@ -103,6 +102,15 @@ fn m_step<'a, I: Iterator<Item = (&'a [AlnInfo], &'a [f32], &'a [f64])>>(
}
}

/// The code that actually performs the EM loop in the single-threaded context.
/// The parameters are
/// `em_info` : an [EMInfo] struct that contains the relevant parameters and data
/// `make_iter`: a function that returns an iterator over the alignments and conditional
/// probabilites
/// `do_log`: `true` if logging information is written about this EM run and false otherwise
///
/// returns:
/// A [Vec<f64>] represented the expected read assignments to each transcript.
pub fn do_em<'a, I: Iterator<Item = (&'a [AlnInfo], &'a [f32], &'a [f64])> + 'a, F: Fn() -> I>(
em_info: &'a EMInfo,
make_iter: F,
Expand Down