dgrun / StemID

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

Seurat object for StemID score evaluation #3

Closed Dragonmasterx87 closed 4 years ago

Dragonmasterx87 commented 4 years ago

Hello!

Thank you for the wonderful software. I have a question, is it possible to run STEMID calculations for a Seurat object? I would like to calculate STEMID scores of clusters of cells that have been already calculated and projected using UMAP.

Thank you!

dgrun commented 4 years ago

Hi,

please run the following code on your data in order to apply StemID on Seurat output:

input data: ndata (matrix with genes as rows and cells as columns)

1.Run RaceID (control cell filtering with mintotal, i.e. total UMI count

per cell) -> sc object

2.Run Seurat with filtering such that the same cells are retained

3.Re-initialize RaceID output with Seurat data:

part <- as.numeric(se@meta.data$seurat_clusters) d <- as.matrix( dist(se@reductions$pca@cell.embeddings) ) tsne <- as.data.frame(se@reductions$tsne@cell.embeddings) names(part) <- colnames(d)

n <- colnames(sc@ndata) part <- part[n]

partition

sc@cpart <- sc@cluster$kpart <- part

distances

sc@distances <- d[n,n]

tsne

sc@tsne <- tsne[n,]

expression data (optional)

sc@counts <- sc@counts * 0 + 1 sc@ndata <- ndata[,n]

cluster medoids

sc@medoids <- compmedoids(sc, sc@cpart)

colors for clusters

set.seed(12345) sc@fcol <- sample(rainbow(max(sc@cpart)))

4. Now, you can run StemID on the sc object, ideally with default

parameters…

Good luck! Dominic

On Fri, Oct 11, 2019 at 7:44 PM Fahd Qadir notifications@github.com wrote:

Hello!

Thank you for the wonderful software. I have a question, is it possible to run STEMID calculations for a Seurat object? I would like to calculate STEMID scores of clusters of cells that have been already calculated and projected using UMAP.

Thank you!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/dgrun/StemID/issues/3?email_source=notifications&email_token=ACVD55DGIFDY5D7M4R7JGYLQOC3O3A5CNFSM4I74RNVKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HRITKVA, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACVD55E34ANELDE2GYUMAS3QOC3O3ANCNFSM4I74RNVA .

Dragonmasterx87 commented 4 years ago

Cheers thanks alot Dominic!

raveancic commented 4 years ago

Dear all,

I am trying to run StemID on my Seurat object on which I have done both the QC needed and the clustering analysis. I am following both the answer here and the tutorial here: https://cran.r-project.org/web/packages/RaceID/vignettes/RaceID.html.

Unfortunately I meet the following error:

Error in array(x, c(length(x), 1L), if (!is.null(names(x))) list(names(x),  : 
  'data' must be of a vector type, was 'NULL'

when I perform the comppvalue step.

Here is all the code I am running:


# Create the sc object
ndata <- seurat_integrated@assays$SCT@counts[,]

sc <- SCseq(ndata)

# Filter for this
sc <- filterdata(sc, mintotal = 2000)

# Re-initialize raceID
part <- as.numeric(seurat_integrated@meta.data$seurat_clusters)
d <- as.matrix(dist(seurat_integrated@reductions$pca@cell.embeddings))
umap <- as.data.frame(seurat_integrated@reductions$UMAP@cell.embeddings)
names(part) <- colnames(d)

n <- colnames(sc@ndata)
part <- part[n]

# partition
sc@cpart <- sc@cluster$kpart <- part
# distances
sc@distances <- d[n,n]
# umap
sc@umap <- umap[n,]
# expression data (optional)
sc@counts <- sc@counts * 0 + 1
sc@ndata  <- ndata[,n]
# cluster medoids
sc@medoids <- compmedoids(sc, sc@cpart)

col_cluster <- colorRampPalette(brewer.pal(12,"Set3"))(length(unique(seurat_integrated@meta.data$seurat_clusters)))
names(col_cluster) <- as.character(unique(seurat_integrated@meta.data$seurat_clusters))

set.seed(12345)
sc@fcol <- col_cluster[order(as.numeric(names(col_cluster)))]

# Run StemID

ltr <- Ltree(sc)

ltr <- compentropy(ltr)
ltr <- projcells(ltr,cthr=5,nmode=TRUE,fr=TRUE, um=T, knn=3)

ltr <- lineagegraph(ltr)

ltr <- comppvalue(ltr,pthr=0.05)
# Here I get the error

plotgraph(ltr,showCells=FALSE,showMap=TRUE)

x <- compscore(ltr)

Can anyone help me on this? I really thank you in advance for this, Have a great day, Alessandro

Fatemeh99m commented 3 months ago

Dear all, Hi. I want to use stemID for my seurat object and I followed the workflow the @dgrun mentioned. Thanks for your explanation. I faced an error while running :

ltr <- comppvalue(ltr,pthr=0.05) Error in h(simpleError(msg, call)) : error in evaluating the argument 'x' in selecting a method for function 't': 'n' must be a positive integer >= 'x'

My seurat object contain about 5200 cells.

dgrun commented 3 months ago

Please send sample data with code to reproduce the error and I can try to help.