niaid/dsb

return.stats use-case error

diegoalexespi opened this issue · 2 comments

Hi dsb team!

Thank you for the excellent tool and vignettes. I ran into an error when setting the following parameters in DSBNormalizeProtein:

DSBNormalizeProtein(
        cell_protein_matrix = raw_matrix, 
        empty_drop_matrix = background_matrix,
        denoise.counts = TRUE, 
        use.isotype.control = FALSE,
        return.stats = TRUE)

When return.stats = TRUE and use.isotype.control = FALSE, the object noise_matrix will not be instantiated, but the function will attempt to access it, leading to the error: Error in t(noise_matrix) : object 'noise_matrix' not found because of the following lines of code:

dsb/R/dsb.r

Lines 254 to 257 in 3531cdc

if(isTRUE(denoise.counts)) {
technical_stats = cbind(t(noise_matrix), dsb_technical_component = noise_vector)
} else{
technical_stats = NULL

I quickly fixed this by adding an if-else statement in a fork, and I can open a pull request to merge if you agree with the fix!

Hi Diego, thank you for finding this and for this contribution! I've merged your change with the master branch. If no isotypes are specified the technical stats returned is just the technical component.

  • note I will add an additional unit test to capture this change before pushing to CRAN.

@diegoalexespi
Hi Diego, thanks again; this is now fixed in dsb version 1.0.2 on CRAN.

-Matt