satijalab / seurat

R toolkit for single cell genomics
http://www.satijalab.org/seurat
Other
2.24k stars 902 forks source link

Error in `[<-.data.frame`(`*tmp*`, , i, value = new("Seurat", assays = list( : replacement has xx rows, data has xxxx #3708

Closed Yale73 closed 3 years ago

Yale73 commented 3 years ago

Hi Seurat team,

Recently when I created the Seurat object from ADT data, I ran an issue,

Skin149[["ADT"]] <- CreateSeuratObject(counts = Skin149.data$"Antibody Capture")
Error in `[<-.data.frame`(`*tmp*`, , i, value = new("Seurat", assays = list( : 
  replacement has 24 rows, data has 3834

I used to run this code and never meet this problem. I think because of the data matrix, therefore I reverse the DataMatrix. I created the object, but it is not under the assays but under meta.data. Skin149[["ADT"]] <- CreateSeuratObject(counts = t(as.data.frame(Skin149.data$"Antibody Capture"))) image

Can you help me fix it?

Thanks, Yale

yuhanH commented 3 years ago

It seems that you want to add an ADT assay to the object rather than CreateSeuratObject Try CreateAssayObject. Skin149[["ADT"]] <- CreateAssayObject(counts = Skin149.data$"Antibody Capture") If not work, I will reopen the issue

Yale73 commented 3 years ago

It's caused by the R version. I can run it under R 3.6.0, rather than 4.0.2.

Thanks, Yale

ALASKAAAAAAAAA commented 1 year ago

Error in [<-.data.frame(tmp, , i, value = new("Seurat", assays = list( : replacement has xx rows, data has xxxx

Hi, I am getting the same error while using Seurat package RenameIdents function, can you help me fix it?

sce.mergeTEN <- RenameIdents(sce.mergeTEN, "0"="Endothelial", "1"="Epithelial", "2"="T/NK", "3"="Pericytes", "4"="T/NK", "5"="Fibroblast", "6"="Epithelial", "7"="Epithelial", "8"="Pericytes", "9"="Epithelial", "10"="Epithelial", "11"="B", "12"="Epithelial", "13"="Myeloid", "14"="Plasma_B", "15"="Endothelial", "16"="Endothelial", "17"="Fibroblast", "18"="MAST", "19"="Epithelial", "20"="Endothelial", "21"="Endothelial", "22"="T/NK", "23"="Myeloid", "24"="T/NK", "25"="Endothelial", "26"="Epithelial", "27"="T/NK", "28"="Myeloid", "29"="Neuron", "30"="T/NK", "31"="Doublets", "32"="Doublets")

Error in[<-.data.frame(tmp, , i, value = new("Seurat", assays = list( : replacement has 36601 rows, data has 14631

dionne099 commented 7 months ago

Hi,

I tried to use @yuhanH suggestion above but got an error. I want to add a chromatin assay as such: sub_FJ_2[["ATAC"]] <- CreateAssayObject(counts = FI_sub_2$"ChromatinAssay")

FI_sub_2 is a chromatin assay but I get this error saying it is not. I am using R v.4.2.1