I have a count matrix named "metadata_marker", it is a sparse matrix. I want to make a Seurat object of it.
then Find marker genes for two different cell type like "CM" and "FB".
here is my code:
install.packages(c("Seurat", "Matrix"))
library(Seurat)
library(Matrix)
filtered_final_data_marker <- final_data_marker
filtered_final_data_marker <- as((as.matrix(filtered_final_data_marker)), "sparseMatrix")
seurat_obj <- CreateSeuratObject(counts = filtered_final_data_marker, assay = "RNA", names.field = 1, names.delim = "_", meta.data = metadata_marker)
markers <- FindMarkers(seurat_obj, ident.1 = "CM", ident.2 = "FB" , assay = "RNA", test.use = "wilcox", logfc.threshold = 0.1)
When I run the last line it shows this error:
Warning: No layers found matching search pattern provided
Error in h(simpleError(msg, call)) :
error in evaluating the argument 'x' in selecting a method for function 'rowSums': subscript out of bounds
In addition: Warning messages:
1: Layer ‘data’ is empty
2: Layer ‘data’ is empty
for more information,
head(metadata_marker)
celltype donor condition
1 CM H5 Healthy
2 CM H5 Healthy
3 CM H5 Healthy
4 CM H5 Healthy
5 CM H5 Healthy
6 CM H5 Healthy
it has 615 rows
and
head(filtered_final_data_marker[1:3,1:3])
CM_H5_hca_Healthy_1 CM_H5_hca_Healthy_2 CM_H5_hca_Healthy_3
MIR1302-2HG 0 0 0
FAM138A 0 0 0
OR4F5 0 0 0
dim of it is 33555*615
Is there anyone who knows how to fix it?
thanks in advance.