numbat
numbat copied to clipboard
```run_numbat()``` error unclear
I am trying to use the run_numbat()
function and am running into an error:
Error in h(simpleError(msg, call)) :
error in evaluating the argument 'x' in selecting a method for function 'which': 'x' must be an array of at least two dimensions
Not sure if it is my count matrix (a dgCMatrix) or something else as the error does not specify. My data structure is shown here.
> str(count_mat)
Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
..@ i : int [1:2386588] 53 170 186 204 216 237 362 370 386 438 ...
..@ p : int [1:1379] 0 1151 2410 3388 5426 5963 6947 9501 11006 16016 ...
..@ Dim : int [1:2] 36601 1378
..@ Dimnames:List of 2
.. ..$ : NULL
.. ..$ : NULL
..@ x : num [1:2386588] 1 1 1 1 1 1 1 1 1 2 ...
..@ factors : list()
> str(df_allele)
'data.frame': 206646 obs. of 11 variables:
$ cell : chr "ACATTTCAGATTTGCC-1" "CAAAGAATCCAACTAG-1" "CCCATTGTCACCATCC-1" "CTCATCGAGCTTGTTG-1" ...
$ snp_id: chr "1_779047_G_A" "1_779047_G_A" "1_779047_G_A" "1_779047_G_A" ...
$ CHROM : int 1 1 1 1 1 1 1 1 1 1 ...
$ POS : int 779047 779047 779047 779047 779047 779047 779047 779047 779047 779047 ...
$ cM : num 0 0 0 0 0 0 0 0 0 0 ...
$ REF : chr "G" "G" "G" "G" ...
$ ALT : chr "A" "A" "A" "A" ...
$ AD : int 1 1 0 1 0 1 0 0 0 0 ...
$ DP : int 1 1 1 1 1 1 1 1 1 1 ...
$ GT : chr "0|1" "0|1" "0|1" "0|1" ...
$ gene : chr "" "" "" "" ...
>
@teng-gao can you help advise on this issue? thanks.
This error ('x' must be an array of at least two dimensions
) could be to do with the gene x cell count matrix file. The only difference between the one on the numbat example and my one is the Dimnames
slot where the example data has genes and barcodes and mine does not. However I ran cellranger in the standard way so why would my mtx file not have this? Do you know if this is the issue causing the error and how can I get around this?
I read in my count mat file 2 ways and both dont have the dimnames slot.
mtx <- as(Matrix::readMM("~/outs/filtered_feature_bc_matrix/matrix.mtx"), "dgCMatrix")
count_mat1 <- Matrix::readMM("~/outs/filtered_feature_bc_matrix/matrix.mtx")
two count mat datasets, the first is the numbat example
> str(count_mat_ATC2)
Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
..@ i : int [1:754228] 21 22 26 27 39 43 53 54 55 66 ...
..@ p : int [1:174] 0 6171 11532 17700 23887 27738 33726 39027 45642 52144 ...
..@ Dim : int [1:2] 33538 173
..@ Dimnames:List of 2
.. ..$ : chr [1:33538] "MIR1302-2HG" "FAM138A" "OR4F5" "AL627309.1" ...
.. ..$ : chr [1:173] "ATC2_AACCACAGTCCATCTC-1" "ATC2_AAGACAAGTTAGAAGT-1" "ATC2_AAGCGTTTCGAGCCTG-1" "ATC2_ACAAGCTAGCATGATA-1" ...
..@ x : num [1:754228] 2 1 1 7 2 2 8 1 6 6 ...
..@ factors : list()
> str(count_mat)
Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
..@ i : int [1:2386588] 53 170 186 204 216 237 362 370 386 438 ...
..@ p : int [1:1379] 0 1151 2410 3388 5426 5963 6947 9501 11006 16016 ...
..@ Dim : int [1:2] 36601 1378
..@ Dimnames:List of 2
.. ..$ : NULL
.. ..$ : NULL
..@ x : num [1:2386588] 1 1 1 1 1 1 1 1 1 2 ...
..@ factors : list()
@teng-gao
Hi, @cathalgking ,
I got the same error and solve it by add colnames and rownames to the matrix.
..@ Dimnames:List of 2
.. ..$ : NULL
.. ..$ : NULL
Nelson
Hi @zezhuo Thanks so much for your message. Can you show me an example of how you did that? Did you do it in R?
Yes. Below are the scripts for your reference.
# Get count matrix
DefaultAssay(L07V) <- "Spatial"
count_mat <- L07V@assays$Spatial@layers$counts
rownames(count_mat) <- rownames(L07V)
colnames(count_mat) <- colnames(L07V)
I got the same error and solve it by add colnames and rownames to the matrix.
Unfortunately this did not resolve the issue for me. Still getting it with Dimnames assigned.