{ "cells": [ { "cell_type": "markdown", "id": "f9a5e963", "metadata": {}, "source": [ "# S2. Interoperability" ] }, { "cell_type": "markdown", "id": "a0420f40", "metadata": {}, "source": [ "Here, we briefly demonstrate how the single-cell objects may be converted between R and python to run CCC analyses in either language:" ] }, { "cell_type": "code", "execution_count": 1, "id": "5fc40519", "metadata": {}, "outputs": [], "source": [ "import os\n", "import scanpy as sc\n", "\n", "data_path = '../../data/'" ] }, { "cell_type": "markdown", "id": "881e5514", "metadata": {}, "source": [ "## to R\n", "\n", "For use in R, the .h5ad file saved in [Tutorial 1](./01-Preprocess-Expression.ipynb) can be loaded in R as a SeuratObject using SeuratDisk. See the [companion supplementary R tutorial](../ccc_R/S2_Interoperability.ipynb) for loading these saved files.\n", "\n", "## from R\n", "\n", "### SCE\n", "Here, we can load the data that was generated in the [R version of Tutorial l](../ccc_R/01-Preprocess-Expression.ipynb) using SingleCellExperiment:" ] }, { "cell_type": "code", "execution_count": 2, "id": "b4bf8e56", "metadata": {}, "outputs": [], "source": [ "file_name = os.path.join(data_path, 'processed_fromR_toPython.h5ad')\n", "adata_fromR_sce = sc.read_h5ad(file_name)" ] }, { "cell_type": "markdown", "id": "93014a25", "metadata": {}, "source": [ "### Seurat\n", "We can also load the Seurat data we generated in the [supplementary R Tutorial](../ccc_R/S0_Preprocess_Expression_Seurat.ipynb):" ] }, { "cell_type": "code", "execution_count": 3, "id": "7b381ded", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/hratch/miniconda3/envs/ccc_protocols/lib/python3.10/site-packages/anndata/compat/__init__.py:298: FutureWarning: Moving element from .uns['neighbors']['distances'] to .obsp['distances'].\n", "\n", "This is where adjacency matrices should go now.\n", " warn(\n" ] } ], "source": [ "file_name = os.path.join(data_path, 'processed_fromR_toPython_Seurat.h5ad')\n", "adata_fromR_seurat = sc.read_h5ad(file_name)" ] } ], "metadata": { "kernelspec": { "display_name": "Python [conda env:ccc_protocols]", "language": "python", "name": "conda-env-ccc_protocols-py" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.0" } }, "nbformat": 4, "nbformat_minor": 5 }