Irrationone / cellassign

Automated, probabilistic assignment of cell types in scRNA-seq data
Other
191 stars 79 forks source link

length(s) == nrow(Y) is not TRUE #57

Closed olechnwin closed 4 years ago

olechnwin commented 4 years ago

Hi, I got the following error when running cellassign:

Error in cellassign(exprs_obj = sce, marker_gene_info = bone.markers.mat,  :
  length(s) == nrow(Y) is not TRUE

I thought this error is related to the number of rows in my exprs_obj and the s cellsize factor, but they are equal:

length(s)
[1] 17
> nrow(sce)
[1] 17

This is my code to run cellassign, where I convert the Seurat object to sce then subset the expression to be only the markers.

# creating markers gene variable
tmp <- read.table("../MSC Ob markers_v2.txt",sep="\t",header=TRUE,
 stringsAsFactors = FALSE)
tmp.lst =as.list(tmp)
bone.markers=NULL
bone.markers$symbol=tmp.lst
bone.markers.mat <- marker_list_to_mat(bone.markers$symbol)
sample.name="OS17.culture"
# raw gene expression for all bone.markers in each cluster
os17.CAinput <- subset(alldata.filt2.list[[sample.name]],features=
  rownames(bone.markers.mat))
# convert to singlecellexpreriment object
sce <- as.SingleCellExperiment(os17.CAinput,assay = "RNA")
# compute sum factor using entire assay
sce.sf <- as.SingleCellExperiment(alldata.filt2.list[[sample.name]],assay="RNA")
s=computeSumFactors(sce.sf)
# subsetting s for only bone.markers for inpu to cellassign(CA)
s=s[rownames(s) %in% rownames(bone.markers.mat),]
fit <- cellassign(exprs_obj = sce, 
 marker_gene_info = bone.markers.mat, 
 s = s, 
 learning_rate = 1e-2, 
 shrinkage = TRUE,
 verbose = FALSE)

I tried to run the code in cellassign.R one-by-one but strangely it won't find extract_expression_matrix Thank you in advance for your help

olechnwin commented 4 years ago

Never mind. I figured it out. My bad. s is the size factor duh! so I should have this: s=sizeFactors(computeSumFactors(sce.sf)) and deleted this line: s=s[rownames(s) %in% rownames(bone.markers.mat),]