Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

save result object in h5ad format for better interoperability with other packages #1

Open
sreichl opened this issue Mar 29, 2022 · 2 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@sreichl
Copy link
Contributor

sreichl commented Mar 29, 2022

provide info in the docs e.g., resources but do not implement as the use cases are highly custom (which assays to put where etc.)

example code:

##converting to h5ad format
obj_m@active.assay <- "RNA"
                              
if(file.exists(file.path(analysis_dir, "merged", "rna_merged.h5Seurat"))) file.remove(file.path(analysis_dir, "merged", "rna_merged.h5Seurat"))                          
SaveH5Seurat(obj_m, filename = file.path(analysis_dir, "merged", "rna_merged.h5Seurat"))
                              
if(file.exists(file.path(analysis_dir, "merged", "rna_merged.h5ad"))) file.remove(file.path(analysis_dir, "merged", "rna_merged.h5ad"))                              
Convert(file.path(analysis_dir, "merged", "rna_merged.h5Seurat"), dest = "h5ad")
@sreichl sreichl added the enhancement New feature or request label Mar 29, 2022
@sreichl
Copy link
Contributor Author

sreichl commented May 10, 2022

or use this: https://github.com/theislab/anndata2ri

@sreichl sreichl self-assigned this Jul 27, 2023
@sreichl
Copy link
Contributor Author

sreichl commented Mar 4, 2024

or using SeuratDisk
add as a separate rule that does this for the last step?
or separate config that indicates step and assay(and data slot?) (breaking change)

# https://mojaveazure.github.io/seurat-disk/articles/convert-anndata.html

library("Seurat")
library("SeuratDisk")

# configs
object_path <- file.path("scrnaseq_processing_seurat/merged/NORMALIZED/object.rds")
results_path <- file.path("result/path")

dir.create(results_path, recursive = TRUE)

# load seurat object
data <- readRDS(file = file.path(object_path))

# save as h5Seurat
SaveH5Seurat(data, filename = file.path(results_path,"object.h5Seurat"), overwrite = TRUE)

# convert to anndata for scanpy (https://mojaveazure.github.io/seurat-disk/reference/Convert.html)
Convert(file.path(results_path,"object.h5Seurat"), assay = "SCT", dest = "h5ad", overwrite = TRUE)

@sreichl sreichl added documentation Improvements or additions to documentation and removed enhancement New feature or request labels Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant