Skip to content
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

Simulated data for one cell type #71

Open
ahassien opened this issue Jan 8, 2025 · 3 comments
Open

Simulated data for one cell type #71

ahassien opened this issue Jan 8, 2025 · 3 comments

Comments

@ahassien
Copy link

ahassien commented Jan 8, 2025

Hi there,

The data that I am working with has a single cell type (tumor cells), and I am wondering why this would not work within the scDesign3 framework. I am trying to benchmark the identification of DEGs.

I tried replicating the issue by changing the cell type filtering in the DE analysis example to only include one cell type: https://songdongyuan1994.github.io/scDesign3/docs/articles/scDesign3-DEanalysis-vignette.html#identification-of-de-genes-between-discrete-cell-types

# selected_cells <- which(colData(example_sce)$phenoid %in% c("b.cells","regulatory.t"))
selected_cells <- which(colData(example_sce)$phenoid %in% c("b.cells"))

And it yields the same error that I get when I run it on my own data:

Convert Residuals to Multivariate Gaussian
Error in `colnames<-`(`*tmp*`, value = rownames(sce)) : 
  attempt to set 'colnames' on an object with less than two dimensions
In addition: Warning message:
In mclapply(seq_len(n), do_one, mc.preschedule = mc.preschedule,  :
  all scheduled cores encountered errors in user code

Is there any reason why the scDesign3 framework requires more than one cell type?
Unrelated to the example, I am having some follow-up issues with my particular dataset, particularly involving the following error:

Error in x$fit : $ operator is invalid for atomic vectors

I am thinking that this error could be related to the one cell type issue since I do not want my formula to include cell_type.
Many thanks in advance!

@dsong-lab
Copy link

@ahassien Hi Alexa,
Yes, your guess is correct. Because here you only have one cell type, you should change any formula (e.g., mu_formula = 'cell_type') to mu_formula = '1'. You can imagine that if your covariate only has one value, it equals to the intercept. Let me know if you have more questions.

Best regards,
Dongyuan

@ahassien
Copy link
Author

ahassien commented Jan 8, 2025

@dsong-lab Hi there Dongyuan,

This makes perfect sense. Thank you for the clarification. Does this also affect models with additional covariates?
For example, if I want to include 'sample' and 'grade' covariates in my mu formula. I get the following error regardless of whether I use mu_formula = "sample + grade" or mu_formula = "1 + sample + grade"

Input Data Construction Start
Input Data Construction End
Start Marginal Fitting
Marginal Fitting End
Start Copula Fitting
Error in x$fit : $ operator is invalid for atomic vectors

Here is my code for using the scDesign function:

simu_res <- scdesign3(sce = sce_test, 
                      assay_use = "counts", 
                      celltype = "cell_type", 
                      pseudotime = NULL, 
                      spatial = NULL, 
                      other_covariates = NULL, 
                      mu_formula = "sample + grade", # alternatively I have tried "1 + sample + grade"
                      sigma_formula = "1", 
                      family_use = "nb", 
                      usebam = FALSE, 
                      corr_formula = "1", 
                      copula = "gaussian", 
                      DT = TRUE, 
                      pseudo_obs = FALSE, 
                      return_model = FALSE)

Many thanks in advance,
Lexie

@dsong-lab
Copy link

Hi Lexie,
You need to add those covariate names into other_covariates; otherwise, scDesign3 does not know you have them in your dataset.

Best,
Dongyuan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants