From 78d9af4355d399c11d8103e5fa37a8048e32807c Mon Sep 17 00:00:00 2001 From: sreichl Date: Thu, 14 Nov 2024 16:37:52 +0100 Subject: [PATCH] add helper script for conversion to h5ad #1 and update README accordingly --- README.md | 3 +++ helpers/Seurat_to_h5ad_conversion.R | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 helpers/Seurat_to_h5ad_conversion.R diff --git a/README.md b/README.md index 940d373..4373841 100644 --- a/README.md +++ b/README.md @@ -187,6 +187,9 @@ Beyond this the workflow was tested on multimodal scCRISPR-seq data sets with >3 - [Snakemake Workflow Catalog Entry](https://snakemake.github.io/snakemake-workflow-catalog?usage=epigen/scrnaseq_processing_seurat) # 📚 Resources +- Helper scripts + - [Converting Parse Bioscience scRNA-seq data to (expected) 10x Genomics/MTX format](./helpers/parse_to_10x_conversion.R) + - [Converting Seurat object to scanpy compatible anndata object in `h5ad` format](./helpers/Seurat_to_h5ad_conversion.R) - Data Resources for scRNA-seq data in compatible MTX format - [10X Genomics Datasets](https://www.10xgenomics.com/datasets) - [CELLxGENE](https://cellxgene.cziscience.com/) diff --git a/helpers/Seurat_to_h5ad_conversion.R b/helpers/Seurat_to_h5ad_conversion.R new file mode 100644 index 0000000..2af27a3 --- /dev/null +++ b/helpers/Seurat_to_h5ad_conversion.R @@ -0,0 +1,19 @@ +# adapted from: https://mojaveazure.github.io/seurat-disk/articles/convert-anndata.html + +# libraries +library("Seurat") +library("SeuratDisk") + +# configs +object_path <- file.path("path/to/Seurat/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)