bvieth / powsimR

Power analysis is essential to optimize the design of RNA-seq experiments and to assess and compare the power to detect differentially expressed genes. PowsimR is a flexible tool to simulate and evaluate differential expression from bulk and especially single-cell RNA-seq data making it suitable for a priori and posterior power analyses.
https://bvieth.github.io/powsimR/
Artistic License 2.0
103 stars 23 forks source link

vector size #63

Closed antoine4ucsd closed 11 months ago

antoine4ucsd commented 1 year ago

Hello I was able to install your great package. it works fine. but I have an error with the following: My goal is to do a power analyses for 20 samples with 500 and 1000 (and ideally 5000) cells per sample. I started with smthg like that

#read in count seurat object with spleed scRNAseq data
spleen.filt <- readRDS('spleen_filt_cells.rds', refhook = NULL)

#extract counts from Seurat object
counts <- as.matrix(GetAssayData(object = spleen.filt, slot = "counts"))

setupres <- Setup(ngenes = 10000, nsims = 10, 
                  p.DE = 0.05, pLFC = p.lfc,
                  n1 = c(10000,20000), n2 = c(10000,20000), 
                  Thinning = NULL, LibSize = 'equal',
                  estParamRes = estparam,
                  estSpikeRes = NULL,
                  DropGenes = TRUE,
                  setup.seed = 5299, verbose = TRUE) 

The provided count matrix has 3881 out of 3881 single cells and 21901 out of 33539 genes with at least 1 count.

# define log fold change
p.lfc <- function(x) sample(c(-1,1), size=x,replace=T)*rgamma(x, shape = 1, rate = 2)
# set up simulations
setupres <- Setup(ngenes = 10000, nsims = 5, # was initially set to 25
                  p.DE = 0.05, pLFC = p.lfc,
                  n1 = c(10000,20000), n2 = c(10000,20000), # number of cells for example, if 20 samples, this will evaluate 500 cells and 1000 cells
                  Thinning = NULL, LibSize = 'equal',
                  estParamRes = estparam,
                  estSpikeRes = NULL,
                  DropGenes = TRUE,
                  setup.seed = 5299, verbose = TRUE)

but I get an error due to the vector size... " cannot allocate a vector of size 1.3Go"

is there a way to make it work for such sample size?

thank you!

bvieth commented 11 months ago

Hello,

with your defined setup the matrices indeed will be very large. If you want to create 20 'pseudo' replicates of 500 vs 1000, you can just run the Setup() with nsims = 20 and n1 = 500 and n2 = 1000.

HTH Beate

antoine4ucsd commented 11 months ago

thank you!