dviraran / SingleR

SingleR: Single-cell RNA-seq cell types Recognition (legacy version)
GNU General Public License v3.0
271 stars 98 forks source link

SingleR.PlotTsne #57

Open mnovalri opened 5 years ago

mnovalri commented 5 years ago

Hi, Thank you so much for developing this great package. I do have a small issue and I'm not able to figure out what I'm doing wrong. I was wondering if could provide me some advices.
I'm creating my Single.R object but when I try to plot the Tsne I get this error:

Error in $<-.data.frame(*tmp*, "x", value = c(AAACCCAAGAGAGGTA = -19.7122580813558, : replacement has 7632 rows, data has 0

Here is the code I'm using: data<-Read10X(data.dir = '~/Dropbox/R_Single_cell/AA_Single_cell/filtered_gene_bc_matrices_LCWE')

singler = CreateSinglerObject(counts=data, annot = NULL, project.name="LCWE", min.genes = 0, technology = "10X", species = "Mouse", citation = "", ref.list = list(), normalize.gene.length = F, variable.genes = "de", fine.tune = F, do.signatures = F, clusters = NULL, do.main.types = T, reduce.file.size = T, numCores = SingleR.numCores)

LCWE<-readRDS("~/Dropbox/R_Single_cell/AA_Single_cell/LCWE_tsne_final.rds") singler$seurat = LCWE singler$meta.data$orig.ident = LCWE@meta.data$orig.ident singler$meta.data$xy = LCWE@reductions$tsne@cell.embeddings # the tsne coordinates singler$meta.data$clusters = LCWE@active.ident

save the SingleR object

save(singler,file='singler_object_LCWE.RData')

Plot Tsne

out <- SingleR.PlotTsne(singler, singler$meta.data$xy, score.thres = 0, clusters = NULL, do.letters = TRUE, dot.size = 1, do.labels = FALSE, do.legend = TRUE, label.size = 3, title = "", colors = singler.colors, font.size = NULL, alpha = 0.5)

Although, when i do the heatmap, it works really nicely.

heatmap

SingleR.DrawHeatmap(singler$singler[[2]]$SingleR.clusters,clusters = c(row.names(singler$singler[[2]]$SingleR.clusters$scores)),order.by.clusters=T, fontsize_row=15,cells_order=c(row.names(singler$singler[[2]]$SingleR.clusters$scores)))

Thank you, M

dviraran commented 5 years ago

Thank you for your kind words.

The first field in SingleR.PlotTsne should be singler$singler[[i]]$SingleR.single, just like in the DrawHeatmap function. I understand it is not intuitive, and hopefully will find time to adjust the whole code to work with the S4 object (that is now only supported in the online viewer), which will make it much easier to work with.

mnovalri commented 5 years ago

Thank you so much! I managed to make it work. I realized that I was filtering our features in when I was generating my Seurat object. There was a discrepancy between the numbers of "cells" in the SingleR object and the numbers of samples in the Seurat object. Fixing that plus your correction made it work. Thank you, M