dsb icon indicating copy to clipboard operation
dsb copied to clipboard

## Advance use error

Open Sogand65 opened this issue 2 years ago • 5 comments

Hi, I am using the latest version 1.0.3 When using argument scsle.factor = "mean_subtract I get the following error: [1] "correcting ambient protein background noise" [1] "fitting models to each cell for dsb technical component and removing cell to cell technical noise" Error in apply(norm_adt, 2, function(x) { : object 'norm_adt' not found

This error seems to suggest that there's a reference to a local variable norm_adt within the function that is not found. The error occurs only when I set the scale.factor argument to "mean_subtract". If I omit this argument, the function proceeds without any issues.

Could you please help me understand what might be causing this error and how to resolve it?

Thank you for your assistance and for developing such a useful tool.

Sogand65 avatar Nov 11 '23 22:11 Sogand65

@Sogand65 Thanks, I'm taking a look at this. Can you please provide me with the entire function and all options you used?

MattPM avatar Nov 13 '23 12:11 MattPM

Sure!

Advanced user

cells.dsb.norm.adv <- DSBNormalizeProtein( cell_protein_matrix = cell.adt, empty_drop_matrix = empty_drop, denoise.counts = TRUE, use.isotype.control = TRUE, isotype.control.name.vec = isotype_controls, define.pseudocount = TRUE, pseudocount.use = 1, quantile.clipping = TRUE, quantile.clip = c(0.05, 0.95), return.stats = TRUE sacale.factor = "mean.subtract". ## Here if I use this scaling it generates the error )

Sogand65 avatar Nov 14 '23 14:11 Sogand65

Hi @Sogand65 I can't reproduce your error.

In both of your comments above you misspelled the argument scale.factor. Could that be the problem?

In the software, I have unit tests that cover all the different normalization function options. The unit test that corresponds to this scaling argument is below:


  # test non default scaling
  r2 =
    DSBNormalizeProtein(cell_protein_matrix = cells_citeseq_mtx[ ,1:100],
                         empty_drop_matrix = empty_drop_citeseq_mtx,
                         define.pseudocount = TRUE,
                         pseudocount.use = 5,
                         use.isotype.control = TRUE,
                         isotype.control.name.vec = rownames(cells_citeseq_mtx)[grepl(
                           rownames(cells_citeseq_mtx), pattern = 'otyp')],
                         quantile.clipping = TRUE, scale.factor = 'mean.subtract',
                         return.stats = FALSE)
  r2mean = mean(rowMeans(r2))
  testthat::expect_lt(object = r2mean, 1)

This is the output I get: [1] "correcting ambient protein background noise" [1] "fitting models to each cell for dsb technical component and removing cell to cell technical noise"

r2mean = mean(rowMeans(r2)) r2mean [1] 0.3772075

If you still have the error let me know and maybe provide a reprex using the included package data? (See various examples in the documentation). Sorry this took a while to get back to you.

MattPM avatar Mar 06 '24 17:03 MattPM

Hi, I'm really happy I found your package, thank you so much! I am going through your end_to_end_workflow vignette and I had the same error as Sogand65. But I figured out it is because there is a typo in the vignette, it's in chunk 13, "scale.factor = 'mean_subtract'" should be "scale.factor = 'mean.subtract'". Correcting that typo fixes the error and the function runs normally. It is correct in the function documentation. Just thought you might want to know in case you can fix the vignette! :)

Moonbow11 avatar May 16 '24 00:05 Moonbow11

@Moonbow11 I see, thanks for letting me know, I will fix the documentation. -Matt

MattPM avatar May 17 '24 16:05 MattPM

This is updated in dsb 1.0.4 now on CRAN. https://cran.r-project.org/package=dsb

MattPM avatar Jun 16 '24 16:06 MattPM