Home Install User Guide Python Notebook API FAQ

Import Seurat Object (R Studio)

Seuratexport.R

You can load a completed analysis stored in R seurat object into MongoDB step 1: export results from Seurat Object

In [ ]:
library(Seurat)

export counts data from seurat object

In [ ]:
pbmc <- readRDS(file = "../data/pbmc3k_final.rds");
d <- as.matrix(pbmc@assays$RNA@counts); 
umap <- pbmc@reductions$umap@cell.embeddings

export cell annotation information

In [ ]:
annotation <- pbmc@meta.data
coord <- transform(merge(umap,annotation,by="row.names",all=TRUE), row.names=Row.names, Row.names=NULL)

add cell type name from seurat object

In [ ]:
celltype=Idents(pbmc)
coord <- cbind(coord,celltype)

select the types of annotation

In [ ]:
coord <- coord[,c("seurat_clusters","celltype")]

create Single Cell Explorer map information; the following information can be added here or from python notebook

In [ ]:
mapType="umap";
mapName='pmbc10k_health_tSNE';  
study="Baseline";
subjectid="";
disease="Healthy";
source="10XGenomic";
sample="Blood";
comment="from seurat";
author="demo";
mapinfo <- c(study,subjectid,disease,source,sample,comment,author)

save all the results in three csv files

In [ ]:
write.csv(d,"counts.csv")
write.csv(coord,"coords.csv")
write.csv(mapinfo, "mapinfo.csv")