{ "cells": [ { "cell_type": "markdown", "id": "2483a40b", "metadata": {}, "source": [ "# Read spatial omics" ] }, { "cell_type": "code", "execution_count": 1, "id": "fb9eab1c", "metadata": {}, "outputs": [], "source": [ "import SOAPy_st as sp\n", "import pandas as pd" ] }, { "cell_type": "markdown", "id": "9c5c64b9", "metadata": {}, "source": [ "## Read Visium" ] }, { "cell_type": "markdown", "id": "47c921ed", "metadata": {}, "source": [ "we used 10X Visium data of mouse dorsolateral prefrontal cortex (DLPFC, 151676) as an example to read the 10X Visium data. To prepare raw data, follow these steps:\n", "\n", "1.Raw data file could be download from https://research.libd.org/globus/. \n", "\n", "2.Click *jhpce#HumanPilot10x* and *151676* in turn.\n", "\n", "3.Download *151676_raw_feature_bc_matrix.h5*, *tissue_hires_image.png*, *tissue_lowres_image.png*, *tissue_positions_list.txt* and *scalefactors_json.json*.\n", "\n", "4.Rename *tissue_positions_list.txt* to *tissue_positions_list.csv*.\n", "\n", "5.Assemble the folders as *151676/151676_raw_feature_bc_matrix.h5* , *151676/spatial/tissue_hires_image.png*, *151676/spatial/tissue_lowres_image.png*, *151676/spatial/tissue_positions_list.csv* and *151676/spatial/scalefactors_json.json*." ] }, { "cell_type": "code", "execution_count": 2, "id": "99b4cc95", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/wangheqi/anaconda3/envs/SpatialOmics/lib/python3.9/site-packages/anndata/_core/anndata.py:1832: UserWarning: Variable names are not unique. To make them unique, call `.var_names_make_unique`.\n", " utils.warn_names_duplicates(\"var\")\n" ] } ], "source": [ "adata_visium = sp.pp.read_visium2adata(\n", " path = './151676/',\n", " count_file = '151676_raw_feature_bc_matrix.h5'\n", ")" ] }, { "cell_type": "code", "execution_count": 3, "id": "6a7e8ed6", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "AnnData object with n_obs × n_vars = 4992 × 33538\n", " obs: 'in_tissue', 'array_row', 'array_col'\n", " var: 'gene_ids', 'feature_types', 'genome'\n", " uns: 'spatial'\n", " obsm: 'spatial'" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "adata_visium" ] }, { "cell_type": "markdown", "id": "4666a2e1", "metadata": {}, "source": [ "## Read GeoMx DSP" ] }, { "cell_type": "markdown", "id": "bfe66fd4", "metadata": {}, "source": [ "Read spatial transcriptomics data of NanoString GeoMx DSP. Mouse embryonic development samples are used as examples.\n", "\n", "Download [Count Results](https://external-soa-downloads-p-1.s3.us-west-2.amazonaws.com/mu_dev_count_results.tar.gz) and [E13 Images](https://external-soa-downloads-p-1.s3.us-west-2.amazonaws.com/mu_dev_E13_image_files.tar.gz) files from https://nanostring.com/products/geomx-digital-spatial-profiler/spatial-organ-atlas/mouse-development/ .\n" ] }, { "cell_type": "code", "execution_count": 4, "id": "0ba8a502", "metadata": {}, "outputs": [], "source": [ "adata_dsp = sp.pp.read_dsp2adata(\n", " # The path of 'Images' files \n", " xml_file={\n", " # Using the xml file for two samples as an example, \n", " # you can add key-value pairs to the dictionary if you need information about sample points for more samples.\n", " 'mu_dev_E13_006': './nanostring_growth/mu_dev_E13_006.ome.xml',\n", " 'mu_dev_E13_011': './nanostring_growth/mu_dev_E13_011.ome.xml'\n", " },\n", " # The path of Count Results\n", " information_file='./nanostring_growth/Export4_NormalizationQ3.xlsx',\n", ")" ] }, { "cell_type": "code", "execution_count": 5, "id": "072b8d2f", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
| \n", " | SlideName | \n", "ScanLabel | \n", "ROILabel | \n", "SegmentLabel | \n", "QCFlags | \n", "AOISurfaceArea | \n", "AOINucleiCount | \n", "ROICoordinateX | \n", "ROICoordinateY | \n", "RawReads | \n", "... | \n", "Timepoint | \n", "ROIID | \n", "SegmentID | \n", "ScanWidth | \n", "ScanHeight | \n", "ScanOffsetX | \n", "ScanOffsetY | \n", "LOQ (Mouse NGS Whole Transcriptome Atlas RNA) | \n", "NormalizationFactor | \n", "ExpressionFilteringThreshold (Mouse NGS Whole Transcriptome Atlas RNA) | \n", "
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| SegmentDisplayName | \n", "\n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " |
| mu_dev_E9_001 | 001 | Full ROI | \n", "mu_dev_E9_001 | \n", "mu_dev_E9_001 | \n", "1 | \n", "Full ROI | \n", "Low Negative Probe Count for Probe Kit Mouse N... | \n", "47287.021916 | \n", "392 | \n", "16573 | \n", "18896 | \n", "4259786 | \n", "... | \n", "E9 | \n", "c73163bc-f107-498f-bd40-bbcab9a48993 | \n", "f057dc6e-68ce-441d-a816-58802fc38258 | \n", "16904.210938 | \n", "20578.818359 | \n", "7932 | \n", "6094 | \n", "16.252453 | \n", "0.536152 | \n", "16.252453 | \n", "
| mu_dev_E9_001 | 002 | Full ROI | \n", "mu_dev_E9_001 | \n", "mu_dev_E9_001 | \n", "2 | \n", "Full ROI | \n", "Low Negative Probe Count for Probe Kit Mouse N... | \n", "41175.373907 | \n", "340 | \n", "16485 | \n", "19752 | \n", "4725639 | \n", "... | \n", "E9 | \n", "be667b65-38c0-49c4-af51-845ffd8a7a85 | \n", "09985ba0-449c-4b1a-9c8f-9327991df8fa | \n", "16904.210938 | \n", "20578.818359 | \n", "7932 | \n", "6094 | \n", "17.745085 | \n", "0.496225 | \n", "17.745085 | \n", "
| mu_dev_E9_001 | 003 | Full ROI | \n", "mu_dev_E9_001 | \n", "mu_dev_E9_001 | \n", "3 | \n", "Full ROI | \n", "Low Negative Probe Count for Probe Kit Mouse N... | \n", "43198.870210 | \n", "403 | \n", "15756 | \n", "18824 | \n", "5958816 | \n", "... | \n", "E9 | \n", "ba522e1c-7e21-4cc6-b529-118603949d5a | \n", "2ac08d0d-c65d-4ab9-b834-5ef7ebbad4cd | \n", "16904.210938 | \n", "20578.818359 | \n", "7932 | \n", "6094 | \n", "18.109046 | \n", "0.395298 | \n", "18.109046 | \n", "
| mu_dev_E9_001 | 004 | Full ROI | \n", "mu_dev_E9_001 | \n", "mu_dev_E9_001 | \n", "4 | \n", "Full ROI | \n", "Low Negative Probe Count for Probe Kit Mouse N... | \n", "44444.810459 | \n", "368 | \n", "15722 | \n", "19675 | \n", "3703922 | \n", "... | \n", "E9 | \n", "52d9a6b1-934d-4f42-a80e-a4a78b7ede43 | \n", "aeed549d-8b7a-4fa4-b22a-c54059e83066 | \n", "16904.210938 | \n", "20578.818359 | \n", "7932 | \n", "6094 | \n", "14.509348 | \n", "0.605782 | \n", "14.509348 | \n", "
| mu_dev_E9_001 | 005 | Full ROI | \n", "mu_dev_E9_001 | \n", "mu_dev_E9_001 | \n", "5 | \n", "Full ROI | \n", "Low Negative Probe Count for Probe Kit Mouse N... | \n", "31889.529594 | \n", "279 | \n", "15064 | \n", "18429 | \n", "3069897 | \n", "... | \n", "E9 | \n", "a9e0bca3-59a4-4131-90b7-c787ca400759 | \n", "c53d1b52-712e-4a3d-9af4-5bdb55365eef | \n", "16904.210938 | \n", "20578.818359 | \n", "7932 | \n", "6094 | \n", "12.118616 | \n", "0.717618 | \n", "12.118616 | \n", "
5 rows × 35 columns
\n", "| \n", " | slide | \n", "roi | \n", "x | \n", "y | \n", "
|---|---|---|---|---|
| 0 | \n", "mu_dev_E13_006 | \n", "1 | \n", "13011.793535 | \n", "10484.417086 | \n", "
| 1 | \n", "mu_dev_E13_006 | \n", "1 | \n", "13109.708338 | \n", "10499.139178 | \n", "
| 2 | \n", "mu_dev_E13_006 | \n", "1 | \n", "13184.708338 | \n", "10547.123928 | \n", "
| 3 | \n", "mu_dev_E13_006 | \n", "1 | \n", "13242.708338 | \n", "10642.093747 | \n", "
| 4 | \n", "mu_dev_E13_006 | \n", "1 | \n", "13261.840745 | \n", "10730.656697 | \n", "
| ... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
| 4171 | \n", "mu_dev_E13_011 | \n", "58 | \n", "4548.893838 | \n", "10387.159712 | \n", "
| 4172 | \n", "mu_dev_E13_011 | \n", "58 | \n", "4477.882657 | \n", "10362.799483 | \n", "
| 4173 | \n", "mu_dev_E13_011 | \n", "58 | \n", "4437.660936 | \n", "10371.299021 | \n", "
| 4174 | \n", "mu_dev_E13_011 | \n", "58 | \n", "4487.202775 | \n", "10425.060315 | \n", "
| 4175 | \n", "mu_dev_E13_011 | \n", "58 | \n", "4636.188087 | \n", "10423.920083 | \n", "
4176 rows × 4 columns
\n", "