Last active
April 17, 2018 12:35
-
-
Save FloWuenne/dfd1e00c198b2ae1adeb16720a844441 to your computer and use it in GitHub Desktop.
Create .Rdata file from Seurat object for clustering module of shiny server (for .Rdata)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(dplyr) | |
| library(tidyr) | |
| time_point <- readline(prompt="Enter time point: ") | |
| ## Load Seurat object | |
| seurat_object <- readRDS(paste("../Objects/",time_point,".Seurat_object.Rds",sep="")) | |
| ## Normalized expression data | |
| norm_exprs_sparse <- seurat_object@data | |
| norm_exprs_matrix <- as.matrix(seurat_object@data) | |
| norm_exprs_df <- as.data.frame(norm_exprs_matrix) | |
| ## Create a new data frame that contains tSNE embeddings and cluster identities | |
| tsne_mappings <- seurat_object@dr$tsne@cell.embeddings | |
| cell_identities <- data.frame(seurat_object@ident) | |
| rownames(cell_identities) <- names(seurat_object@ident) | |
| tsne_mappings <- merge(tsne_mappings,cell_identities,by=0,all=TRUE) | |
| rownames(tsne_mappings) <- tsne_mappings$Row.names | |
| tsne_mappings <- tsne_mappings %>% | |
| select(-Row.names) | |
| ## Metadata information | |
| metadata <- seurat_object@meta.data | |
| save(norm_exprs_df,tsne_mappings,metadata, | |
| file=paste("../Shiny_server_data/Clustering.",time_point,".RData",sep="")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment