Merge branch 'master' of github.com:mojaveazure/loomR
authorPaul Hoffman <phoffman@nygenome.org>
Tue, 31 Oct 2017 23:24:51 +0000 (19:24 -0400)
committerPaul Hoffman <phoffman@nygenome.org>
Tue, 31 Oct 2017 23:24:51 +0000 (19:24 -0400)
R/loom.R

index a330526b1674b34b4b37ffab4d061fdf9b73e8f4..c5515c6af1bfd766ac346398f15ab46d666a7bf4 100644 (file)
--- a/R/loom.R
+++ b/R/loom.R
@@ -475,6 +475,20 @@ connect <- function(filename, mode = "r") {
   return(new.loom)
 }
 
+CreateLoomFromSeurat <- function(object, filename) {
+  object.data=t(object@raw.data[rownames(object@data),object@cell.names])
+  object.meta.data=object@meta.data
+  row_attrs=list(); col_attrs=list()
+  gene.names=colnames(object.data)
+  object.meta.data$ident = object@ident
+  object.meta.data$CellID = object@cell.names
+  for(i in 1:ncol(object.meta.data)) {
+    col_attrs[[colnames(object.meta.data)[i]]]=object.meta.data[,i]
+  }
+  row_attrs[["Gene"]]=gene.names
+  create(filename,object.data,gene.attrs = row_attrs, cell.attrs = col_attrs)
+}
+
 #need to comment
 #need to add progress bar
 #but otherwise, pretty cool