Convert loom file to Seurat
2
0
Entering edit mode
5.9 years ago
mxs1489 • 0

Hello- I am trying to convert an available loom file to Seurat. The convert documentation seems to support conversion to/from loom but I am having difficulty getting it to work. Any help would be greatly appreciated!

hdf5r is updated (hdf5r_1.0.1); loomR is updated (loomR_0.2.0). (see below for complex session info)

Here is the command followed by the error:

S_object <- Convert(from= lfile, to= "seurat")
`Error in UseMethod(generic = "Convert", object = from) :
no applicable method for 'Convert' applied to an object of class "c('loom', 'H5File', 'H5RefClass', 'R6')"



sessionInfo()
R version 3.5.2 (2018-12-20)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Mojave 10.14.2

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] splines stats4 parallel stats graphics grDevices utils
[8] datasets methods base

other attached packages:
[1] loomR_0.2.0 itertools_0.1-3 iterators_1.0.10
[4] hdf5r_1.0.1 R6_2.3.0 monocle_2.10.0
[7] DDRTree_0.1.5 irlba_2.3.2 VGAM_1.0-6
[10] Biobase_2.42.0 BiocGenerics_0.28.0 bindrcpp_0.2.2
[13] Seurat_2.3.4 Matrix_1.2-15 cowplot_0.9.3
[16] ggplot2_3.1.0
Seurat loom loomr • 9.3k views
ADD COMMENT
0
Entering edit mode

have you found the solution?

ADD REPLY
0
Entering edit mode

I have Seurat v3, and there it says: "Converting to and from loom files is currently unavailable; we are working on restoring this functionality" -- not sure if that broke down in the version you're using, but my suspicion is that it's probably an incompatibility with the loomR package

ADD REPLY
0
Entering edit mode

yes, I also use Seurat v3.I see that:seurat offers a conversion function to go from Seurat objects to loom files. The reverse conversion is currently in progress..Do you know that when they will restore this functionality? I need to merge my seurat data with the data provided by loom edition(http://mousebrain.org/tissues.html).But I don't know how to convert this loom file to seurat object, so that I can merge them with my own data and do next analysis. I tried to get the matrix and meta data from loom file,and use them to create seurat object,but I failed to get metadata from loom either.

ADD REPLY
0
Entering edit mode

The cellRanger output should also contain the matrix, which can be read in with Seurat's read10X() function

ADD REPLY
0
Entering edit mode

How do you know that converting to and from loom files is currently unavailable?Did you ask the seurat team?

ADD REPLY
0
Entering edit mode

It says in the code, object.R:

Convert.seurat <- function(
  from,
  to,
  filename,
  chunk.dims = 'auto',
  chunk.size = 1000,
  overwrite = FALSE,
  display.progress = TRUE,
  anndata.raw = "raw.data",
  anndata.X = "data",
  ...
) {
  object.to <- switch(
    EXPR = to,
    'loom' = {
      stop("Converting to and from loom files is currently unavailable; we are working on restoring this functionality")
      # if (!PackageCheck('loomR', error = FALSE)) {
      #   stop("Please install loomR from GitHub before converting to a loom object")
      # }
      # # cell.order <- from@cell.names
      # cell.order <- colnames(x = from)
      # gene.order <- rownames(x = from)
      # loomfile <- loomR::create(
      #   filename = filename,
      #   data = GetAssayData(object = from, slot = 'counts')[, cell.order],
      #   cell.attrs = from[[]][cell.order, ],
      #   layers = list('norm_data' = t(x = GetAssayData(object = from)[, cell.order])),
      #   chunk.dims = chunk.dims,
      #   chunk.size = chunk.size,
      #   overwrite = overwrite,
      #   display.progress = display.progress
      # )
      # if (nrow(x = HVFInfo(object = from)) > 0) {
      #   hvg.info <- HVFInfo(object = from)
      #   colnames(x = hvg.info) <- gsub(
      #     pattern = '.',
      #     replacement = '_',
      #     x = colnames(x = hvg.info),
      #     fixed = TRUE
      #   )
...
ADD REPLY
0
Entering edit mode

Thank you, the convert function is defunct.Now we can just convert seurat to loom,not in reverse. So we can only wait,no other solutions?

ADD REPLY
0
Entering edit mode

As I wrote above, I would probably try to find the entire cellRanger output folder (usually a gzip/tar folder) which should contain the matrix, which can be read in with Seurat's read10X() function.

Apart from that you could a) contact the loomR authors or b) the 10X Genomics Tech Support Team.

ADD REPLY
0
Entering edit mode
5.7 years ago

You might be able to use loomExperiment (see here), they offer an import function, so that would get you the loom file into R and from there you could use Seurat's CreateSeuratObject.

Maybe, the coercion might even work:

sce <- as(loomObject, "SingleCellExperiment")

and from there you could use Seurat's convert function from SCE to Seurat.

ADD COMMENT
0
Entering edit mode
5.7 years ago
Assa Yeroslaviz ★ 1.9k

The broad institute wot (see here) package offers a possibility to convert loom files in to text. Maybe you can use this solution, until there is a more direct one.

ADD COMMENT

Login before adding your answer.

Traffic: 1761 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6