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

The program got stuck when simulating spatial data #70

Open
chthub opened this issue Jan 5, 2025 · 3 comments
Open

The program got stuck when simulating spatial data #70

chthub opened this issue Jan 5, 2025 · 3 comments

Comments

@chthub
Copy link

chthub commented Jan 5, 2025

Thanks for your awesome tool. When I try the tutorial to simulate the spatial transcriptomic data, the code got stuck in "Start Parameter Extraction", here is the code:

library(scDesign3)
library(SingleCellExperiment)
library(ggplot2)
library(dplyr)
library(viridis)
theme_set(theme_bw())

example_sce <- readRDS((url("https://figshare.com/ndownloader/files/40582019")))
print(example_sce)

example_sce <- example_sce[1:10, ]

set.seed(123)
example_simu <- scdesign3(
  sce = example_sce,
  assay_use = "counts",
  celltype = "cell_type",
  pseudotime = NULL,
  spatial = c("spatial1", "spatial2"),
  other_covariates = NULL,
  mu_formula = "s(spatial1, spatial2, bs = 'gp', k= 10)",
  sigma_formula = "1",
  family_use = "nb",
  n_cores = 128,
  usebam = TRUE,
  corr_formula = "1",
  copula = "gaussian",
  DT = TRUE,
  pseudo_obs = FALSE,
  return_model = FALSE,
  nonzerovar = FALSE,
  parallelization = "pbmcapply"
)
print(example_simu)

Here is the outputs:

class: SingleCellExperiment
dim: 1000 2696
metadata(0):
assays(2): counts logcounts
rownames(1000): Calb2 Gng4 ... Fndc5 Gda
rowData names(0):
colnames(2696): AAACAAGTATCTCCCA-1 AAACACCAATAACTGC-1 ...
  TTGTTTCACATCCAGG-1 TTGTTTCCATACAACT-1
colData names(12): orig.ident nCount_Spatial ... spatial2 cell_type
reducedDimNames(0):
mainExpName: NULL
altExpNames(0):
Input Data Construction Start
Input Data Construction End
Start Marginal Fitting
Marginal Fitting End
Start Copula Fitting
Convert Residuals to Multivariate Gaussian
Converting End
Copula group 1 starts
Copula Fitting End
Start Parameter Extraction

I have been waiting for many days, but the program is just stuck here...

@dsong-lab
Copy link

Hi,

Thanks for your interst in scDesign3. Since you only test on 10 genes, would you mind trying n_cores = 1 and let me know if it works? Thanks!

@chthub
Copy link
Author

chthub commented Jan 6, 2025

@dsong-lab Thanks for your reply. It works. I am confused that when I need to adjust this parameter? Should I always use 1?

@dsong-lab
Copy link

Hi,
The number of cores you should use is a complicated problem; it depends on both your number of available cores and memory. If you use too many cores, the program will freeze quite often.

I would suggest: 1. The number of cores should be smaller than 1/10 of your total number of genes;
2. Make sure that each core can get >1 GB ROM;
3. I usually use <= 20 cores to make it safe.

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