-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Warnings/errors produced while running MAST with mixed effect #133
Comments
Can you provide a minimal reproducible example? Otherwise we are just speculating. |
Thank you so much for taking the time to take a look at this! I've attached the sca object that I'm working with but downsampled to 1000 cells in each condition to reduce file size. I anticipate that the above command should reproduce the errors that I'm seeing. |
Could you post the sca object with all cells but downsampled to several genes that give the error and others that don't? |
Okay so just looking quickly at your data set, it looks like you haven't filtered out genes that aren't expressed in any cells. That's likely the problem. When I filter on genes with at least 10% expression the errors you describe go away. |
Ah I see! I will make those changes and see how it goes. Thank you so much for checking! |
Hmm taking a look, it seems that filtering out genes expressed in at least 10% cells still produces the same errors/warnings for many, albeit possibly at lower frequency. They include: Error : number of levels of each grouping factor must be < number of observations In addition: Warning messages: 2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, : 5: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
None of these strictly stop the code from running, so I'll take a look at the end results once it completes on the computer cluster (the code noticeably takes a much longer time than with fixed effects using bayesglm, understandably) |
Can you post code that does the filtering and leads to the same errors? I am not experiencing this side-effect. |
Sure! This is the code I've been using below: ==================================
|
So the above works relatively fine, some convergence errors. |
Also, don't fit different models for each pariwise comparison. Fit one model and compute contrasts. |
Ah gotcha ... I was hoping that including the random effect might allow me to account for batch effect without downsampling, but I guess it makes sense that this might lead to unstable fits that don't converge. One warning for the life of me I can't understand though is this: It seems like it's a function in both lme4 and stats, but both are loaded for me. Do you have a sense of what this method is when I'm running MAST and if it's something specific to my R environment? In the meantime, I'll try to downsample and balance the batches. Thank you! |
To be clear, the problem is not that you're donwnsampling, the problem is that you appear to be fitting a bunch of pairwise models. Instead fit one model and compute the contrasts of interest. |
Ah I see what you are saying about fitting a single model and using contrasts for multiple pairwise comparisons. I guess for this particular case though I'm just running this code once and making a single pairwise comparison, and these 2 conditions that I'm comparing essentially cover the entire dataset; so in essence, I'm doing a single pairwise comparison for the entire dataset and getting these warnings/errors. But your point is well taken, and definitely for instances where I'm doing multiple pairwise comparisons in the future, I'll be sure to change my code to fit a single model! |
See if you can isolate one gene that gives the |
|
Thank you both so much for your comments! I do think you're right that the batch sizes are unbalanced and that may be leading to errors. The batch sizes that I sent you were uniformly downsampled actually just to give you guys a smaller file size to work with, but are actually much larger. That said, there is def the same imbalance with one batch size far outnumbering the others. I just did a run without that large batch and found that a number of these errors had disappeared, so I do believe I might need to downsample a bit to try to restore some balance. I'll see how the downsampling works ... thank you so much! |
Hi there,
I was wondering if you might be able to help me with an issue I've been having when running MAST including a random effect for batch. Despite following previous threads related to this topic, I keep getting a number of warnings and errors.
In particular, I have data for ~53,000 cells from 20 patients (batch) where I want to compare 2 groups of cells (condition), after calculating the centered cellular detection rate (cngeneson). I placed "batch" as a vector of 20 factors in my sca data frame. I then run the following command:
library(lme4)
zlmCond <- zlm(~condition + cngeneson + (1|batch), sca = sca, method = 'glmer', ebayes = F, strictConvergence=F, fitArgsD = list(nAGQ = 0))
However, I get a number of different warnings and errors, 3 of which worry me:
==============
Warning message:
In nobs.default(object, use.fallback = use.fallback) :
no 'nobs' method is available
Error : number of levels of each grouping factor must be < number of observations
Error in (function (cl, name, valueClass) :
assignment of an object of class “list” is not valid for @‘optimMsg’ in an object of class “LMERlike”; is(value, "character") is not TRUE
==============
It's unclear to me why 'nobs' is not recognized as a method, as it appears to be included in lme4 which I already loaded. It seems like the levels of my grouping factor (20) are well below the number of observations (53,000). I have no idea what to make of the 3rd error.
Thank you for any help you can provide!
The text was updated successfully, but these errors were encountered: