biosurf / cyCombine

Robust Integration of Single-Cell Cytometry Datasets
Other
24 stars 6 forks source link

detect_batch_effect_express error with ggridges::geom_density_ridges() #46

Closed fingeram closed 5 months ago

fingeram commented 6 months ago

Hi,

I recently updated my R and RStudio (along with the necessary tools and java) on a Mac M2 (Sonoma OS) and now I am receiving an error message when attempting to run detect_batch_effect_express on my counts table. Here is the code I am using to generate the data tibble from my flowset object and the error I receive. Previously cyCombine and its batch effect detection functions have worked perfectly with my R version. So I am assuming it has something to do with the update. I would really appreciate any feedback on this!

Thank you

create tibble from flowSet

dfci_transform <- prepare_data(data_dir = NULL, flowset=fcs_transform_QC, metadata = md_2, filename_col = "file_name", batch_ids = "batch", markers = c(markerstotransform), #same as used for clustering derand = F, down_sample = FALSE, #can also downsample here if needed transform = F, #we already transformed above, so not needed condition = "genotype", panel = panel, panel_channel = "fcs_colname", panel_antigen = "antigen", seed = 1234)

run batch effect express

detect_batch_effect_express(df = dfci_transform[,c(1,9:25,28:30)], out_dir = 'batcheffect_express_transform', batch_col = "batch", downsample = NULL, seed=1234)

Starting the quick(er) detection of batch effects. Making distribution plots for all markers in each batch. Error in ggridges::geom_density_ridges(): ! Problem while computing aesthetics. ℹ Error occurred in the 1st layer. Caused by error: ! object 'F4' not found Backtrace:

  1. cyCombine::detect_batch_effect_express(...)
    1. cowplot::plot_grid(plotlist = p, nrow = round(length(all_markers)/6))
    2. cowplot::align_plots(...)
    3. base::lapply(...)
    4. cowplot (local) FUN(X[[i]], ...) ...
    5. ggplot2 (local) f(l = layers[[i]], d = data[[i]])
    6. l$compute_aesthetics(d, plot)
    7. ggplot2 (local) compute_aesthetics(..., self = self)
    8. base::lapply(aesthetics, eval_tidy, data = data, env = env)
    9. rlang (local) FUN(X[[i]], ...)
shdam commented 6 months ago

Hi there,

Thank you for using cyCombine! I am happy to hear it usually works perfectly :)

I wonder what this "F4" object it is looking for is.. As a sanity check, could you share what is returned by cyCombine::get_markers(dfci_transform[,c(1,9:25,28:30)])?

Best regards, Søren

fingeram commented 6 months ago

Hi

thanks for your reply! :) Here's what you asked for:

cyCombine::get_markers(dfci_transform[,c(1,9:25,28:30)]) [1] "F4/80" "TNFa" "LIF" "SiglecF" "MHCII" "CD103" "XCR1" "CD11b" "CD11c" "Ly6G" "CD90.2" "CD64" "CD301b" [14] "CD8a" "SiglecH" "CD45" "CD3"

I also went into the function of detect_batch_effect_express() to see where the error is coming from exactly. And it seems like the issue is the cowplot::plot_grid command. I believe it comes down to plot_grid not working with the new version of R on mac M2.

shdam commented 6 months ago

Hey,

I suspect the marker "F4/80" could be causing issues, since it has an illegal character. Does it work if you exclude it?

Best regards, Søren

fingeram commented 6 months ago

No, it returns the same error. I have also used this marker/name previously and it has worked fine.

shdam commented 6 months ago

Hi,

I encourage you to try again. I changed a column name in my test data to "F4/80", and I now get exactly your error. Renaming it to, e.g., "F4.80" made it work again.

Let me know if it still fails.

Best regards, Søren

fingeram commented 6 months ago

Hi Søren,

apologies I am just getting back to you and thank you for insisting! I went back to the beginning of the analysis and made sure I changed the name to F4.80 in all the metadata. In fact that fixed the issue and I was able to run the batch effect check functions (express and full)! It's weird because I definitely was able to run it with the slash previously but now I am just glad it works.

Thanks a lot for your help! Best, Anna

shdam commented 5 months ago

Hi Anna,

Happy to hear it got resolved! I will try to account for this issue in the code as well :)

Best regards, Søren