niaid / dsb

Normalize CITEseq Data
Other
63 stars 13 forks source link

## Advance use error #45

Closed Sogand65 closed 5 months ago

Sogand65 commented 1 year ago

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.

MattPM commented 1 year ago

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

Sogand65 commented 1 year ago

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 )

MattPM commented 8 months ago

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.

Moonbow11 commented 6 months ago

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! :)

MattPM commented 6 months ago

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

MattPM commented 5 months ago

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