MuSiC
MuSiC copied to clipboard
Error music_basis and music_prop: Error in h(simpleError(msg, call)) : error in evaluating the argument 'i' in selecting a method for function '[': 'x' must be an array of at least two dimensions
Hi,
I am having the following error when I run both music_basis
and music_prop
functions:
Error in h(simpleError(msg, call)) :
error in evaluating the argument 'i' in selecting a method for function '[': 'x' must be an array of at least two dimensions
If I try with the example data it works but when I use my data it does not.
Here is my code:
sc.basis <- music_basis( x=sce, non.zero = TRUE, markers = NULL, clusters='cellType',samples='sampleID', select.ct = NULL )
Est.prop <- music_prop(bulk.mtx = bulk.m, sc.sce = sce, clusters = 'cellType', samples = 'sampleID', select.ct = c("Epithelial cells", "Fibroblasts" , "Macrophages" ,"T cells" , "Endothelial cells" ,"Stroma cells" , "Neutrophils" ), markers= NULL)
The sce looks like this:
>sce
class: SingleCellExperiment
dim: 32845 7958
metadata(0):
assays(1): counts
rownames(32845): Xkr4 Gm1992 ... Trbj2.5 Vamp9
rowData names(0):
colnames(7958): 678478_1 791068_1 ... 820364_2 458736_2
colData names(2): sampleID cellType
reducedDimNames(0):
mainExpName: NULL
altExpNames(0):
The bulk.m:
>head(bulk.m)
noise_expression_fresh noise_expression_24h
0610009B22Rik 1.268665e-04 1.807174e-04
0610010F05Rik 1.014932e-04 1.161755e-04
0610030E20Rik 6.343326e-05 1.549007e-04
0610037L13Rik 6.343326e-05 9.035872e-05
0610040B10Rik 0.000000e+00 1.290839e-05
0610040J01Rik 1.649265e-04 1.290839e-04
> class(bulk.m)
[1] "matrix" "array"
>dim( bulk.m)
[1] 10136 2
> str( bulk.m)
num [1:10136, 1:2] 1.27e-04 1.01e-04 6.34e-05 6.34e-05 0.00 ...
- attr(*, "dimnames")=List of 2
..$ : chr [1:10136] "0610009B22Rik" "0610010F05Rik" "0610030E20Rik" "0610037L13Rik" ...
..$ : chr [1:2] "noise_expression_fresh" "noise_expression_24h"
I think the problem is in the single cell cause when I use the example bulk RNA provided I get the same problem, but if I use my bulk but the example sc data it says "Too few common genes!".
Any guidance on how to solve the error would be much appreciated!
Thanks, Yolanda
Hi! I've been dealing with a similar problem for a couple of days, so I hope the way I went around it works for you.
I got the same error in any music_basis
/music_prop
/music2_prop
as you did when the SCE contained only one value in the samples variable. In my case, I was testing a 1-donor version of a 4-donor dataset when this showed up. So check the data in the sce column that corresponds to your samples
parameter in the function call.
I went through the code in music_basis
and I think it makes sense because the creation of the S
matrix expects somehow both samples and celltypes to compute the relative abundances.
Anyhow, is MuSiC intended for 1 sample datasets?
So, I went for the full dataset and the "Too few common genes!" problem also appeared. I checked: my data have some 30000 genes present in both bulk and single-cell datasets. I think I solved partially the problem with this piece of code, which basically, subsets and resorts the data to common genes:
c.genes <- sort(intersect(rownames(control.mtx), rownames(sce)))
sce <- sce[c.genes,]
control.mtx <- as.matrix(control.mtx[c.genes,])
# case.mtx <- as.matrix(case.mtx[c.genes,])
dim(sce)
dim(control.mtx)
# dim(case.mtx)
Now, the Too few common genes!
error is gone, though I think this could/should be fixed in the package itself, no?
PS: music2_prop
is still complaining about non-conformable arrays, but I don't think it's related to these problems.
Error in MOD0 + mod0: non-conformable arrays