Skip to content

Commit

Permalink
feat: allow gz unfiltered permit list via niffler
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Patro committed Dec 20, 2024
1 parent bcaa78c commit 0c8c8ed
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 8 deletions.
22 changes: 22 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ clap = { version = "4.5.23", features = [
noodles = { version = "0.85.0", features = ["bam", "bgzf", "sam"] }
dashmap = { version = "6.1.0", features = ["serde", "inline"] }
nalgebra = "0.33.2"
niffler = { version = "2.6.0", default-features = false, features = ["gz", "gz_cloudflare_zlib"] }

[profile.release]
#debug = true
Expand Down
8 changes: 4 additions & 4 deletions scripts/testing/compare_counts.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ def compare_quants(args):

odict = { "nobs_ref" : a.n_obs, "nobs_test" : b.n_obs }

odict['diff_U'] = float(abs(a.layers['unspliced'] - b[ a.obs_names, : ].layers['unspliced']).sum())
odict['diff_S'] = float(abs(a.layers['spliced'] - b[ a.obs_names, : ].layers['spliced']).sum())
odict['diff_A'] = float(abs(a.layers['ambiguous'] - b[ a.obs_names, : ].layers['ambiguous']).sum())
odict['diff_U'] = float(abs(a.layers['unspliced'] - b[ a.obs_names, a.var_names ].layers['unspliced']).sum())
odict['diff_S'] = float(abs(a.layers['spliced'] - b[ a.obs_names, a.var_names ].layers['spliced']).sum())
odict['diff_A'] = float(abs(a.layers['ambiguous'] - b[ a.obs_names, a.var_names ].layers['ambiguous']).sum())

odict['obs_ref-obs_test'] = list(a.obs_names.difference(b.obs_names))
odict['obs_test-obs_ref'] = list(b.obs_names.difference(a.obs_names))
Expand All @@ -67,7 +67,7 @@ def compare_quants(args):

odict = { "nobs_ref" : a.n_obs, "nobs_test" : b.n_obs }

odict['diff_X'] = float(abs(a.X - b[ a.obs_names, : ].X).sum())
odict['diff_X'] = float(abs(a.X - b[ a.obs_names, a.var_names ].X).sum())

odict['obs_ref-obs_test'] = list(a.obs_names.difference(b.obs_names))
odict['obs_test-obs_ref'] = list(b.obs_names.difference(a.obs_names))
Expand Down
13 changes: 11 additions & 2 deletions src/atac/cellfilter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,17 @@ pub fn generate_permit_list(gpl_opts: GenPermitListOpts) -> anyhow::Result<u64>
}

if let CellFilterMethod::UnfilteredExternalList(fname, _) = &filter_meth {
let i_file = File::open(fname).context("could not open input file")?;
let br = BufReader::new(i_file);
let (reader, compression) = niffler::from_path(fname)
.with_context(|| format!("coult not open input file {}", fname.display()))?;
let br = BufReader::new(reader);

info!(
log,
"reading permit list from {}; inferred format {:#?}",
fname.display(),
compression
);

unfiltered_bc_counts = Some(populate_unfiltered_barcode_map(br, &mut first_bclen, rc));
info!(
log,
Expand Down
14 changes: 12 additions & 2 deletions src/cellfilter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use libradicl::rad_types::{self, RadType};
use libradicl::BarcodeLookupMap;
use libradicl::{chunk, record::AlevinFryReadRecord};
use needletail::bitkmer::*;
use niffler::{compression, Error};
use num_format::{Locale, ToFormattedString};
use serde::Serialize;
use serde_json::json;
Expand Down Expand Up @@ -634,8 +635,17 @@ pub fn generate_permit_list(gpl_opts: GenPermitListOpts) -> anyhow::Result<u64>
let mut first_bclen = 0usize;
let mut unfiltered_bc_counts = None;
if let CellFilterMethod::UnfilteredExternalList(fname, _) = &filter_meth {
let i_file = File::open(fname).context("could not open input file")?;
let br = BufReader::new(i_file);
let (reader, compression) = niffler::from_path(fname)
.with_context(|| format!("coult not open input file {}", fname.display()))?;
let br = BufReader::new(reader);

info!(
log,
"reading permit list from {}; inferred format {:#?}",
fname.display(),
compression
);

unfiltered_bc_counts = Some(populate_unfiltered_barcode_map(br, &mut first_bclen));
info!(
log,
Expand Down

0 comments on commit 0c8c8ed

Please sign in to comment.