xuranw / MuSiC

Multi-subject Single Cell Deconvolution
https://github.com/xuranw/MuSiC
GNU General Public License v3.0
231 stars 92 forks source link

Problems with bulk_construct #74

Open bieniu777 opened 3 years ago

bieniu777 commented 3 years ago

Hello,

I am using the code given in the tutorial to calculate real proportions of cells but I am getting an error. First I create an ExpressionSet from a Seurat object.

CZbiohub.eset <- ExpressionSet(
  assayData = cpm(as.matrix(Czbiohub.filtered@assays$RNA@counts)),
  phenoData = new("AnnotatedDataFrame",
                  data = Czbiohub.filtered@meta.data)
)

CZbiohub.construct = bulk_construct(CZbiohub.eset, clusters = 'Meta_Lineage', samples = 'All_sample_ID')
CZbiohub.construct$prop.real = relative.ab(CZbiohub.construct$num.real, by.col = FALSE)

Error in rowSums(X) : 'x' must be numeric

When I inspect the Czbiohub.construct object and see how "num.real" looks like - it's a list of three elements: Length, Class and Mode. I do have some numbers in Length but I can only see "character" repeated in both Class and Mode, and not my cell types (that is what my Meta_Lineage is).

When I run this: table(CZbiohub.eset@phenoData@data$Meta_Lineage)

everything seems fine and I can see my Cell types and the number of cells - so the metadata seems fine.

I would appreciate any info on what the problem might be here and how to fix it.

BW

ladyjkalx commented 2 years ago

I also had this problem and pinpointed it to this line in the code: ctdf = ddply(mdf, samples, function(x){ summary(x[, clusters]) })

ddply/summary was not working correctly. I played around with it a bit but then gave up and wrote a work-around function, replacing the above line with a dplyr::summarise equivalent.

RO