Closed gt7901b closed 4 years ago
Hi,
make.obj
function only takes data frame (expression matrix) files to make an iCellR object.
For Seurat objects, here is how to do it:
objectName = seurat.obj
my.data <- as.data.frame(as.matrix(objectName@assays$RNA@data))
myUMAP <- as.data.frame(objectName@reductions$umap@cell.embeddings)
myPCA <- as.data.frame(objectName@reductions$pca@cell.embeddings)
my.obj <- make.obj(my.data)
my.obj@main.data <- my.obj@raw.data
my.obj@umap.data <- myUMAP
my.obj@pca.data <- myPCA
If you did the above, your iCellR object only has the expression matrix, UMAP and PCA data from your Seurat object.
You can add more data from Seurat to iCellR object just like above (e.g. tSNE, clusters, etc.).
Use slotNames(iCellR.obj) #or slotNames(Seurat.obj)
slot names function to see which ones you need and simply take from one and put into the other as shown above. Or just add the matrix file and do the rest of the analysis in iCellR.
Note that the conditions in iCellR are in the column.names
(the barcodes also called cell ids). So if you have multiple samples make sure you fix this too.
I recommend re-running your analysis using iCellR for less complications.
Reza
Thank you so much for your reply. I will give it a try.
Hi:
As a follow-up to this issue, how do you add the Seurat IDs to the slot names? For example, when I run the following:
my.data <- as.data.frame(as.matrix(seurat.obj@assays$RNA@data))
myUMAP <- as.data.frame(seurat.obj@reductions$umap@cell.embeddings)
myPCA <- as.data.frame(seurat.obj@reductions$pca@cell.embeddings)
dim(my.data)
dim(myUMAP)
dim(myPCA)
head(my.data)[1:5]
head(myUMAP)
Cond <- (seurat.obj@meta.data$orig.ident)
Cond <- gsub("-",".",Cond)
Cond <- gsub("_",".",Cond)
MyCols <- row.names(myUMAP)
MyCols <- gsub("-",".",MyCols)
MyCols <- gsub("_",".",MyCols)
MyCols <- paste0(Cond,"_",MyCols,sep="")
colnames(my.data) <- MyCols
rownames(myPCA) <- MyCols
rownames(myUMAP) <- MyCols
icellr.obj <- make.obj(my.data)
icellr.objj@main.data <- icellr.objj@raw.data
icellr.obj@umap.data <- myUMAP
icellr.obj@pca.data <- myPCA
icellr.obj <- run.pc.tsne(icellr.obj, dims = 1:10)
MyClust <- icellr.obj@metadata$seurat_clusters
MyClust <- as.numeric(MyClust)
MyClust <- as.numeric(MyClust)
unique(MyClust)
it returns
numeric(0)
Because of this, when I run
MyClust <- as.data.frame(MyClust)
colnames(MyClust) <- "clusters"
rownames(MyClust) <- rownames(myPCA)
I receive Error in
.rowNamesDF<-(x, value = value) : invalid 'row.names' length
I checked the slotNames for both the icellr and Seurat object and the metadata for the icellr object is empty. How do I assign the meta.data from the Seurat object to the new icellr metadata slotName?
Hi:
I tried to convert a Seurat object to iCellR object with the command my.obj <- make.obj(seurat.obj) but got the following error. What is the reason?
Thanks in advance
Error in dimnames(x) <- dn: 'dimnames' applied to non-array Traceback:
row.names<-
(*tmp*
, value = gsub("-", ".", row.names(x)))row.names<-.default
(*tmp*
, value = gsub("-", ".", row.names(x)))rownames<-
(x, value)