ENIGMA
ENIGMA copied to clipboard
Error in rowSums(Ma) : 'x' must be an array of at least two dimensions
Hi,
Thank you for this package. I have been looking for something like this. I tried to use this with my data but I got the following error.
Error in rowSums(Ma) : 'x' must be an array of at least two dimensions
My codes are:
egm = create_ENIGMA(bulk = as.matrix(countdata_all),
ref = sce,
ref_type = "single_cell",
meta_ref = colData(sce))
egm = batch_correct(egm,
varname_cell_type = "celltype_global",
n_pseudo_bulk=100)
Here, I am using a SingleCellExperiment object. Can you please help with the error?
Nurun
Hi Nurun! Thx for using our tool! I have run the following code on my machine, it seems that the 'batch_correct' function could run on my data without error or warnings.
sce = SingleCellExperiment(assays = list(counts = exprs(ref_sc_sub)))
sce$celltype_global = pData(ref_sc_sub)$main_celltype
egm = create_ENIGMA(bulk = Bulk, ref = sce, ref_type = "single_cell",meta_ref = colData(sce))
egm = batch_correct(egm,
varname_cell_type = "celltype_global",
n_pseudo_bulk=10) # for saving time I just generate 10 pseudo-bulk samples
Sat Dec 25 11:32:53 2021 Reference is from Single Cell RNA-seq, doing batch correction in S mode.
Sat Dec 25 11:32:53 2021 Generating pseudo bulk...
Sat Dec 25 11:32:54 2021 Doing ComBat...
Found 1133 genes with uniform expression within a single batch (all zeros); these will not be adjusted for batch.
Found2batches
Adjusting for0covariate(s) or covariate level(s)
Standardizing Data across genes
Fitting L/S model and finding priors
Finding parametric adjustments
Adjusting the Data
Sat Dec 25 11:32:55 2021 Restore reference...
you could check our data right here to see any different with your data. Our data and run example is right here (data: https://github.com/WWXkenmo/ENIGMA/tree/master; code: https://htmlpreview.github.io/?https://github.com/WWXkenmo/ENIGMA/blob/master/vignettes/ENIGMA_toy2.html) I think the following point you need to pay attention
- Do your sce object have sample id (cell barcode infor)
head(colData(sce))
DataFrame with 6 rows and 1 column
celltype_global
<character>
AAACCTGAGTAACCCT_13 B_cell
AAACCTGCAACGATGG_13 Myeloid
AAACCTGCATTAGCCA_13 Myeloid
AAACCTGGTCCATGAT_13 T cell
AAACCTGTCCTGTACC_13 Myeloid
AAACGGGCAAGAAAGG_13 Myeloid
- Do your reference single cell data contains the major cell types but not includes any rare celltype (<1%)
table(colData(sce))/nrow(colData(sce))
B_cell EC Fibro Myeloid T cell Tumor
0.11551043 0.03350254 0.05561196 0.22470389 0.41534123 0.15532995
I hope you could return those information to me or you could give me a toy data (subset of your dataset) as I can't see the details of your dataset to help me fix the potential bugs.
Thx again for using our tool, any suggestions are valuable and welcome!
Best, Ken
Hi, Thanks for your response. I've been looking at the code and I think the source of the error is in the R function S_mode_correction.R
between line 46-50. Perhaps after normalisation in a row it becomes all zero again. I know that does not sound likely, but after adding this line frac <- frac[rowSums(frac)>0,]
after normalization, it seems to have solved the error. If I encounter it again, I'll send you a toy data.
Nurun