Convert a List to .loom File in R for scVelo
1
0
Entering edit mode
21 months ago
630720255 • 0

Hi there, currently I'm doing some trajectory analysis with scVelo and velocyto for some 10X single cell data, which involved in some data integration and barcode relocation process.

I use the read.loom.matrices function to read about 10 to 20 different .loom files in turn, which gives me a huge list, each element of this list contains 3 lists "spliced" "unspliced" "ambiguous", and I did the data processing and integration with R, finally I get a new integrated list which only contains "spliced" "unspliced" "ambiguous" matrices.

My question is, I still have no idea how to convert this final list into .loom file as readable anndata for scVelo in a good way by R. I tried the as.Seurat %>% as.loom, but seems that the layer construction was significant different with the original .loom file. Any income will be much appraciated. Thanks!

velocyto.R Seurat scVelo loom • 1.2k views
ADD COMMENT
0
Entering edit mode
21 months ago
630720255 • 0

OK I've figured it out anyway ... I would like to write my solution here for recording and any possible incomes.

What you need is several .loom files that contain velocity info, and a related seurat object which have already been integrated.

First you will need to read those .loom files (e.g. read.loom.matrices) as a list, each element of this list contains 3 elements :spliced, unspliced, and ambiguous. Then you need to change colnames of each sub element along with colnames of your seurat object. The merging process of this list could be done as a simple lapply function with do.call(cbind), after that you will get a new list which contains spliced, unspliced, and ambiguous dgmatirx.

For scVelo, use the as.Seurat(x = ldat) to convert the ldat list into the Seurat format (e.g., seu.new), then change the seu.new[["RNA"]] slot to the [["spliced"]] slot and set as the default assay slot with DefaultAssay function. Load what you will need (e.g., [["umap"]] or $seurat_clusters slot) into the seu.new object.

Finally, convert it into H5AD format with SaveH5Seurat and Convert function, which could be read by scanpy in python.

best, W

ADD COMMENT

Login before adding your answer.

Traffic: 1884 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