Skip to content

Instantly share code, notes, and snippets.

@moritzschaefer
Created July 8, 2025 22:58
Show Gist options
  • Save moritzschaefer/a07b6acdf12959c2e6127d57b8cb621a to your computer and use it in GitHub Desktop.
Save moritzschaefer/a07b6acdf12959c2e6127d57b8cb621a to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "6ec68ca4",
"metadata": {},
"outputs": [],
"source": [
"library(Seurat)\n",
"library(SeuratDisk)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8267e257",
"metadata": {},
"outputs": [],
"source": [
"library(Seurat)\n",
"library(SeuratData)\n",
"library(SeuratDisk)\n",
"\n",
"# Load the RDS file\n",
"seurat_object <- readRDS(\"input.rds\")\n",
"\n",
"# Check the Seurat version\n",
"if (\"Seurat\" %in% class(seurat_object)) {\n",
" print(seurat_object@version)\n",
"} else {\n",
" print(\"The loaded object is not a Seurat object.\")\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "155e058c",
"metadata": {},
"outputs": [],
"source": [
"SaveH5Seurat(seurat_object, filename = \"intermediate.h5Seurat\")\n",
"Convert(\"intermediate.h5Seurat\", dest = \"h5ad\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "81723928",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "R",
"language": "R",
"name": "ir"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
name: r_seuratdisk_env
channels:
- conda-forge
- bioconda
- defaults
dependencies:
- r-base
- r-seuratdisk
- r-seurat
- r-irkernel # For Jupyter integration
- nb_conda_kernels
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment