dgrun / StemID

Algorithm for the inference of cell types and lineage trees from single-cell RNA-seq data.
39 stars 19 forks source link

Error about projcells #7

Closed TuoCai2000 closed 7 months ago

TuoCai2000 commented 7 months ago

Hi, thank you for developing StemID! I tried to run StemID on my seurat object following the closed issues. However, it errors when I run the code:

 ltr <- projcells(
  object = ltr,
  cthr=5
)
Error in `.rowNamesDF<-`(x, value = value) : invalid 'row.names' length

I will appreciate a lot if you help me! Thank you very much!

dgrun commented 7 months ago

Did you make sure your input object for the RaceID analysis had unique row names (genes) and column names (cells)? If this is the case, I'd need sample code reproducing the error.

TuoCai2000 commented 7 months ago

Hi! Thank you so much! I have sent my code and data to the email: StemID@noreply.github.com,I will appreciate a lot if you help me !

dgrun commented 7 months ago

Not sure that works. Please send to me directly and I can see what I can do: dominic.gruen@uni-wuerzburg.de Ideally, send small sample data.

dgrun commented 7 months ago

I ran your code.

Please install the RaceID package from CRAN, instead of sourcing the R file from this repo.

Also, there is no need to convert ndata to a data.frame: ndata <-hspc@assays$RNA@counts)

I also recommend computing the distance matrix in PCA space instead of in UMAP space. UMAP distances can be meaningless or at least very distorted.

require(RaceID) library(Seurat) hspc=readRDS("hspc.rds") ndata <-hspc@assays$RNA@counts sc <- SCseq(ndata) sc <- filterdata( object = sc, mintotal = 500 ) part <- as.numeric(hspc@meta.data$RNA_snn_res.0.255) d <- as.matrix(dist(hspc@reductions$umap@cell.embeddings)) umap <- as.data.frame(hspc@reductions$umap@cell.embeddings) names(part) <- colnames(d) n <- colnames(sc@ndata) part <- part[n] sc@cpart <- sc@cluster$kpart <- part sc@distances <- d[n,n] sc@tsne <- umap[n,] sc@medoids <- compmedoids(sc, sc@cpart) ltr <- Ltree(sc) ltr <- compentropy(ltr) ltr <- projcells( object = ltr, cthr=5, # use clusters with at least this many cells nmode=TRUE # use knn )