From 635d4d8fa460b392a160d3a27aa02c4d840b401d Mon Sep 17 00:00:00 2001 From: Automated Date: Wed, 14 Jun 2023 17:26:37 +0000 Subject: [PATCH] Latest notebook update: Wed Jun 14 17:26:37 UTC 2023 --- vignettes/bivariate.ipynb | 98 +++++----- vignettes/create_sfe.ipynb | 66 +++---- vignettes/create_sfe_v2.ipynb | 36 ++-- vignettes/localc.ipynb | 64 +++---- vignettes/multispati.ipynb | 176 +++++++++--------- vignettes/nonspatial.ipynb | 278 ++++++++++++++-------------- vignettes/sfemethod.ipynb | 70 +++---- vignettes/variogram.ipynb | 78 ++++---- vignettes/vig1_visium_basic.ipynb | 172 +++++++++--------- vignettes/vig2_visium.ipynb | 244 ++++++++++++------------- vignettes/vig3_slideseq_v2.ipynb | 92 +++++----- vignettes/vig4_cosmx.ipynb | 218 +++++++++++----------- vignettes/vig5_xenium.ipynb | 282 ++++++++++++++--------------- vignettes/vig6_merfish.ipynb | 234 ++++++++++++------------ vignettes/vig7_seqfish.ipynb | 102 +++++------ vignettes/vig8_codex.ipynb | 76 ++++---- vignettes/visium_10x.ipynb | 116 ++++++------ vignettes/visium_10x_spatial.ipynb | 234 ++++++++++++------------ 18 files changed, 1318 insertions(+), 1318 deletions(-) diff --git a/vignettes/bivariate.ipynb b/vignettes/bivariate.ipynb index ce9fdd2c4..61302e128 100644 --- a/vignettes/bivariate.ipynb +++ b/vignettes/bivariate.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "raw", - "id": "5e0fc39e", + "id": "32cf172a", "metadata": {}, "source": [ "---\n", @@ -26,7 +26,7 @@ { "cell_type": "code", "execution_count": null, - "id": "78790fc6", + "id": "1ad1dfcd", "metadata": { "tags": [ "remove_cell" @@ -43,7 +43,7 @@ { "cell_type": "code", "execution_count": null, - "id": "63c58525", + "id": "3bf0e2cc", "metadata": { "eval": false, "tags": [ @@ -78,7 +78,7 @@ }, { "cell_type": "markdown", - "id": "d06e4a1f", + "id": "5d6e7a7a", "metadata": { "lines_to_next_cell": 0 }, @@ -94,7 +94,7 @@ { "cell_type": "code", "execution_count": null, - "id": "13c33745", + "id": "59c6e5c4", "metadata": { "message": false }, @@ -113,7 +113,7 @@ }, { "cell_type": "markdown", - "id": "b83b536c", + "id": "7da5f2fa", "metadata": { "lines_to_next_cell": 0 }, @@ -124,7 +124,7 @@ { "cell_type": "code", "execution_count": null, - "id": "470d2ee9", + "id": "1d1fb5ca", "metadata": {}, "outputs": [], "source": [ @@ -133,7 +133,7 @@ }, { "cell_type": "markdown", - "id": "4cf56335", + "id": "0f613ac2", "metadata": { "lines_to_next_cell": 0 }, @@ -146,7 +146,7 @@ { "cell_type": "code", "execution_count": null, - "id": "fb68f5a4", + "id": "d74dacea", "metadata": {}, "outputs": [], "source": [ @@ -155,7 +155,7 @@ }, { "cell_type": "markdown", - "id": "4e70da9c", + "id": "b3700f7d", "metadata": { "lines_to_next_cell": 0 }, @@ -166,7 +166,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1fc4165b", + "id": "c8e8e558", "metadata": {}, "outputs": [], "source": [ @@ -179,7 +179,7 @@ { "cell_type": "code", "execution_count": null, - "id": "28017350", + "id": "8fec11dc", "metadata": {}, "outputs": [], "source": [ @@ -192,7 +192,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ead7125d", + "id": "7841f82d", "metadata": {}, "outputs": [], "source": [ @@ -203,7 +203,7 @@ { "cell_type": "code", "execution_count": null, - "id": "82de8595", + "id": "5a7626c3", "metadata": {}, "outputs": [], "source": [ @@ -213,7 +213,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f954544c", + "id": "ad3af497", "metadata": {}, "outputs": [], "source": [ @@ -222,7 +222,7 @@ }, { "cell_type": "markdown", - "id": "5151d3e4", + "id": "caa49b7e", "metadata": { "lines_to_next_cell": 0 }, @@ -243,7 +243,7 @@ { "cell_type": "code", "execution_count": null, - "id": "174fd528", + "id": "056c7e2f", "metadata": {}, "outputs": [], "source": [ @@ -252,7 +252,7 @@ }, { "cell_type": "markdown", - "id": "7c94f7a1", + "id": "0c46956c", "metadata": {}, "source": [ "Because bivariate global results can have very different formats (matrix for Lee's L and lists for many other methods), the results are not stored in the SFE object." @@ -261,7 +261,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7f87cbbb", + "id": "2dc70345", "metadata": {}, "outputs": [], "source": [ @@ -270,7 +270,7 @@ }, { "cell_type": "markdown", - "id": "eec7ba18", + "id": "164b769b", "metadata": { "lines_to_next_cell": 0 }, @@ -281,7 +281,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9e7e9602", + "id": "7b5bb783", "metadata": {}, "outputs": [], "source": [ @@ -292,7 +292,7 @@ { "cell_type": "code", "execution_count": null, - "id": "cb91d592", + "id": "e04fbdff", "metadata": { "fig.height": 6, "fig.width": 6 @@ -305,7 +305,7 @@ }, { "cell_type": "markdown", - "id": "8b8030f8", + "id": "1f647d01", "metadata": { "lines_to_next_cell": 0 }, @@ -348,7 +348,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5c18a910", + "id": "032b5632", "metadata": {}, "outputs": [], "source": [ @@ -357,7 +357,7 @@ }, { "cell_type": "markdown", - "id": "701abadd", + "id": "55964aed", "metadata": {}, "source": [ "Here we compute local L for two myofiber marker genes and one gene highly expressed in the injury site:" @@ -366,7 +366,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6636aafa", + "id": "bb3633cf", "metadata": {}, "outputs": [], "source": [ @@ -376,7 +376,7 @@ }, { "cell_type": "markdown", - "id": "3e48f5a4", + "id": "2227ddae", "metadata": {}, "source": [ "Bivariate local results are stored in the `localResults` field and the feature names are the pairwise combinations of features supplied. When only `feature1` is specified, then the bivariate method is applied to all pairwise combinations of `feature1`. " @@ -385,7 +385,7 @@ { "cell_type": "code", "execution_count": null, - "id": "581a1555", + "id": "ef3a7ade", "metadata": {}, "outputs": [], "source": [ @@ -394,7 +394,7 @@ }, { "cell_type": "markdown", - "id": "bce81f7e", + "id": "915df65a", "metadata": { "lines_to_next_cell": 0 }, @@ -407,7 +407,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8ee401fb", + "id": "f32d2c87", "metadata": { "fig.height": 4, "fig.width": 10 @@ -420,7 +420,7 @@ }, { "cell_type": "markdown", - "id": "9dbec2ac", + "id": "ef4be604", "metadata": { "lines_to_next_cell": 0 }, @@ -431,7 +431,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a3bf9345", + "id": "0dd6d872", "metadata": { "fig.height": 4, "fig.width": 10 @@ -446,7 +446,7 @@ }, { "cell_type": "markdown", - "id": "7e4b4765", + "id": "6d644e02", "metadata": { "lines_to_next_cell": 0 }, @@ -459,7 +459,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2523ad7e", + "id": "c7403290", "metadata": { "fig.height": 4, "fig.width": 10 @@ -473,7 +473,7 @@ }, { "cell_type": "markdown", - "id": "fd09ff4f", + "id": "d0b69072", "metadata": { "lines_to_next_cell": 0 }, @@ -484,7 +484,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ee6bf126", + "id": "62a27fe0", "metadata": {}, "outputs": [], "source": [ @@ -495,7 +495,7 @@ { "cell_type": "code", "execution_count": null, - "id": "74f5b4d8", + "id": "95df834f", "metadata": { "fig.height": 4, "fig.width": 10 @@ -510,7 +510,7 @@ }, { "cell_type": "markdown", - "id": "5edddce7", + "id": "bf95b266", "metadata": {}, "source": [ "The patterns are qualitatively the same, but while local Moran's I is negative in heterogeneous regions, the SSS can't be negative.\n", @@ -529,7 +529,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7c10e713", + "id": "882a2603", "metadata": {}, "outputs": [], "source": [ @@ -540,7 +540,7 @@ { "cell_type": "code", "execution_count": null, - "id": "be6f4034", + "id": "4a261f53", "metadata": {}, "outputs": [], "source": [ @@ -549,7 +549,7 @@ }, { "cell_type": "markdown", - "id": "756dd803", + "id": "4aeadc59", "metadata": { "lines_to_next_cell": 0 }, @@ -560,7 +560,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4c223e3d", + "id": "85f1e663", "metadata": {}, "outputs": [], "source": [ @@ -569,7 +569,7 @@ }, { "cell_type": "markdown", - "id": "be3427cc", + "id": "65ff87cf", "metadata": { "lines_to_next_cell": 0 }, @@ -580,7 +580,7 @@ { "cell_type": "code", "execution_count": null, - "id": "698e6be3", + "id": "2fa08428", "metadata": { "fig.height": 7.5, "fig.width": 10 @@ -596,7 +596,7 @@ }, { "cell_type": "markdown", - "id": "0d9bdb11", + "id": "92e9e644", "metadata": {}, "source": [ "The first row plots XY while the second row plots YX; note that while they are similar, they are not the same. What does bivariate local Moran mean? It's kind of like contribution of each location to the correlation between $x$ and spatially lagged $y$, so $x$ is not smoothed. In contrast, Lee's L is a scaled Pearson correlation between spatially lagged $x$ and spatially lagged $y$. Because permutation testing is performed, we can plot the pseudo-p-value, after correcting for multiple testing based on the spatial neighborhood graph:" @@ -605,7 +605,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2545e26d", + "id": "818ec983", "metadata": { "fig.height": 7.5, "fig.width": 10 @@ -621,7 +621,7 @@ }, { "cell_type": "markdown", - "id": "77d58d2f", + "id": "2cf846bd", "metadata": { "lines_to_next_cell": 0 }, @@ -640,7 +640,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f6e026c5", + "id": "7ee9987d", "metadata": {}, "outputs": [], "source": [ @@ -649,7 +649,7 @@ }, { "cell_type": "markdown", - "id": "c9b7f1b3", + "id": "4391889b", "metadata": {}, "source": [ "# References" diff --git a/vignettes/create_sfe.ipynb b/vignettes/create_sfe.ipynb index 37f4c92bd..fe3c42ec4 100644 --- a/vignettes/create_sfe.ipynb +++ b/vignettes/create_sfe.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "raw", - "id": "9f19fe8f", + "id": "d3ea3260", "metadata": {}, "source": [ "---\n", @@ -25,7 +25,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9479c846", + "id": "09b440b5", "metadata": { "tags": [ "remove_cell" @@ -42,7 +42,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7cd94180", + "id": "e1bbcc62", "metadata": { "eval": false, "tags": [ @@ -80,7 +80,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e7008227", + "id": "14cb4f08", "metadata": { "name": "setup" }, @@ -94,7 +94,7 @@ }, { "cell_type": "markdown", - "id": "00f141be", + "id": "0f232b1e", "metadata": {}, "source": [ "# Visium Space Ranger output\n", @@ -105,7 +105,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c70bf880", + "id": "7b4fc098", "metadata": {}, "outputs": [], "source": [ @@ -120,7 +120,7 @@ }, { "cell_type": "markdown", - "id": "7e950375", + "id": "38ba454b", "metadata": {}, "source": [ "The results for each tissue capture should be in the `outs` directory. Inside the `outs` directory there are two directories: `raw_reature_bc_matrix` has the unfiltered gene count matrix, and `spatial` has the spatial information. " @@ -129,7 +129,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f8beb2d5", + "id": "aa471706", "metadata": {}, "outputs": [], "source": [ @@ -138,7 +138,7 @@ }, { "cell_type": "markdown", - "id": "7b658737", + "id": "7e09bb91", "metadata": {}, "source": [ "The [`DropletUtils`](https://bioconductor.org/packages/release/bioc/html/DropletUtils.html) package has a function `read10xCounts()` which reads the gene count matrix. SPE reads in the spatial information, and SFE uses the spatial information to construct Visium spot polygons and spatial neighborhood graphs. Inside the `spatial` directory:" @@ -147,7 +147,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5508f895", + "id": "ed031300", "metadata": {}, "outputs": [], "source": [ @@ -156,7 +156,7 @@ }, { "cell_type": "markdown", - "id": "2eb91ade", + "id": "4c1d6b88", "metadata": {}, "source": [ "`tissue_lowres_image.png` is a low resolution image of the tissue.\n", @@ -167,7 +167,7 @@ { "cell_type": "code", "execution_count": null, - "id": "657a30d1", + "id": "4e7a6e10", "metadata": {}, "outputs": [], "source": [ @@ -176,7 +176,7 @@ }, { "cell_type": "markdown", - "id": "a5785ce8", + "id": "87048ddc", "metadata": {}, "source": [ "`spot_diameter_fullres` is the diameter of each Visium spot in the full resolution H&E image in pixels. `tissue_hires_scalef` and `tissue_lowres_scalef` are the ratio of the size of the high resolution (but not full resolution) and low resolution H&E image to the full resolution image. `fiducial_diameter_fullres` is the diameter of each fiducial spot used to align the spots to the H&E image in pixels in the full resolution image.\n", @@ -189,7 +189,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1ee2f89c", + "id": "ed71f4be", "metadata": {}, "outputs": [], "source": [ @@ -200,7 +200,7 @@ }, { "cell_type": "markdown", - "id": "179f6996", + "id": "b214ef6f", "metadata": {}, "source": [ "Space Ranger output includes the gene count matrix, spot coordinates, and spot diameter. The Space Ranger output does NOT include nuclei segmentation or pathologist annotation of histological regions. Extra image processing, such as with ImageJ and QuPath, are required for those geometries.\n", @@ -212,7 +212,7 @@ { "cell_type": "code", "execution_count": null, - "id": "eac9123d", + "id": "356b3ef9", "metadata": {}, "outputs": [], "source": [ @@ -223,7 +223,7 @@ { "cell_type": "code", "execution_count": null, - "id": "93e9d23c", + "id": "ad011aeb", "metadata": {}, "outputs": [], "source": [ @@ -232,7 +232,7 @@ }, { "cell_type": "markdown", - "id": "d04f19c6", + "id": "79b63c79", "metadata": { "lines_to_next_cell": 0 }, @@ -246,7 +246,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3c292d8f", + "id": "ee04ff12", "metadata": {}, "outputs": [], "source": [ @@ -267,7 +267,7 @@ }, { "cell_type": "markdown", - "id": "16c379dd", + "id": "4231551c", "metadata": { "lines_to_next_cell": 0 }, @@ -278,7 +278,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1ddf7008", + "id": "4e1e8874", "metadata": {}, "outputs": [], "source": [ @@ -289,7 +289,7 @@ }, { "cell_type": "markdown", - "id": "f98d0f54", + "id": "06268ebd", "metadata": { "lines_to_next_cell": 0 }, @@ -302,7 +302,7 @@ { "cell_type": "code", "execution_count": null, - "id": "fa2d6e82", + "id": "8e1d8593", "metadata": {}, "outputs": [], "source": [ @@ -314,7 +314,7 @@ }, { "cell_type": "markdown", - "id": "8c7ada4d", + "id": "dda282f6", "metadata": { "lines_to_next_cell": 0 }, @@ -331,7 +331,7 @@ { "cell_type": "code", "execution_count": null, - "id": "63c52f9d", + "id": "67c0e04f", "metadata": { "eval": false }, @@ -351,7 +351,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2bbd714c", + "id": "8411ce3f", "metadata": { "eval": false }, @@ -370,7 +370,7 @@ }, { "cell_type": "markdown", - "id": "1baa1e13", + "id": "edc27301", "metadata": {}, "source": [ "### Cell polygons\n", @@ -382,7 +382,7 @@ { "cell_type": "code", "execution_count": null, - "id": "189b4ad7", + "id": "c7630cae", "metadata": { "eval": false }, @@ -398,7 +398,7 @@ }, { "cell_type": "markdown", - "id": "e59492c1", + "id": "ce0562a6", "metadata": { "lines_to_next_cell": 0 }, @@ -409,7 +409,7 @@ { "cell_type": "code", "execution_count": null, - "id": "54b58af2", + "id": "fb3ea525", "metadata": { "eval": false }, @@ -425,7 +425,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f1050e34", + "id": "ce644181", "metadata": { "eval": false }, @@ -442,7 +442,7 @@ }, { "cell_type": "markdown", - "id": "12c2c57e", + "id": "705d3069", "metadata": { "lines_to_next_cell": 0 }, @@ -457,7 +457,7 @@ { "cell_type": "code", "execution_count": null, - "id": "98dbbe6c", + "id": "ea47ed68", "metadata": {}, "outputs": [], "source": [ diff --git a/vignettes/create_sfe_v2.ipynb b/vignettes/create_sfe_v2.ipynb index 4144e65de..9efa5832e 100644 --- a/vignettes/create_sfe_v2.ipynb +++ b/vignettes/create_sfe_v2.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "raw", - "id": "ce4ada20", + "id": "40338946", "metadata": {}, "source": [ "---\n", @@ -26,7 +26,7 @@ { "cell_type": "code", "execution_count": null, - "id": "053bd756", + "id": "e543a7d1", "metadata": { "tags": [ "remove_cell" @@ -44,7 +44,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8e9cb196", + "id": "92bfd755", "metadata": { "eval": false, "tags": [ @@ -85,7 +85,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8128ae7d", + "id": "86de86bb", "metadata": { "lines_to_next_cell": 0, "name": "setup" @@ -103,7 +103,7 @@ }, { "cell_type": "markdown", - "id": "39fec238", + "id": "420fb9a4", "metadata": {}, "source": [ "## Downloading the data\n", @@ -116,7 +116,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c9a163fc", + "id": "c89e1374", "metadata": { "lines_to_next_cell": 0 }, @@ -128,7 +128,7 @@ }, { "cell_type": "markdown", - "id": "6f2c366b", + "id": "add7ce7b", "metadata": { "lines_to_next_cell": 0 }, @@ -141,7 +141,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a4560253", + "id": "41410653", "metadata": { "lines_to_next_cell": 0 }, @@ -156,7 +156,7 @@ }, { "cell_type": "markdown", - "id": "19276f05", + "id": "6a500fdf", "metadata": { "lines_to_next_cell": 0 }, @@ -167,7 +167,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8e96043c", + "id": "b8140b4b", "metadata": { "lines_to_next_cell": 0 }, @@ -180,7 +180,7 @@ }, { "cell_type": "markdown", - "id": "784d38a1", + "id": "d74c38de", "metadata": { "lines_to_next_cell": 0 }, @@ -192,7 +192,7 @@ { "cell_type": "code", "execution_count": null, - "id": "02ed1e86", + "id": "90c7c26f", "metadata": { "lines_to_next_cell": 0 }, @@ -210,7 +210,7 @@ }, { "cell_type": "markdown", - "id": "1e344156", + "id": "f8de54f4", "metadata": {}, "source": [ "Here, spot locations are provided as a CSV file. There are two columns of particular interest, namely `xcoord` and `ycoord`. The barcode column corresponds to the barcodes in the count matrix. Before calling the `SpatialFeatureExperiment` constructor, the spatial coordinates must be converted to a `sf` data frame using `df2sf()`. The coordinates are centroid positions, so we will indicate that `geometryType=\"POINT\"`. " @@ -219,7 +219,7 @@ { "cell_type": "code", "execution_count": null, - "id": "29a3c2d2", + "id": "20df764c", "metadata": { "lines_to_next_cell": 0 }, @@ -234,7 +234,7 @@ }, { "cell_type": "markdown", - "id": "140f6459", + "id": "6875e66e", "metadata": { "lines_to_next_cell": 0 }, @@ -245,7 +245,7 @@ { "cell_type": "code", "execution_count": null, - "id": "173b0c28", + "id": "bc0e1e90", "metadata": { "lines_to_next_cell": 0 }, @@ -261,7 +261,7 @@ }, { "cell_type": "markdown", - "id": "7ecafb1c", + "id": "9707d3fb", "metadata": { "lines_to_next_cell": 0 }, @@ -272,7 +272,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0dc7b1ae", + "id": "9168945f", "metadata": {}, "outputs": [], "source": [ diff --git a/vignettes/localc.ipynb b/vignettes/localc.ipynb index 2ca6065a9..a475b3304 100644 --- a/vignettes/localc.ipynb +++ b/vignettes/localc.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "raw", - "id": "53f6b865", + "id": "a88a47bb", "metadata": {}, "source": [ "---\n", @@ -26,7 +26,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8bf0af6f", + "id": "02debc3d", "metadata": { "lines_to_next_cell": 2, "tags": [ @@ -44,7 +44,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5913e95c", + "id": "8a65a553", "metadata": { "eval": false, "tags": [ @@ -79,7 +79,7 @@ }, { "cell_type": "markdown", - "id": "010e112f", + "id": "382ef850", "metadata": { "lines_to_next_cell": 0 }, @@ -105,7 +105,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9f30373e", + "id": "2f890356", "metadata": { "message": false }, @@ -123,7 +123,7 @@ }, { "cell_type": "markdown", - "id": "3753a58a", + "id": "a08b8e44", "metadata": { "lines_to_next_cell": 0 }, @@ -134,7 +134,7 @@ { "cell_type": "code", "execution_count": null, - "id": "826597df", + "id": "e1f12ef2", "metadata": {}, "outputs": [], "source": [ @@ -143,7 +143,7 @@ }, { "cell_type": "markdown", - "id": "0f0f3a81", + "id": "e2c8115d", "metadata": { "lines_to_next_cell": 0 }, @@ -154,7 +154,7 @@ { "cell_type": "code", "execution_count": null, - "id": "56cfd9d1", + "id": "b851a533", "metadata": {}, "outputs": [], "source": [ @@ -167,7 +167,7 @@ { "cell_type": "code", "execution_count": null, - "id": "22dfdcdd", + "id": "bed9056d", "metadata": {}, "outputs": [], "source": [ @@ -180,7 +180,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5dfec499", + "id": "e1ab058f", "metadata": {}, "outputs": [], "source": [ @@ -191,7 +191,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4c24eac5", + "id": "103c4734", "metadata": {}, "outputs": [], "source": [ @@ -201,7 +201,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a34a51eb", + "id": "4e3b5707", "metadata": {}, "outputs": [], "source": [ @@ -210,7 +210,7 @@ }, { "cell_type": "markdown", - "id": "64f5d89e", + "id": "7261e71b", "metadata": { "lines_to_next_cell": 0 }, @@ -222,7 +222,7 @@ { "cell_type": "code", "execution_count": null, - "id": "fed167cf", + "id": "4095853d", "metadata": {}, "outputs": [], "source": [ @@ -232,7 +232,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7fe2cafe", + "id": "143d91d7", "metadata": {}, "outputs": [], "source": [ @@ -241,7 +241,7 @@ }, { "cell_type": "markdown", - "id": "1f1e4875", + "id": "fb665a33", "metadata": { "lines_to_next_cell": 0 }, @@ -252,7 +252,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0d887ef4", + "id": "d6323c6e", "metadata": {}, "outputs": [], "source": [ @@ -262,7 +262,7 @@ { "cell_type": "code", "execution_count": null, - "id": "71a85139", + "id": "908a9ce5", "metadata": {}, "outputs": [], "source": [ @@ -272,7 +272,7 @@ }, { "cell_type": "markdown", - "id": "a0fea045", + "id": "5ef55cce", "metadata": {}, "source": [ "In Geary's C, a value below 1 indicates positive spatial autocorrelation and a value above 1 indicates negative spatial autocorrelation. Local Geary's C is not scaled, but from the square difference expression, a low value means a more homogeneous neighborhood and a high value means a more heterogeneous neighborhood. Here considering all 341 top HVGs, the muscle tendon junction and the unjury site are more heterogeneous, which is detected as negative cluster.\n", @@ -283,7 +283,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1f094bc8", + "id": "051bf1f0", "metadata": {}, "outputs": [], "source": [ @@ -294,7 +294,7 @@ }, { "cell_type": "markdown", - "id": "9a2509d5", + "id": "bb62c8b4", "metadata": {}, "source": [ "Warm colors indicate adjusted p < 0.05. This should be interpreted along with the clusters. In this dataset, there are interestingly homogeneous regions in the myofibers, and an interestingly heterogeneous region in the injury site. Most of the significant regions are positive cluster, but the center of the injury site is significant and is negative cluster.\n", @@ -308,7 +308,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c0dd9385", + "id": "04457d60", "metadata": {}, "outputs": [], "source": [ @@ -318,7 +318,7 @@ { "cell_type": "code", "execution_count": null, - "id": "76cf4413", + "id": "2f34722d", "metadata": {}, "outputs": [], "source": [ @@ -327,7 +327,7 @@ }, { "cell_type": "markdown", - "id": "4ed1b6cc", + "id": "9df13f1f", "metadata": { "lines_to_next_cell": 0 }, @@ -338,7 +338,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5a8e2b19", + "id": "512e76d9", "metadata": {}, "outputs": [], "source": [ @@ -348,7 +348,7 @@ { "cell_type": "code", "execution_count": null, - "id": "eefcd439", + "id": "d46f2694", "metadata": {}, "outputs": [], "source": [ @@ -363,7 +363,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3246cda5", + "id": "7d717424", "metadata": {}, "outputs": [], "source": [ @@ -374,7 +374,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4a4f3b8e", + "id": "4fe0def3", "metadata": {}, "outputs": [], "source": [ @@ -385,7 +385,7 @@ }, { "cell_type": "markdown", - "id": "45305fc8", + "id": "b382ddb6", "metadata": { "lines_to_next_cell": 0 }, @@ -398,7 +398,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2172493c", + "id": "26732aae", "metadata": {}, "outputs": [], "source": [ @@ -407,7 +407,7 @@ }, { "cell_type": "markdown", - "id": "40d9d481", + "id": "d9bde8a5", "metadata": {}, "source": [ "# References" diff --git a/vignettes/multispati.ipynb b/vignettes/multispati.ipynb index f00f41860..da86f3941 100644 --- a/vignettes/multispati.ipynb +++ b/vignettes/multispati.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "raw", - "id": "3c939fbc", + "id": "802315ed", "metadata": {}, "source": [ "---\n", @@ -26,7 +26,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b7590763", + "id": "fc7e93b3", "metadata": { "lines_to_next_cell": 2, "tags": [ @@ -44,7 +44,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b951827a", + "id": "0af1d0e5", "metadata": { "eval": false, "tags": [ @@ -79,7 +79,7 @@ }, { "cell_type": "markdown", - "id": "ff189bea", + "id": "3eefe9c4", "metadata": {}, "source": [ "# Introduction\n", @@ -107,7 +107,7 @@ { "cell_type": "code", "execution_count": null, - "id": "90f1f290", + "id": "b7194033", "metadata": { "message": false, "name": "setup" @@ -135,7 +135,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3f6e4027", + "id": "d8cbbf12", "metadata": {}, "outputs": [], "source": [ @@ -144,7 +144,7 @@ }, { "cell_type": "markdown", - "id": "7388f012", + "id": "8eb9db7c", "metadata": { "lines_to_next_cell": 0 }, @@ -155,7 +155,7 @@ { "cell_type": "code", "execution_count": null, - "id": "498e72ff", + "id": "939bd86a", "metadata": {}, "outputs": [], "source": [ @@ -164,7 +164,7 @@ }, { "cell_type": "markdown", - "id": "ca0cf3bf", + "id": "82a99c87", "metadata": { "lines_to_next_cell": 0 }, @@ -178,7 +178,7 @@ { "cell_type": "code", "execution_count": null, - "id": "40a22fac", + "id": "c5c2b6b7", "metadata": {}, "outputs": [], "source": [ @@ -189,7 +189,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a7f9ee71", + "id": "305cd55b", "metadata": {}, "outputs": [], "source": [ @@ -209,7 +209,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3e421f1b", + "id": "d99bb33f", "metadata": {}, "outputs": [], "source": [ @@ -218,7 +218,7 @@ }, { "cell_type": "markdown", - "id": "692dcd48", + "id": "2bb75b6f", "metadata": { "lines_to_next_cell": 0 }, @@ -229,7 +229,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f8c5f4f7", + "id": "f802969e", "metadata": {}, "outputs": [], "source": [ @@ -239,7 +239,7 @@ }, { "cell_type": "markdown", - "id": "5f2131f5", + "id": "c94b91b8", "metadata": {}, "source": [ "There still are over 390,000 cells left after removing the outliers. \n", @@ -250,7 +250,7 @@ { "cell_type": "code", "execution_count": null, - "id": "23d516e7", + "id": "90a9cad0", "metadata": {}, "outputs": [], "source": [ @@ -264,7 +264,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e9c091c6", + "id": "8f88e5bd", "metadata": {}, "outputs": [], "source": [ @@ -277,7 +277,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d47a47fd", + "id": "15f7a975", "metadata": {}, "outputs": [], "source": [ @@ -286,7 +286,7 @@ }, { "cell_type": "markdown", - "id": "d0659f1b", + "id": "3d67f40a", "metadata": {}, "source": [ "Here Moran's I is a little negative, but from the permutation testing, it is significant, though that can also be the large number of cells. The lower bound of Moran's I given the spatial neighborhood graph is usually closer to -0.5 than -1, while the upper bound is usually around 1. The bounds given a specific spatial neighborhood graph can be found with `moranBounds()`, but because it double centers the adjacency matrix, hence making it dense, there isn't enough memory to use it for the entire dataset. But we can look at the Moran bounds of a small subset of data, which might be generalizable to the whole dataset given that this tissue appears quite homogeneous in space." @@ -295,7 +295,7 @@ { "cell_type": "code", "execution_count": null, - "id": "37c0d8d9", + "id": "013979f8", "metadata": {}, "outputs": [], "source": [ @@ -308,7 +308,7 @@ { "cell_type": "code", "execution_count": null, - "id": "66c6f469", + "id": "10c4a5e8", "metadata": {}, "outputs": [], "source": [ @@ -317,7 +317,7 @@ }, { "cell_type": "markdown", - "id": "d2f84c89", + "id": "4e6016a6", "metadata": { "lines_to_next_cell": 0 }, @@ -328,7 +328,7 @@ { "cell_type": "code", "execution_count": null, - "id": "aaf8efed", + "id": "506ff85c", "metadata": {}, "outputs": [], "source": [ @@ -339,7 +339,7 @@ }, { "cell_type": "markdown", - "id": "e9e69bd5", + "id": "9d7dd8fc", "metadata": {}, "source": [ "whose magnitudes seem more substantial for `nCounts` and `nGenes` if it's positive spatial autocorrelation. So there may be mild to moderate negative spatial autocorrelation." @@ -348,7 +348,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0afb03f6", + "id": "446f68d7", "metadata": {}, "outputs": [], "source": [ @@ -358,7 +358,7 @@ }, { "cell_type": "markdown", - "id": "bfd396b3", + "id": "28be8bce", "metadata": {}, "source": [ "# Hepatic zonation\n", @@ -369,7 +369,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f1aa3127", + "id": "8493a468", "metadata": {}, "outputs": [], "source": [ @@ -378,7 +378,7 @@ }, { "cell_type": "markdown", - "id": "d9bdd865", + "id": "5207b8c7", "metadata": {}, "source": [ "A portal triad is shown near the top right of this bounding box. The two large vessels on the left and bottom right are central veins. The portal triad consists of the hepatic artery, portal vein which brings blood from the intestine, and bile duct, so it's more oxygenated. The regions around the central vein is more deoxygenated. The different oxygen and nutrient contents mean that hepatocytes play different metabolic roles in the zones between the portal triad and the central vein. Here we plot some zonation marker genes from [@Halpern2017-lq]. " @@ -387,7 +387,7 @@ { "cell_type": "code", "execution_count": null, - "id": "11b6ff6a", + "id": "97d2dcdf", "metadata": {}, "outputs": [], "source": [ @@ -400,7 +400,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8f118a7f", + "id": "ebd23cf2", "metadata": {}, "outputs": [], "source": [ @@ -409,7 +409,7 @@ }, { "cell_type": "markdown", - "id": "d45ac155", + "id": "55b419ef", "metadata": { "lines_to_next_cell": 0 }, @@ -420,7 +420,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ee5b9e5d", + "id": "fc599bdc", "metadata": { "fig.height": 3, "fig.width": 9 @@ -433,7 +433,7 @@ }, { "cell_type": "markdown", - "id": "24cbbc5c", + "id": "aa640894", "metadata": {}, "source": [ "Besides hepatocytes, the liver also has many endothelial cells and Kupffer cells (macrophages). Marker genes of these cells from [@Bonnardel2019-le] are plotted to visualize these cell types in space:" @@ -442,7 +442,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8861442e", + "id": "45858b39", "metadata": {}, "outputs": [], "source": [ @@ -456,7 +456,7 @@ }, { "cell_type": "markdown", - "id": "51b6a615", + "id": "ff1b457d", "metadata": { "lines_to_next_cell": 0 }, @@ -467,7 +467,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2bbabb99", + "id": "699a9522", "metadata": {}, "outputs": [], "source": [ @@ -477,7 +477,7 @@ }, { "cell_type": "markdown", - "id": "bffd4049", + "id": "028e8e9e", "metadata": {}, "source": [ "Expression of this gene does not seem very spatially coherent." @@ -486,7 +486,7 @@ { "cell_type": "code", "execution_count": null, - "id": "14fea7d3", + "id": "cd4721f1", "metadata": {}, "outputs": [], "source": [ @@ -497,7 +497,7 @@ }, { "cell_type": "markdown", - "id": "0cc9f595", + "id": "cf3907ba", "metadata": { "lines_to_next_cell": 0 }, @@ -508,7 +508,7 @@ { "cell_type": "code", "execution_count": null, - "id": "df754fad", + "id": "f7a301de", "metadata": { "fig.height": 3, "fig.width": 9 @@ -521,7 +521,7 @@ }, { "cell_type": "markdown", - "id": "4ca70c24", + "id": "3291acab", "metadata": {}, "source": [ "Wnt2 seems to be more pericentral, while Ltbp4 and Efnb2 seem more periportal.\n", @@ -535,7 +535,7 @@ { "cell_type": "code", "execution_count": null, - "id": "038d73ff", + "id": "d9d8ae87", "metadata": {}, "outputs": [], "source": [ @@ -550,7 +550,7 @@ }, { "cell_type": "markdown", - "id": "4dc549ac", + "id": "1ce85898", "metadata": {}, "source": [ "That's pretty quick for almost 400,000 cells, but there aren't that many genes here. Use the elbow plot to see variance explained by each PC:" @@ -559,7 +559,7 @@ { "cell_type": "code", "execution_count": null, - "id": "63145c0e", + "id": "3d2eb3d7", "metadata": {}, "outputs": [], "source": [ @@ -568,7 +568,7 @@ }, { "cell_type": "markdown", - "id": "4f4b4688", + "id": "f11d5124", "metadata": { "lines_to_next_cell": 0 }, @@ -579,7 +579,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a96db1e1", + "id": "926f2cfa", "metadata": {}, "outputs": [], "source": [ @@ -588,7 +588,7 @@ }, { "cell_type": "markdown", - "id": "01b54cd5", + "id": "dbb67ef4", "metadata": { "lines_to_next_cell": 0 }, @@ -601,7 +601,7 @@ { "cell_type": "code", "execution_count": null, - "id": "02dc4a5c", + "id": "ccacdd8f", "metadata": { "fig.height": 7, "fig.width": 9 @@ -614,7 +614,7 @@ }, { "cell_type": "markdown", - "id": "947b8b0b", + "id": "0fa32194", "metadata": {}, "source": [ "PC1 and PC4 highlight the major blood vessels, while PC2 and PC3 have less spatial structure. While in the CosMX and Xenium datasets on this website, the top PCs have clear spatial structures despite the absence of spatial information in non-spatial PCA because of clear spatial compartments for some cell types, which does not seem to be the case in this dataset except for the blood vessels. We have seen above that some genes have strong spatial structures. \n", @@ -625,7 +625,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f59d9368", + "id": "a2b45996", "metadata": { "fig.height": 7, "fig.width": 9 @@ -638,7 +638,7 @@ }, { "cell_type": "markdown", - "id": "06a0a90d", + "id": "1db04a48", "metadata": {}, "source": [ "There's some spatial structure at a smaller scale, perhaps some negative spatial autocorrelation.\n", @@ -649,7 +649,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e0df811a", + "id": "b41049da", "metadata": {}, "outputs": [], "source": [ @@ -661,7 +661,7 @@ }, { "cell_type": "markdown", - "id": "0949c867", + "id": "4ebeccdf", "metadata": { "lines_to_next_cell": 0 }, @@ -672,7 +672,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7fe5c871", + "id": "7a8f8beb", "metadata": {}, "outputs": [], "source": [ @@ -681,7 +681,7 @@ }, { "cell_type": "markdown", - "id": "24d204c7", + "id": "9edf43cd", "metadata": {}, "source": [ "Here the positive eigenvalues drop sharply from PC1 to PC4, and there is only one very negative eigenvalue which might be interesting, which is unsurprising given the moderately negative Moran's I for `nCounts` and `nGenes`. However, from the [first MERFISH vignette](https://pachterlab.github.io/voyager/articles/vig6_merfish.html#morans-i), none of the genes have very negative Moran's I. Perhaps the negative eigenvalue comes from negative spatial autocorrelation in a gene program or \"eigengene\" and is not obvious from individual genes. This is the beauty of multivariate analysis.\n", @@ -692,7 +692,7 @@ { "cell_type": "code", "execution_count": null, - "id": "eae617f2", + "id": "475364e5", "metadata": {}, "outputs": [], "source": [ @@ -701,7 +701,7 @@ }, { "cell_type": "markdown", - "id": "043583f5", + "id": "a01c180e", "metadata": { "lines_to_next_cell": 0 }, @@ -714,7 +714,7 @@ { "cell_type": "code", "execution_count": null, - "id": "dda7654b", + "id": "2596ef8d", "metadata": { "fig.height": 7, "fig.width": 9, @@ -729,7 +729,7 @@ }, { "cell_type": "markdown", - "id": "66d69fb7", + "id": "048a538c", "metadata": {}, "source": [ "The first two PCs pick up zoning. PC3 seems to have smaller scale spatial structure. PC\"40\" (should really be 300 something) is an example of negative spatial autocorrelation in biology. That Kupffer cells and endothelial cells are scattered among hepatocytes may play a functional role. This does not mean that non-spatial PCA is bad. While MULTISPATI tends not to lose too much variance explained in per PC with positive eigenvalues, it identifies co-expressed genes with spatially structured expression patterns. MULTISPATI tells a different story from non-spatial PCA. PCA cell embeddings are often used for downstream analysis. Whether to use MULTISPATI embeddings instead and which or how many PCs to use depend on the questions asked in the further downstream analyses.\n", @@ -742,7 +742,7 @@ { "cell_type": "code", "execution_count": null, - "id": "490548d8", + "id": "e2695204", "metadata": {}, "outputs": [], "source": [ @@ -757,7 +757,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3df75c34", + "id": "08b92891", "metadata": {}, "outputs": [], "source": [ @@ -773,7 +773,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e234da80", + "id": "bacf71f1", "metadata": {}, "outputs": [], "source": [ @@ -783,7 +783,7 @@ { "cell_type": "code", "execution_count": null, - "id": "304baf97", + "id": "f14e9dc4", "metadata": {}, "outputs": [], "source": [ @@ -801,7 +801,7 @@ }, { "cell_type": "markdown", - "id": "5c37b23f", + "id": "2e6c2bd9", "metadata": {}, "source": [ "In MULTISPATI, Moran's I is high in PC1 and PC2, but then sharply drops. Moran's I for the PC with the most negative eigenvalues is not very negative, which means the large magnitude of that eigenvalue comes from explaining more variance. However, considering the lower bound of Moran's I that is around -0.6 instead of -1, the magnitude of Moran's I for the PC with the most negative eigenvalue is not trivial." @@ -810,7 +810,7 @@ { "cell_type": "code", "execution_count": null, - "id": "36e12476", + "id": "47be5484", "metadata": {}, "outputs": [], "source": [ @@ -819,7 +819,7 @@ }, { "cell_type": "markdown", - "id": "8c2f2579", + "id": "505ac861", "metadata": {}, "source": [ "Non-spatial PCs are not sorted by Moran's I; PC5 has surprising large Moran's I. " @@ -828,7 +828,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c0d488b8", + "id": "c32c4ad9", "metadata": {}, "outputs": [], "source": [ @@ -838,7 +838,7 @@ }, { "cell_type": "markdown", - "id": "5f654463", + "id": "fdaf80a9", "metadata": {}, "source": [ "PC5 must be about zonation. Also show a larger scale:" @@ -847,7 +847,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8c3bbf40", + "id": "5a251cca", "metadata": {}, "outputs": [], "source": [ @@ -857,7 +857,7 @@ }, { "cell_type": "markdown", - "id": "5696decf", + "id": "198177ad", "metadata": { "lines_to_next_cell": 0 }, @@ -869,7 +869,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4cc4a330", + "id": "9a497a6c", "metadata": {}, "outputs": [], "source": [ @@ -879,7 +879,7 @@ { "cell_type": "code", "execution_count": null, - "id": "cf36f04f", + "id": "5c0e8b87", "metadata": {}, "outputs": [], "source": [ @@ -891,7 +891,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d2568f8f", + "id": "5a9cc814", "metadata": { "fig.height": 6, "fig.width": 10 @@ -907,7 +907,7 @@ }, { "cell_type": "markdown", - "id": "fd696979", + "id": "7c48f7e1", "metadata": {}, "source": [ "PCs 1-3 have some fainter clusters outside the main cluster, indicating heterogeneous spatial autocorrelation. Also make Moran scatter plots for MULTISPATI" @@ -916,7 +916,7 @@ { "cell_type": "code", "execution_count": null, - "id": "07cd1332", + "id": "8bbcd6c6", "metadata": {}, "outputs": [], "source": [ @@ -929,7 +929,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a6ee1fd8", + "id": "7f57973e", "metadata": {}, "outputs": [], "source": [ @@ -942,7 +942,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2f2b094d", + "id": "8d919823", "metadata": { "fig.height": 6, "fig.width": 10 @@ -958,7 +958,7 @@ }, { "cell_type": "markdown", - "id": "4d5f5e2a", + "id": "1a8a19b9", "metadata": {}, "source": [ "There are some interesting clusters.\n", @@ -975,7 +975,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2f5cec82", + "id": "9508d565", "metadata": {}, "outputs": [], "source": [ @@ -994,7 +994,7 @@ }, { "cell_type": "markdown", - "id": "9c04efc8", + "id": "94bab14b", "metadata": { "lines_to_next_cell": 0 }, @@ -1005,7 +1005,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e2f05934", + "id": "c372f64d", "metadata": {}, "outputs": [], "source": [ @@ -1024,7 +1024,7 @@ }, { "cell_type": "markdown", - "id": "671f285b", + "id": "28c5f451", "metadata": { "lines_to_next_cell": 0 }, @@ -1035,7 +1035,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ed5c0d56", + "id": "7ff61d43", "metadata": { "fig.height": 4, "fig.width": 11 @@ -1050,7 +1050,7 @@ }, { "cell_type": "markdown", - "id": "e7471044", + "id": "8a4161c5", "metadata": { "lines_to_next_cell": 0 }, @@ -1061,7 +1061,7 @@ { "cell_type": "code", "execution_count": null, - "id": "fb2e08a5", + "id": "c9a872da", "metadata": { "fig.height": 4, "fig.width": 11 @@ -1076,7 +1076,7 @@ }, { "cell_type": "markdown", - "id": "6bf45699", + "id": "d800e478", "metadata": { "lines_to_next_cell": 0 }, @@ -1091,7 +1091,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2bb8ce61", + "id": "38de9164", "metadata": {}, "outputs": [], "source": [ @@ -1100,7 +1100,7 @@ }, { "cell_type": "markdown", - "id": "746834f9", + "id": "b0b06ca3", "metadata": {}, "source": [ "# References" diff --git a/vignettes/nonspatial.ipynb b/vignettes/nonspatial.ipynb index 43b774982..c8bd824cb 100644 --- a/vignettes/nonspatial.ipynb +++ b/vignettes/nonspatial.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "raw", - "id": "52e10556", + "id": "fa414c9c", "metadata": {}, "source": [ "---\n", @@ -26,7 +26,7 @@ { "cell_type": "code", "execution_count": null, - "id": "cfadc723", + "id": "30aeeee2", "metadata": { "tags": [ "remove_cell" @@ -43,7 +43,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0e768087", + "id": "3735eda7", "metadata": { "eval": false, "tags": [ @@ -80,7 +80,7 @@ }, { "cell_type": "markdown", - "id": "cc21ec3c", + "id": "e7a09841", "metadata": { "lines_to_next_cell": 0 }, @@ -95,7 +95,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a6829de9", + "id": "1f640e0b", "metadata": { "name": "setup" }, @@ -123,7 +123,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ce6b339b", + "id": "f655e5b6", "metadata": {}, "outputs": [], "source": [ @@ -138,7 +138,7 @@ }, { "cell_type": "markdown", - "id": "14c7f7ec", + "id": "378e7acc", "metadata": {}, "source": [ "Here we download the filtered [Cell Ranger gene count matrix from the 10X website](https://support.10xgenomics.com/single-cell-gene-expression/datasets/3.0.2/5k_pbmc_v3_nextgem?). The empty droplets have already been removed." @@ -147,7 +147,7 @@ { "cell_type": "code", "execution_count": null, - "id": "11d3bb69", + "id": "78a9bc1a", "metadata": {}, "outputs": [], "source": [ @@ -159,7 +159,7 @@ }, { "cell_type": "markdown", - "id": "2caf0ad5", + "id": "996ecb87", "metadata": { "lines_to_next_cell": 0 }, @@ -170,7 +170,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3795f8cd", + "id": "b56f6f79", "metadata": {}, "outputs": [], "source": [ @@ -180,7 +180,7 @@ { "cell_type": "code", "execution_count": null, - "id": "053597e5", + "id": "7ed7ebce", "metadata": {}, "outputs": [], "source": [ @@ -189,7 +189,7 @@ }, { "cell_type": "markdown", - "id": "69503620", + "id": "06b8778e", "metadata": { "lines_to_next_cell": 0 }, @@ -201,7 +201,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e2c57138", + "id": "5d485bc3", "metadata": {}, "outputs": [], "source": [ @@ -212,7 +212,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a010a691", + "id": "77d69f2e", "metadata": {}, "outputs": [], "source": [ @@ -222,7 +222,7 @@ }, { "cell_type": "markdown", - "id": "f875e9bd", + "id": "ae222a3c", "metadata": {}, "source": [ "The `addPerCellQCMetrics()` function computes the total UMI counts detected per cell (`sum`), number of genes detected per cell (`detected`), `sum` and `detected` for mitochondrial counts, and percentage of mitochondrial counts per cell." @@ -231,7 +231,7 @@ { "cell_type": "code", "execution_count": null, - "id": "cbace157", + "id": "f3750be2", "metadata": {}, "outputs": [], "source": [ @@ -242,7 +242,7 @@ }, { "cell_type": "markdown", - "id": "393fec89", + "id": "4525b670", "metadata": { "lines_to_next_cell": 0 }, @@ -253,7 +253,7 @@ { "cell_type": "code", "execution_count": null, - "id": "382e4d07", + "id": "17532743", "metadata": {}, "outputs": [], "source": [ @@ -263,7 +263,7 @@ { "cell_type": "code", "execution_count": null, - "id": "be839067", + "id": "31b6027c", "metadata": {}, "outputs": [], "source": [ @@ -272,7 +272,7 @@ }, { "cell_type": "markdown", - "id": "66825b00", + "id": "3ac79f1d", "metadata": { "lines_to_next_cell": 0 }, @@ -283,7 +283,7 @@ { "cell_type": "code", "execution_count": null, - "id": "74f336da", + "id": "9f745687", "metadata": {}, "outputs": [], "source": [ @@ -293,7 +293,7 @@ }, { "cell_type": "markdown", - "id": "62c05d45", + "id": "839f41b0", "metadata": { "lines_to_next_cell": 0 }, @@ -305,7 +305,7 @@ { "cell_type": "code", "execution_count": null, - "id": "63b24232", + "id": "d28317c9", "metadata": {}, "outputs": [], "source": [ @@ -317,7 +317,7 @@ }, { "cell_type": "markdown", - "id": "ac6c8d3e", + "id": "0f3e5c18", "metadata": { "lines_to_next_cell": 0 }, @@ -328,7 +328,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8800b4a2", + "id": "5662fd5b", "metadata": {}, "outputs": [], "source": [ @@ -339,7 +339,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1cde7727", + "id": "fecffe7b", "metadata": {}, "outputs": [], "source": [ @@ -350,7 +350,7 @@ }, { "cell_type": "markdown", - "id": "76445f7f", + "id": "426b9533", "metadata": { "lines_to_next_cell": 0 }, @@ -361,7 +361,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c042f8d1", + "id": "e1cfe426", "metadata": {}, "outputs": [], "source": [ @@ -370,7 +370,7 @@ }, { "cell_type": "markdown", - "id": "5e2a6be1", + "id": "a1172086", "metadata": {}, "source": [ "Variance explained drops sharply from PC1 and again from PC4 and then levels off. Plot genes with the largest loadings of the top 4 PCs:" @@ -379,7 +379,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ed4120c7", + "id": "c5adc110", "metadata": { "lines_to_next_cell": 2 }, @@ -390,7 +390,7 @@ }, { "cell_type": "markdown", - "id": "cc51e3fe", + "id": "8acd4bef", "metadata": {}, "source": [ "To keep a little more information, we use 10 PCs, after which variance explained levels off even more." @@ -399,7 +399,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3b46248f", + "id": "63b42867", "metadata": {}, "outputs": [], "source": [ @@ -414,7 +414,7 @@ }, { "cell_type": "markdown", - "id": "5671c406", + "id": "971ac86d", "metadata": {}, "source": [ "Here we plot the cells in the first 4 PCs in a matrix plot. The diagonals are density plots of the number of cells as projected on each PC. The x axis should correspond to the columns of the matrix plot, and the y axis should correspond to the rows, so the plot in row 1 column 2 has PC2 in the x axis and PC1 in the y axis. The cells are colored by clusters found in the previous code chunk." @@ -423,7 +423,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f01489b2", + "id": "5ae1214b", "metadata": { "fig.height": 9, "fig.width": 9 @@ -435,7 +435,7 @@ }, { "cell_type": "markdown", - "id": "2087558c", + "id": "3946a3b1", "metadata": { "lines_to_next_cell": 0 }, @@ -446,7 +446,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a115ee1d", + "id": "b51de023", "metadata": {}, "outputs": [], "source": [ @@ -455,7 +455,7 @@ }, { "cell_type": "markdown", - "id": "782d024f", + "id": "3c39909d", "metadata": { "lines_to_next_cell": 0 }, @@ -466,7 +466,7 @@ { "cell_type": "code", "execution_count": null, - "id": "30213759", + "id": "c57dc5f2", "metadata": { "lines_to_next_cell": 2 }, @@ -479,7 +479,7 @@ }, { "cell_type": "markdown", - "id": "0da2ebf4", + "id": "06f9ef57", "metadata": {}, "source": [ "See how specific the top markers are to each cluster:" @@ -488,7 +488,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d7b36b5b", + "id": "00bf208b", "metadata": {}, "outputs": [], "source": [ @@ -499,7 +499,7 @@ { "cell_type": "code", "execution_count": null, - "id": "edef65f4", + "id": "afcd5b13", "metadata": {}, "outputs": [], "source": [ @@ -509,7 +509,7 @@ }, { "cell_type": "markdown", - "id": "4634bf0e", + "id": "cf38a146", "metadata": { "lines_to_next_cell": 0 }, @@ -520,7 +520,7 @@ { "cell_type": "code", "execution_count": null, - "id": "bc619b69", + "id": "a78c72e9", "metadata": {}, "outputs": [], "source": [ @@ -532,7 +532,7 @@ }, { "cell_type": "markdown", - "id": "174d0e9b", + "id": "b7523ec9", "metadata": { "lines_to_next_cell": 0 }, @@ -544,7 +544,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0c5e6e2e", + "id": "c852ea0f", "metadata": {}, "outputs": [], "source": [ @@ -570,7 +570,7 @@ }, { "cell_type": "markdown", - "id": "998635a7", + "id": "df7773ff", "metadata": { "lines_to_next_cell": 0 }, @@ -581,7 +581,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7d17ffde", + "id": "806ff825", "metadata": {}, "outputs": [], "source": [ @@ -591,7 +591,7 @@ }, { "cell_type": "markdown", - "id": "ed464939", + "id": "4f8c70c4", "metadata": { "lines_to_next_cell": 0 }, @@ -602,7 +602,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f68105a8", + "id": "60a27209", "metadata": {}, "outputs": [], "source": [ @@ -611,7 +611,7 @@ }, { "cell_type": "markdown", - "id": "be0bcfa5", + "id": "d880178a", "metadata": { "lines_to_next_cell": 0 }, @@ -622,7 +622,7 @@ { "cell_type": "code", "execution_count": null, - "id": "62ef9cf6", + "id": "d81b9e79", "metadata": {}, "outputs": [], "source": [ @@ -632,7 +632,7 @@ }, { "cell_type": "markdown", - "id": "c98e7992", + "id": "2acafb12", "metadata": { "lines_to_next_cell": 0 }, @@ -647,7 +647,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c9b561a5", + "id": "a0e5c106", "metadata": {}, "outputs": [], "source": [ @@ -656,7 +656,7 @@ }, { "cell_type": "markdown", - "id": "6983a23f", + "id": "c6fad14a", "metadata": { "lines_to_next_cell": 0 }, @@ -667,7 +667,7 @@ { "cell_type": "code", "execution_count": null, - "id": "188a463e", + "id": "6d36b7c2", "metadata": {}, "outputs": [], "source": [ @@ -676,7 +676,7 @@ }, { "cell_type": "markdown", - "id": "3723283f", + "id": "98c22e07", "metadata": { "lines_to_next_cell": 0 }, @@ -687,7 +687,7 @@ { "cell_type": "code", "execution_count": null, - "id": "75d958b8", + "id": "01318671", "metadata": {}, "outputs": [], "source": [ @@ -697,7 +697,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8d4cdd78", + "id": "e5cf44a0", "metadata": {}, "outputs": [], "source": [ @@ -706,7 +706,7 @@ }, { "cell_type": "markdown", - "id": "7df43ec0", + "id": "d843c9f6", "metadata": {}, "source": [ "There is one main cluster on this plot for the number of genes detected and for the percentage of mitochondrial counts. However, cells are somewhat separated by gene expression clusters. This is not surprising because the gene expression clusters are also based on the k nearest neighbor graph. Cluster 4 cells have a higher percentage of mitochondrial counts and so do their neighbors. \n", @@ -718,7 +718,7 @@ { "cell_type": "code", "execution_count": null, - "id": "50f8fe74", + "id": "2ce2f54f", "metadata": {}, "outputs": [], "source": [ @@ -727,7 +727,7 @@ }, { "cell_type": "markdown", - "id": "d630bafd", + "id": "e3be466e", "metadata": { "lines_to_next_cell": 0 }, @@ -738,7 +738,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9ced25d1", + "id": "9992920f", "metadata": { "fig.height": 6, "fig.width": 8 @@ -750,7 +750,7 @@ }, { "cell_type": "markdown", - "id": "317c9cd4", + "id": "ddc0aae0", "metadata": { "lines_to_next_cell": 0 }, @@ -761,7 +761,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0f74c5d9", + "id": "fcb9b1c6", "metadata": { "fig.height": 6, "fig.width": 8 @@ -775,7 +775,7 @@ }, { "cell_type": "markdown", - "id": "59b0f025", + "id": "8eccbd01", "metadata": { "lines_to_next_cell": 0 }, @@ -786,7 +786,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2882940c", + "id": "5c4e8829", "metadata": {}, "outputs": [], "source": [ @@ -796,7 +796,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f31b2649", + "id": "66b6d079", "metadata": {}, "outputs": [], "source": [ @@ -808,7 +808,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3bec2f99", + "id": "e6cf0bbc", "metadata": {}, "outputs": [], "source": [ @@ -819,7 +819,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d3edc598", + "id": "49324a44", "metadata": {}, "outputs": [], "source": [ @@ -832,7 +832,7 @@ }, { "cell_type": "markdown", - "id": "371eccc9", + "id": "3fce744d", "metadata": {}, "source": [ "The y axis is log transformed (hence that warning when some bins have no cells), so the color of cells in the long tail can be seen because most cells don't have very strong local Moran's I. Cells in cluster 7 have high local Moran's I in total UMI counts and genes detected, which means that they tend to be more homogeneous in these QC metrics.\n", @@ -843,7 +843,7 @@ { "cell_type": "code", "execution_count": null, - "id": "49f5da50", + "id": "945fc915", "metadata": {}, "outputs": [], "source": [ @@ -854,7 +854,7 @@ }, { "cell_type": "markdown", - "id": "19739f04", + "id": "c6b138de", "metadata": {}, "source": [ "Cells more locally homogeneous in total UMI counts are also more homogeneous in number of genes detected, which is not surprising given the correlation between the two." @@ -863,7 +863,7 @@ { "cell_type": "code", "execution_count": null, - "id": "306bd3bc", + "id": "f6cb9214", "metadata": {}, "outputs": [], "source": [ @@ -874,7 +874,7 @@ }, { "cell_type": "markdown", - "id": "b1f0f0c1", + "id": "6a2cb00c", "metadata": { "lines_to_next_cell": 0 }, @@ -887,7 +887,7 @@ { "cell_type": "code", "execution_count": null, - "id": "354aba51", + "id": "31d42b11", "metadata": {}, "outputs": [], "source": [ @@ -900,7 +900,7 @@ }, { "cell_type": "markdown", - "id": "1e7d99b3", + "id": "14890c96", "metadata": { "lines_to_next_cell": 0 }, @@ -915,7 +915,7 @@ { "cell_type": "code", "execution_count": null, - "id": "31a9007c", + "id": "1f2236eb", "metadata": {}, "outputs": [], "source": [ @@ -925,7 +925,7 @@ { "cell_type": "code", "execution_count": null, - "id": "94489457", + "id": "aaaa584b", "metadata": { "fig.height": 6, "fig.width": 8 @@ -938,7 +938,7 @@ }, { "cell_type": "markdown", - "id": "d234886d", + "id": "8c6b694c", "metadata": {}, "source": [ "Here we make the same non-spatial plots for LOSH as in local Moran's I." @@ -947,7 +947,7 @@ { "cell_type": "code", "execution_count": null, - "id": "41d79381", + "id": "0b0d4220", "metadata": {}, "outputs": [], "source": [ @@ -957,7 +957,7 @@ { "cell_type": "code", "execution_count": null, - "id": "299916c3", + "id": "eb5ad527", "metadata": {}, "outputs": [], "source": [ @@ -969,7 +969,7 @@ { "cell_type": "code", "execution_count": null, - "id": "57512e88", + "id": "3edbf7ad", "metadata": {}, "outputs": [], "source": [ @@ -982,7 +982,7 @@ }, { "cell_type": "markdown", - "id": "c63f639c", + "id": "0f4c3439", "metadata": {}, "source": [ "Here, clusters 2 and 6 tend to be more locally heterogeneous. How do total counts and genes detected relate in LOSH?" @@ -991,7 +991,7 @@ { "cell_type": "code", "execution_count": null, - "id": "537172f7", + "id": "e2dba446", "metadata": {}, "outputs": [], "source": [ @@ -1001,7 +1001,7 @@ }, { "cell_type": "markdown", - "id": "dbc90517", + "id": "4ce341fb", "metadata": {}, "source": [ "While generally cells higher in LOSH in total counts are also higher in LOSH in genes detected, there are some outliers that are very high in both, with more heterogeneous neighborhoods. Absolute distance to the neighbors is not taken into account when the adjacency matrix is row normalized. It would be interesting to see if those outliers tend to be further away from their 10 nearest neighbors, or in a region in the PCA space where cells are further apart.\n", @@ -1012,7 +1012,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d48dbc3d", + "id": "40b974b2", "metadata": {}, "outputs": [], "source": [ @@ -1022,7 +1022,7 @@ }, { "cell_type": "markdown", - "id": "6f99fa08", + "id": "1c70fe3d", "metadata": { "lines_to_next_cell": 0 }, @@ -1036,7 +1036,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ab73b87d", + "id": "6fe69585", "metadata": {}, "outputs": [], "source": [ @@ -1051,7 +1051,7 @@ }, { "cell_type": "markdown", - "id": "7995ac24", + "id": "8d1464e6", "metadata": { "lines_to_next_cell": 0 }, @@ -1062,7 +1062,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4fa5ad1a", + "id": "7a3ff287", "metadata": {}, "outputs": [], "source": [ @@ -1071,7 +1071,7 @@ }, { "cell_type": "markdown", - "id": "427168d2", + "id": "3c77b60d", "metadata": { "lines_to_next_cell": 0 }, @@ -1082,7 +1082,7 @@ { "cell_type": "code", "execution_count": null, - "id": "47cd3500", + "id": "bb39cd68", "metadata": {}, "outputs": [], "source": [ @@ -1091,7 +1091,7 @@ }, { "cell_type": "markdown", - "id": "6f07ce81", + "id": "f1713322", "metadata": { "lines_to_next_cell": 0 }, @@ -1102,7 +1102,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4fe3afe6", + "id": "2a74369d", "metadata": {}, "outputs": [], "source": [ @@ -1115,7 +1115,7 @@ }, { "cell_type": "markdown", - "id": "c9ca715f", + "id": "8a451ff2", "metadata": {}, "source": [ "The top marker genes all have quite positive Moran's I on the k nearest neighbor graph. It would also be interesting to color this histogram by gene sets. Since the k nearest neighbor graph was found in PCA space, which is based on gene expression, as expected, Moran's I with this graph is mostly positive, although often not that strong. A small number of genes have slightly negative Moran's I. What do the top genes look like in PCA?" @@ -1124,7 +1124,7 @@ { "cell_type": "code", "execution_count": null, - "id": "cda4c0dd", + "id": "dc83e8d0", "metadata": { "fig.height": 6, "fig.width": 8 @@ -1138,7 +1138,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ec5ff404", + "id": "9c339495", "metadata": {}, "outputs": [], "source": [ @@ -1148,7 +1148,7 @@ }, { "cell_type": "markdown", - "id": "f471116b", + "id": "33ec71ff", "metadata": {}, "source": [ "They are all marker genes for the same cluster, cluster 9. Perhaps these genes have high Moran's I because they are specific to a cell type. Then how does the Moran's I relate to cluster AUC and cluster differential expression p-value?" @@ -1157,7 +1157,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5d5544e2", + "id": "c93ae38a", "metadata": {}, "outputs": [], "source": [ @@ -1168,7 +1168,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ceee26b4", + "id": "a4bd59a5", "metadata": {}, "outputs": [], "source": [ @@ -1180,7 +1180,7 @@ }, { "cell_type": "markdown", - "id": "9ec975eb", + "id": "ef037202", "metadata": { "lines_to_next_cell": 0 }, @@ -1191,7 +1191,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4cd4369c", + "id": "638b7c89", "metadata": {}, "outputs": [], "source": [ @@ -1204,7 +1204,7 @@ }, { "cell_type": "markdown", - "id": "6ca3809b", + "id": "44b4404c", "metadata": {}, "source": [ "Generally, more significant marker genes tend to have higher Moran's I. This is not surprising because the clusters and Moran's I here are both based on the k nearest neighbor graph." @@ -1213,7 +1213,7 @@ { "cell_type": "code", "execution_count": null, - "id": "17b0af98", + "id": "b111360b", "metadata": {}, "outputs": [], "source": [ @@ -1226,7 +1226,7 @@ }, { "cell_type": "markdown", - "id": "3b5a3148", + "id": "18bdfa6a", "metadata": { "lines_to_next_cell": 0 }, @@ -1239,7 +1239,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c58ac733", + "id": "6cd03d9e", "metadata": {}, "outputs": [], "source": [ @@ -1249,7 +1249,7 @@ { "cell_type": "code", "execution_count": null, - "id": "14264286", + "id": "aa25b386", "metadata": {}, "outputs": [], "source": [ @@ -1259,7 +1259,7 @@ { "cell_type": "code", "execution_count": null, - "id": "94f50460", + "id": "28cf4101", "metadata": {}, "outputs": [], "source": [ @@ -1268,7 +1268,7 @@ }, { "cell_type": "markdown", - "id": "5e1babd6", + "id": "124cfc2c", "metadata": {}, "source": [ "They all seem to be very significant. \n", @@ -1279,7 +1279,7 @@ { "cell_type": "code", "execution_count": null, - "id": "fb435c4f", + "id": "03e7f2e9", "metadata": {}, "outputs": [], "source": [ @@ -1292,7 +1292,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e113c194", + "id": "731b845d", "metadata": {}, "outputs": [], "source": [ @@ -1301,7 +1301,7 @@ }, { "cell_type": "markdown", - "id": "75c5404b", + "id": "222deaf8", "metadata": { "lines_to_next_cell": 0 }, @@ -1314,7 +1314,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0d091b57", + "id": "b40dac08", "metadata": {}, "outputs": [], "source": [ @@ -1324,7 +1324,7 @@ { "cell_type": "code", "execution_count": null, - "id": "76a835e8", + "id": "7ee367a8", "metadata": { "fig.height": 9, "fig.width": 12 @@ -1338,7 +1338,7 @@ }, { "cell_type": "markdown", - "id": "db7944cb", + "id": "d4006697", "metadata": {}, "source": [ "We will also plot the histograms, but for now the results need to be added to `colData` first." @@ -1347,7 +1347,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ebf6aee0", + "id": "bee87436", "metadata": {}, "outputs": [], "source": [ @@ -1363,7 +1363,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0dfd7c43", + "id": "1ef27848", "metadata": { "fig.height": 12, "fig.width": 8 @@ -1379,7 +1379,7 @@ }, { "cell_type": "markdown", - "id": "9b477979", + "id": "fa8400a5", "metadata": { "lines_to_next_cell": 0 }, @@ -1392,7 +1392,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3437b9e6", + "id": "92d3ed89", "metadata": {}, "outputs": [], "source": [ @@ -1410,7 +1410,7 @@ }, { "cell_type": "markdown", - "id": "1f5f7abd", + "id": "5fe82493", "metadata": {}, "source": [ "For this gene, just like for total UMI counts, there are two wings and a central value where local Moran's I is around 0. Generally, cells with higher expression of this gene have higher local Moran's I for this gene as well. The density contours show that cells concentrate around 0 expression and some weaker positive local Moran. The streak of cells with 0 expression means that many cells don't express this gene, and their neighbors have low and slightly homogeneous expression of this gene. This pattern may be different for different genes. Also, the p-values for each cell for local Moran's I are available and corrected for multiple hypothesis testing, and can be plotted. The p-values are based on the z score of the local Moran statistic, although how the statistic is distributed for gene expression data warrants more investigation. This p-value can also be computed with permutation (see `localmoran_perm()`). " @@ -1419,7 +1419,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e39799f1", + "id": "c8df91ce", "metadata": {}, "outputs": [], "source": [ @@ -1428,7 +1428,7 @@ }, { "cell_type": "markdown", - "id": "b5b931a6", + "id": "ec5d1336", "metadata": {}, "source": [ "## LOSH" @@ -1437,7 +1437,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0680afb5", + "id": "f0d977c5", "metadata": {}, "outputs": [], "source": [ @@ -1447,7 +1447,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d70751a9", + "id": "518c07d5", "metadata": { "fig.height": 9, "fig.width": 12 @@ -1460,7 +1460,7 @@ }, { "cell_type": "markdown", - "id": "e96b2c77", + "id": "ad54bf6d", "metadata": { "lines_to_next_cell": 0 }, @@ -1473,7 +1473,7 @@ { "cell_type": "code", "execution_count": null, - "id": "fcccd8f5", + "id": "342fe838", "metadata": {}, "outputs": [], "source": [ @@ -1489,7 +1489,7 @@ { "cell_type": "code", "execution_count": null, - "id": "67ee8413", + "id": "8c952d9c", "metadata": { "fig.height": 12, "fig.width": 8 @@ -1505,7 +1505,7 @@ }, { "cell_type": "markdown", - "id": "a42fbd3f", + "id": "48a1dfa9", "metadata": {}, "source": [ "The relationship between expression and LOSH is more complicated. For some genes, such as the top marker gene for cluster 1 LYAR, cells in the cluster with higher expression also have higher LOSH - much like how in Poisson and negative binomial distributions, higher mean also means higher variance. However, some genes, such as the top marker gene for cluster 2 CTSS, have lower LOSH among cells that have higher expression, which means expression of this gene is more homogeneous within the cluster, consistent with local Moran. " @@ -1514,7 +1514,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7c725bbf", + "id": "f1bfc32e", "metadata": {}, "outputs": [], "source": [ @@ -1532,7 +1532,7 @@ }, { "cell_type": "markdown", - "id": "13e9ce99", + "id": "704c6115", "metadata": { "lines_to_next_cell": 0 }, @@ -1547,7 +1547,7 @@ { "cell_type": "code", "execution_count": null, - "id": "95865540", + "id": "dd90efa4", "metadata": {}, "outputs": [], "source": [ @@ -1556,7 +1556,7 @@ }, { "cell_type": "markdown", - "id": "90a6dd06", + "id": "8daf6880", "metadata": { "lines_to_next_cell": 0 }, @@ -1567,7 +1567,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d00c4aa4", + "id": "5a35ffe6", "metadata": {}, "outputs": [], "source": [ @@ -1576,7 +1576,7 @@ }, { "cell_type": "markdown", - "id": "f3286d66", + "id": "c59978d0", "metadata": { "lines_to_next_cell": 0 }, @@ -1587,7 +1587,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7cf2b8b5", + "id": "c8c7de9e", "metadata": {}, "outputs": [], "source": [ @@ -1598,7 +1598,7 @@ { "cell_type": "code", "execution_count": null, - "id": "69f137ba", + "id": "2b294ab5", "metadata": { "fig.height": 9, "fig.width": 9 @@ -1612,7 +1612,7 @@ }, { "cell_type": "markdown", - "id": "d252a2f6", + "id": "b1121650", "metadata": { "lines_to_next_cell": 0 }, @@ -1627,7 +1627,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d35c1e36", + "id": "21d0a744", "metadata": { "lines_to_next_cell": 0 }, @@ -1638,7 +1638,7 @@ }, { "cell_type": "markdown", - "id": "7e7d02fc", + "id": "b148aa93", "metadata": {}, "source": [] } diff --git a/vignettes/sfemethod.ipynb b/vignettes/sfemethod.ipynb index cb3ece80a..b6a91c91b 100644 --- a/vignettes/sfemethod.ipynb +++ b/vignettes/sfemethod.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "raw", - "id": "c70e3484", + "id": "6d998e64", "metadata": {}, "source": [ "---\n", @@ -26,7 +26,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e995a348", + "id": "b193f4a1", "metadata": { "tags": [ "remove_cell" @@ -42,7 +42,7 @@ }, { "cell_type": "markdown", - "id": "30745c0a", + "id": "77af9b44", "metadata": {}, "source": [ "# Introduction\n", @@ -56,7 +56,7 @@ { "cell_type": "code", "execution_count": null, - "id": "171eb94a", + "id": "e5fce4f6", "metadata": {}, "outputs": [], "source": [ @@ -66,7 +66,7 @@ }, { "cell_type": "markdown", - "id": "37f87aa5", + "id": "3eabdff1", "metadata": {}, "source": [ "`Voyager` categorizes exploratory spatial data analysis (ESDA) methods by the number of variables and whether the method gives one result for the entire dataset (global) or gives results at each location (local). While the process to create an `SFEMethod` object is mostly the same across categories, each category has specific arguments.\n", @@ -83,7 +83,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f1cdcf3a", + "id": "832cecae", "metadata": {}, "outputs": [], "source": [ @@ -92,7 +92,7 @@ }, { "cell_type": "markdown", - "id": "79dee2c8", + "id": "f9a89755", "metadata": {}, "source": [ "This is the code used to create the `SFEMethod` object to run Moran's I, with the `SFEMethod()` constructor:" @@ -101,7 +101,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2048f1ca", + "id": "3eecdfa3", "metadata": { "eval": false }, @@ -120,7 +120,7 @@ }, { "cell_type": "markdown", - "id": "de2c0533", + "id": "ac3d8961", "metadata": {}, "source": [ "The `package` argument is used to check if the package is installed when the method is run. The function to run the method is in the `fun` argument. All univariate methods that use a spatial neighborhood graph (`use_graph = TRUE`) must have arguments:\n", @@ -139,7 +139,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1b4fa3cc", + "id": "77819ae4", "metadata": { "eval": false }, @@ -159,7 +159,7 @@ }, { "cell_type": "markdown", - "id": "cd58c674", + "id": "d0ce041e", "metadata": {}, "source": [ "For univariate or bivariate global methods, the function must have:\n", @@ -174,7 +174,7 @@ { "cell_type": "code", "execution_count": null, - "id": "58db1afc", + "id": "5965fc60", "metadata": { "eval": false }, @@ -189,7 +189,7 @@ }, { "cell_type": "markdown", - "id": "36d7883c", + "id": "59a4e2c9", "metadata": {}, "source": [ "The function in `fun` for univariate methods that don't use a spatial neighborhood graph must have arguments `x` and `coords_df` (`sf` data frame for the spatial coordinates) and other arguments are allowed. This is the `.variogram` function:" @@ -198,7 +198,7 @@ { "cell_type": "code", "execution_count": null, - "id": "87903be7", + "id": "578f5ac6", "metadata": { "eval": false }, @@ -226,7 +226,7 @@ }, { "cell_type": "markdown", - "id": "ac9fc988", + "id": "df56e94b", "metadata": {}, "source": [ "The rule for `reorganize_fun` remains the same, and this is the `.other2df` function:" @@ -235,7 +235,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ee732d46", + "id": "0bd5722e", "metadata": { "eval": false }, @@ -252,7 +252,7 @@ }, { "cell_type": "markdown", - "id": "a153e2cb", + "id": "cedb15d4", "metadata": {}, "source": [ "## Local\n", @@ -262,7 +262,7 @@ { "cell_type": "code", "execution_count": null, - "id": "fab90011", + "id": "e5f67583", "metadata": {}, "outputs": [], "source": [ @@ -271,7 +271,7 @@ }, { "cell_type": "markdown", - "id": "f6e1fbb5", + "id": "5db9f95d", "metadata": {}, "source": [ "This is the code used to create the `SFEMethod` object for `localmoran`:" @@ -280,7 +280,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6a68116e", + "id": "f82229aa", "metadata": { "eval": false }, @@ -297,7 +297,7 @@ }, { "cell_type": "markdown", - "id": "35935deb", + "id": "07ddcfc1", "metadata": {}, "source": [ "`spdep::localmoran` already has the right arguments, including `x`, `listw`, and `zero.policy`.\n", @@ -310,7 +310,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8828fc40", + "id": "d849bd2b", "metadata": { "eval": false }, @@ -327,7 +327,7 @@ }, { "cell_type": "markdown", - "id": "c4f8952a", + "id": "a0872585", "metadata": {}, "source": [ "The function must have arguments:\n", @@ -345,7 +345,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7dea65d9", + "id": "7cb17cff", "metadata": {}, "outputs": [], "source": [ @@ -354,7 +354,7 @@ }, { "cell_type": "markdown", - "id": "7b44fc0e", + "id": "a9565c59", "metadata": {}, "source": [ "These are the bivariate local methods in `Voyager`:" @@ -363,7 +363,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4c91c3b6", + "id": "31f2f316", "metadata": {}, "outputs": [], "source": [ @@ -372,7 +372,7 @@ }, { "cell_type": "markdown", - "id": "d3a2a385", + "id": "86e4556c", "metadata": {}, "source": [ "The `SFEMethod` construction for bivariate methods is similar to that of univariate methods, except that the function in `fun` must have argument `y` after `x`. This is the code used to create the `SFEMethod` object for `lee`, Lee's L:" @@ -381,7 +381,7 @@ { "cell_type": "code", "execution_count": null, - "id": "eff6ad3e", + "id": "e4cf5ead", "metadata": { "eval": false }, @@ -395,7 +395,7 @@ }, { "cell_type": "markdown", - "id": "d710070d", + "id": "7eaf8277", "metadata": {}, "source": [ "Note the `use_matrix` argument, which specific to bivariate methods. It means whether the method can take a matrix as argument and compute the statistic for all pairwise combinations of the matrix's rows. This way the computation can be expressed as matrix operations which is much more efficient than R loops because the loops are pushed to the underlying C and Fortran code in BLAS and the `Matrix` package for sparse matrices.\n", @@ -406,7 +406,7 @@ { "cell_type": "code", "execution_count": null, - "id": "77cb8066", + "id": "8ce4b820", "metadata": { "eval": false }, @@ -430,7 +430,7 @@ }, { "cell_type": "markdown", - "id": "ec921907", + "id": "e51958f9", "metadata": {}, "source": [ "Due to the matrix operation, `listw` can be a sparse or dense adjacency matrix of the spatial neighborhood graph. To conform to scRNA-seq conventions, `x` and `y` have genes in rows if they are matrices.\n", @@ -444,7 +444,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9ac9817f", + "id": "45b7156a", "metadata": {}, "outputs": [], "source": [ @@ -453,7 +453,7 @@ }, { "cell_type": "markdown", - "id": "4d6d4758", + "id": "be5aefc1", "metadata": {}, "source": [ "The `SFEMethod` construction for bivariate methods is similar to that of univariate methods, except for two arguments: `joint` to indicate whether it makes sense to run the method for multiple samples jointly just like in non-spatial PCA, and `dest` to indicate whether the results should go into `reducedDims(sfe)` or `colData(sfe)`. This is the code for a multivariate generalization of local Geary's C [@Anselin2019-uv] with permutation testing:" @@ -462,7 +462,7 @@ { "cell_type": "code", "execution_count": null, - "id": "925d2203", + "id": "5d08ddc9", "metadata": { "eval": false }, @@ -491,7 +491,7 @@ }, { "cell_type": "markdown", - "id": "cb1733b3", + "id": "ebc0db2c", "metadata": {}, "source": [ "Here the results, as a single vector, goes into `colData(sfe)`, and it does not make sense to run it across multiple samples jointly as each sample has a separate spatial neighborhood graph, so it will be run on each sample separately. \n", diff --git a/vignettes/variogram.ipynb b/vignettes/variogram.ipynb index 9bfe59a70..d5fddf3f1 100644 --- a/vignettes/variogram.ipynb +++ b/vignettes/variogram.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "raw", - "id": "8ec08f16", + "id": "95097468", "metadata": {}, "source": [ "---\n", @@ -26,7 +26,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2005b5e4", + "id": "86c2dd92", "metadata": { "tags": [ "remove_cell" @@ -43,7 +43,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b9c99139", + "id": "282b550a", "metadata": { "eval": false, "tags": [ @@ -78,7 +78,7 @@ }, { "cell_type": "markdown", - "id": "21b3aab5", + "id": "ae5d63ea", "metadata": { "lines_to_next_cell": 0 }, @@ -107,7 +107,7 @@ { "cell_type": "code", "execution_count": null, - "id": "df38619f", + "id": "208acde2", "metadata": { "message": false }, @@ -127,7 +127,7 @@ }, { "cell_type": "markdown", - "id": "1fed1d55", + "id": "c4cd833f", "metadata": { "lines_to_next_cell": 0 }, @@ -138,7 +138,7 @@ { "cell_type": "code", "execution_count": null, - "id": "12cf5ed1", + "id": "7f2963e4", "metadata": {}, "outputs": [], "source": [ @@ -148,7 +148,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2839d0bc", + "id": "a7bdc3fa", "metadata": {}, "outputs": [], "source": [ @@ -159,7 +159,7 @@ { "cell_type": "code", "execution_count": null, - "id": "79d2e9dc", + "id": "f156c420", "metadata": {}, "outputs": [], "source": [ @@ -168,7 +168,7 @@ }, { "cell_type": "markdown", - "id": "378fe014", + "id": "a1539afe", "metadata": { "lines_to_next_cell": 0 }, @@ -179,7 +179,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d97ca8ad", + "id": "bb778406", "metadata": {}, "outputs": [], "source": [ @@ -189,7 +189,7 @@ }, { "cell_type": "markdown", - "id": "0c6e16a8", + "id": "a679866a", "metadata": {}, "source": [ "# Variogram\n", @@ -199,7 +199,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8893bdbb", + "id": "bea2bccb", "metadata": {}, "outputs": [], "source": [ @@ -210,7 +210,7 @@ { "cell_type": "code", "execution_count": null, - "id": "bec6e210", + "id": "83bf41b7", "metadata": {}, "outputs": [], "source": [ @@ -219,7 +219,7 @@ }, { "cell_type": "markdown", - "id": "d6af68a5", + "id": "c1d47825", "metadata": {}, "source": [ "The data is binned by distance between spots and the variance is computed for each bin. While `gstat`'s plotting functions say \"semivariance\", because the data is scaled so the variance is 1, I do think the variance rather than semivariance is plotted. The numbers by the points in the plot indicate the number of pairs of spots in each bin. \"Ste\" means the Matern model with M. Stein's parameterization was fitted to the points. \n", @@ -236,7 +236,7 @@ { "cell_type": "code", "execution_count": null, - "id": "036d1459", + "id": "16a7cb94", "metadata": { "fig.height": 6, "fig.width": 9 @@ -249,7 +249,7 @@ }, { "cell_type": "markdown", - "id": "a16ae005", + "id": "d950ae3b", "metadata": { "lines_to_next_cell": 0 }, @@ -262,7 +262,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1ec6bb76", + "id": "47a79429", "metadata": {}, "outputs": [], "source": [ @@ -271,7 +271,7 @@ }, { "cell_type": "markdown", - "id": "4e4ae2c4", + "id": "f0ea9862", "metadata": { "lines_to_next_cell": 0 }, @@ -282,7 +282,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6e79c242", + "id": "a426c6d4", "metadata": {}, "outputs": [], "source": [ @@ -292,7 +292,7 @@ }, { "cell_type": "markdown", - "id": "092d55f0", + "id": "fb720059", "metadata": { "lines_to_next_cell": 0 }, @@ -305,7 +305,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0cb50458", + "id": "4aea24e3", "metadata": {}, "outputs": [], "source": [ @@ -318,7 +318,7 @@ { "cell_type": "code", "execution_count": null, - "id": "efb7d291", + "id": "7339850d", "metadata": { "fig.height": 6, "fig.width": 10 @@ -330,7 +330,7 @@ }, { "cell_type": "markdown", - "id": "0bba7c5c", + "id": "b33948c6", "metadata": {}, "source": [ "MT-RNR1 is more widely expressed. IGKC and ICHC3 are restricted to smaller areas, and IGHM is restricted to even smaller areas. Note that genes with variograms in the same cluster don't have to be co-expressed; they only need to have similar length scales and strengths of spatial autocorrelation.\n", @@ -345,7 +345,7 @@ { "cell_type": "code", "execution_count": null, - "id": "90a5c928", + "id": "6d1f38e0", "metadata": {}, "outputs": [], "source": [ @@ -358,7 +358,7 @@ { "cell_type": "code", "execution_count": null, - "id": "28536314", + "id": "e7c661ec", "metadata": {}, "outputs": [], "source": [ @@ -368,7 +368,7 @@ }, { "cell_type": "markdown", - "id": "3a74ee3f", + "id": "ac495b67", "metadata": {}, "source": [ "Here the line is the variogram model fitted to all directions and the text describes this model. The points show the angles in different colors. Zero degree points north (up), and the angles go clockwise.\n", @@ -381,7 +381,7 @@ { "cell_type": "code", "execution_count": null, - "id": "43d6afd3", + "id": "cd283de0", "metadata": {}, "outputs": [], "source": [ @@ -391,7 +391,7 @@ }, { "cell_type": "markdown", - "id": "0d374430", + "id": "f350ad67", "metadata": {}, "source": [ "The `width` argument is the width of the bins, and `cutoff` is the maximum distance." @@ -400,7 +400,7 @@ { "cell_type": "code", "execution_count": null, - "id": "04429346", + "id": "be7ae11e", "metadata": {}, "outputs": [], "source": [ @@ -409,7 +409,7 @@ }, { "cell_type": "markdown", - "id": "4d1a20a6", + "id": "d9ed7be6", "metadata": {}, "source": [ "# Cross variogram\n", @@ -425,7 +425,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8f44a60b", + "id": "8a8f4c9c", "metadata": {}, "outputs": [], "source": [ @@ -436,7 +436,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3688b24c", + "id": "ba4573b7", "metadata": {}, "outputs": [], "source": [ @@ -445,7 +445,7 @@ }, { "cell_type": "markdown", - "id": "ea1bedff", + "id": "d9b5b2b4", "metadata": { "lines_to_next_cell": 0 }, @@ -458,7 +458,7 @@ { "cell_type": "code", "execution_count": null, - "id": "da2e5a31", + "id": "a55dbafe", "metadata": {}, "outputs": [], "source": [ @@ -470,7 +470,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0dc0b558", + "id": "32741eb2", "metadata": {}, "outputs": [], "source": [ @@ -479,7 +479,7 @@ }, { "cell_type": "markdown", - "id": "6425191f", + "id": "87390af1", "metadata": { "lines_to_next_cell": 0 }, @@ -490,7 +490,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b4b94237", + "id": "eeab4c14", "metadata": { "lines_to_next_cell": 2 }, @@ -501,7 +501,7 @@ }, { "cell_type": "markdown", - "id": "de61a901", + "id": "d06264ca", "metadata": {}, "source": [ "# References" diff --git a/vignettes/vig1_visium_basic.ipynb b/vignettes/vig1_visium_basic.ipynb index 007ef7c56..dd0351f49 100644 --- a/vignettes/vig1_visium_basic.ipynb +++ b/vignettes/vig1_visium_basic.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "raw", - "id": "1c3bade2", + "id": "08711269", "metadata": {}, "source": [ "---\n", @@ -26,7 +26,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ac2fcdcd", + "id": "90175972", "metadata": { "tags": [ "remove_cell" @@ -43,7 +43,7 @@ { "cell_type": "code", "execution_count": null, - "id": "cc4e9451", + "id": "4407dc7e", "metadata": { "eval": false, "tags": [ @@ -80,7 +80,7 @@ }, { "cell_type": "markdown", - "id": "119da6e3", + "id": "05e7fe3d", "metadata": { "lines_to_next_cell": 0 }, @@ -100,7 +100,7 @@ { "cell_type": "code", "execution_count": null, - "id": "95bb0ddf", + "id": "54e17d57", "metadata": { "message": false, "name": "setup" @@ -130,7 +130,7 @@ { "cell_type": "code", "execution_count": null, - "id": "67a6822f", + "id": "24537916", "metadata": {}, "outputs": [], "source": [ @@ -143,7 +143,7 @@ { "cell_type": "code", "execution_count": null, - "id": "56bd8b83", + "id": "9105c9c4", "metadata": { "eval": false, "tags": [ @@ -158,7 +158,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2eaddfd8", + "id": "ec47001d", "metadata": {}, "outputs": [], "source": [ @@ -167,7 +167,7 @@ }, { "cell_type": "markdown", - "id": "b37421c2", + "id": "5fb75b1d", "metadata": {}, "source": [ "# Mouse skeletal muscle dataset\n", @@ -183,7 +183,7 @@ { "cell_type": "code", "execution_count": null, - "id": "603dd68f", + "id": "03f4bb9b", "metadata": {}, "outputs": [], "source": [ @@ -192,7 +192,7 @@ }, { "cell_type": "markdown", - "id": "ea186e42", + "id": "e2c20e7d", "metadata": { "lines_to_next_cell": 0 }, @@ -206,7 +206,7 @@ { "cell_type": "code", "execution_count": null, - "id": "415c486d", + "id": "a1e17f15", "metadata": {}, "outputs": [], "source": [ @@ -219,7 +219,7 @@ { "cell_type": "code", "execution_count": null, - "id": "978d300f", + "id": "cc1f048b", "metadata": { "lines_to_next_cell": 2 }, @@ -233,7 +233,7 @@ }, { "cell_type": "markdown", - "id": "32469d5f", + "id": "0c636613", "metadata": {}, "source": [ "# Quality control\n", @@ -244,7 +244,7 @@ { "cell_type": "code", "execution_count": null, - "id": "111cf312", + "id": "3b8b1c9b", "metadata": {}, "outputs": [], "source": [ @@ -253,7 +253,7 @@ }, { "cell_type": "markdown", - "id": "1c77c426", + "id": "3a81c161", "metadata": { "lines_to_next_cell": 0 }, @@ -264,7 +264,7 @@ { "cell_type": "code", "execution_count": null, - "id": "afd24a62", + "id": "41c8ac0c", "metadata": {}, "outputs": [], "source": [ @@ -281,7 +281,7 @@ }, { "cell_type": "markdown", - "id": "acbcfc3a", + "id": "faee87bd", "metadata": { "lines_to_next_cell": 0 }, @@ -294,7 +294,7 @@ { "cell_type": "code", "execution_count": null, - "id": "142ef008", + "id": "4b0dafd7", "metadata": {}, "outputs": [], "source": [ @@ -311,7 +311,7 @@ }, { "cell_type": "markdown", - "id": "55e0627f", + "id": "a14767d2", "metadata": { "lines_to_next_cell": 0 }, @@ -322,7 +322,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9abd4575", + "id": "48299136", "metadata": {}, "outputs": [], "source": [ @@ -331,7 +331,7 @@ }, { "cell_type": "markdown", - "id": "4a983e87", + "id": "4fbd09ae", "metadata": { "lines_to_next_cell": 0 }, @@ -344,7 +344,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a5ce031a", + "id": "67d78530", "metadata": {}, "outputs": [], "source": [ @@ -362,7 +362,7 @@ }, { "cell_type": "markdown", - "id": "44118e8a", + "id": "a5cf59c0", "metadata": { "lines_to_next_cell": 0 }, @@ -375,7 +375,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0dfece4d", + "id": "f66a7014", "metadata": {}, "outputs": [], "source": [ @@ -384,7 +384,7 @@ }, { "cell_type": "markdown", - "id": "85d753ad", + "id": "c0cad189", "metadata": { "lines_to_next_cell": 0 }, @@ -399,7 +399,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f5e86928", + "id": "7334bf09", "metadata": {}, "outputs": [], "source": [ @@ -409,7 +409,7 @@ }, { "cell_type": "markdown", - "id": "79867566", + "id": "86613685", "metadata": { "lines_to_next_cell": 0 }, @@ -423,7 +423,7 @@ { "cell_type": "code", "execution_count": null, - "id": "03b6d073", + "id": "7d08d568", "metadata": {}, "outputs": [], "source": [ @@ -435,7 +435,7 @@ }, { "cell_type": "markdown", - "id": "75f3cce4", + "id": "cbc259ea", "metadata": { "lines_to_next_cell": 0 }, @@ -446,7 +446,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a697355f", + "id": "3c81cfaa", "metadata": {}, "outputs": [], "source": [ @@ -459,7 +459,7 @@ }, { "cell_type": "markdown", - "id": "5708e715", + "id": "5f4513f8", "metadata": {}, "source": [ "The red line, $y = x$ is what is expected for Poisson distributed data, but we find that the variance is higher for more highly expressed genes than expected from Poisson distributed counts. The coefficient of variation shows the same." @@ -468,7 +468,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b12f2232", + "id": "c0f63c2f", "metadata": {}, "outputs": [], "source": [ @@ -481,7 +481,7 @@ }, { "cell_type": "markdown", - "id": "e9fcd4f7", + "id": "9b555f56", "metadata": {}, "source": [ "# Normalize data\n", @@ -496,7 +496,7 @@ { "cell_type": "code", "execution_count": null, - "id": "230d1416", + "id": "714bd4df", "metadata": {}, "outputs": [], "source": [ @@ -508,7 +508,7 @@ }, { "cell_type": "markdown", - "id": "47db82be", + "id": "b1966655", "metadata": { "lines_to_next_cell": 0 }, @@ -523,7 +523,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8afe978a", + "id": "1622701a", "metadata": {}, "outputs": [], "source": [ @@ -533,7 +533,7 @@ }, { "cell_type": "markdown", - "id": "d3ecb1d1", + "id": "ed9d817f", "metadata": { "lines_to_next_cell": 0 }, @@ -544,7 +544,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a190292a", + "id": "e41d486b", "metadata": {}, "outputs": [], "source": [ @@ -555,7 +555,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7a5be916", + "id": "8ceb8b65", "metadata": {}, "outputs": [], "source": [ @@ -565,7 +565,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0dda3196", + "id": "568152ba", "metadata": {}, "outputs": [], "source": [ @@ -574,7 +574,7 @@ }, { "cell_type": "markdown", - "id": "fc4d242e", + "id": "e5fec84e", "metadata": { "lines_to_next_cell": 0 }, @@ -585,7 +585,7 @@ { "cell_type": "code", "execution_count": null, - "id": "bc7b173b", + "id": "0227a211", "metadata": {}, "outputs": [], "source": [ @@ -600,7 +600,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c65d6513", + "id": "b0675052", "metadata": { "fig.height": 6, "fig.width": 7 @@ -612,7 +612,7 @@ }, { "cell_type": "markdown", - "id": "6e2af5db", + "id": "47beb1f6", "metadata": { "lines_to_next_cell": 0 }, @@ -623,7 +623,7 @@ { "cell_type": "code", "execution_count": null, - "id": "aeb77507", + "id": "e3687b92", "metadata": { "fig.height": 8, "fig.width": 6 @@ -637,7 +637,7 @@ }, { "cell_type": "markdown", - "id": "e16cf6ea", + "id": "beb3496a", "metadata": { "lines_to_next_cell": 0 }, @@ -650,7 +650,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f04e0691", + "id": "7e375e94", "metadata": {}, "outputs": [], "source": [ @@ -661,7 +661,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4f349dac", + "id": "c4bd4663", "metadata": {}, "outputs": [], "source": [ @@ -670,7 +670,7 @@ }, { "cell_type": "markdown", - "id": "6c179a7c", + "id": "ba1c5a00", "metadata": {}, "source": [ "UMAP is often used to visualize clusters. An alternative to UMAP is [`concordex`](https://bioconductor.org/packages/devel/bioc/html/concordexR.html), which quantitatively shows the proportion of neighbors on the k nearest neighbor graph with the same cluster label. To be consistent with the default in igraph Leiden clustering, we use k = 10." @@ -679,7 +679,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a0736be4", + "id": "9fc2ccfe", "metadata": {}, "outputs": [], "source": [ @@ -690,7 +690,7 @@ }, { "cell_type": "markdown", - "id": "6b5c7c16", + "id": "088d98c3", "metadata": { "lines_to_next_cell": 0 }, @@ -701,7 +701,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3272dd06", + "id": "49eefe5c", "metadata": {}, "outputs": [], "source": [ @@ -710,7 +710,7 @@ }, { "cell_type": "markdown", - "id": "8992dbe7", + "id": "0adf15a2", "metadata": { "lines_to_next_cell": 0 }, @@ -721,7 +721,7 @@ { "cell_type": "code", "execution_count": null, - "id": "adafdf99", + "id": "aeff11a2", "metadata": { "fig.height": 4, "fig.width": 5 @@ -733,7 +733,7 @@ }, { "cell_type": "markdown", - "id": "212bb33c", + "id": "dc306dfe", "metadata": { "lines_to_next_cell": 0 }, @@ -746,7 +746,7 @@ { "cell_type": "code", "execution_count": null, - "id": "380c311a", + "id": "cd359570", "metadata": {}, "outputs": [], "source": [ @@ -756,7 +756,7 @@ }, { "cell_type": "markdown", - "id": "0a3a27aa", + "id": "7b2e3e80", "metadata": { "lines_to_next_cell": 0 }, @@ -776,7 +776,7 @@ { "cell_type": "code", "execution_count": null, - "id": "49d8c0c5", + "id": "055ac5ed", "metadata": {}, "outputs": [], "source": [ @@ -786,7 +786,7 @@ }, { "cell_type": "markdown", - "id": "1e11e94c", + "id": "02ffe14e", "metadata": { "lines_to_next_cell": 0 }, @@ -797,7 +797,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6e5b75ba", + "id": "96210b82", "metadata": {}, "outputs": [], "source": [ @@ -806,7 +806,7 @@ }, { "cell_type": "markdown", - "id": "ad9f5167", + "id": "ed610caf", "metadata": { "lines_to_next_cell": 0 }, @@ -817,7 +817,7 @@ { "cell_type": "code", "execution_count": null, - "id": "05b8546e", + "id": "5e87ecab", "metadata": {}, "outputs": [], "source": [ @@ -868,7 +868,7 @@ }, { "cell_type": "markdown", - "id": "379b0f77", + "id": "7801e605", "metadata": { "lines_to_next_cell": 0 }, @@ -879,7 +879,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c178ef4a", + "id": "53dfb0b8", "metadata": {}, "outputs": [], "source": [ @@ -890,7 +890,7 @@ }, { "cell_type": "markdown", - "id": "a63793c4", + "id": "ac339115", "metadata": { "lines_to_next_cell": 0 }, @@ -901,7 +901,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a7aaf174", + "id": "b59256b7", "metadata": {}, "outputs": [], "source": [ @@ -913,7 +913,7 @@ }, { "cell_type": "markdown", - "id": "a59d3ad1", + "id": "2bd86652", "metadata": { "lines_to_next_cell": 0 }, @@ -924,7 +924,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0c1c9da4", + "id": "94d38303", "metadata": { "fig.height": 7, "fig.width": 9 @@ -937,7 +937,7 @@ }, { "cell_type": "markdown", - "id": "59dd469c", + "id": "bc5caaf1", "metadata": { "lines_to_next_cell": 0 }, @@ -964,7 +964,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e38fb852", + "id": "378e373a", "metadata": {}, "outputs": [], "source": [ @@ -973,7 +973,7 @@ }, { "cell_type": "markdown", - "id": "311a42af", + "id": "cd07632a", "metadata": { "lines_to_next_cell": 0 }, @@ -984,7 +984,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4860aa88", + "id": "9b836aa7", "metadata": {}, "outputs": [], "source": [ @@ -994,7 +994,7 @@ }, { "cell_type": "markdown", - "id": "88e1aba2", + "id": "489d7628", "metadata": {}, "source": [ "K means kurtosis. The positive values of Moran's I indicate positive spatial autocorrelation.\n", @@ -1006,7 +1006,7 @@ { "cell_type": "code", "execution_count": null, - "id": "07c03cf8", + "id": "4efc0d34", "metadata": {}, "outputs": [], "source": [ @@ -1016,7 +1016,7 @@ }, { "cell_type": "markdown", - "id": "a17d4b0d", + "id": "4c1cda4d", "metadata": { "lines_to_next_cell": 0 }, @@ -1027,7 +1027,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ca2a79dc", + "id": "3753af8d", "metadata": {}, "outputs": [], "source": [ @@ -1036,7 +1036,7 @@ }, { "cell_type": "markdown", - "id": "3328daae", + "id": "b38e8ee5", "metadata": {}, "source": [ "The `NA`'s are for genes that are not highly variable and Moran's I was not computed for those genes. We rank the genes by Moran's I and plot them in space as follows:" @@ -1045,7 +1045,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5fc09a35", + "id": "405b68d6", "metadata": {}, "outputs": [], "source": [ @@ -1056,7 +1056,7 @@ }, { "cell_type": "markdown", - "id": "797d031e", + "id": "4e6673ef", "metadata": { "lines_to_next_cell": 0 }, @@ -1069,7 +1069,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0ba5adbc", + "id": "2a8064d2", "metadata": {}, "outputs": [], "source": [ @@ -1081,7 +1081,7 @@ }, { "cell_type": "markdown", - "id": "e93953bf", + "id": "8b69c9fe", "metadata": { "lines_to_next_cell": 0 }, @@ -1092,7 +1092,7 @@ { "cell_type": "code", "execution_count": null, - "id": "32908b4a", + "id": "be7273ca", "metadata": { "fig.height": 7, "fig.width": 9 @@ -1105,7 +1105,7 @@ }, { "cell_type": "markdown", - "id": "b6f54492", + "id": "cb1b6f43", "metadata": { "lines_to_next_cell": 0 }, @@ -1122,7 +1122,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d4bfd74a", + "id": "84cba0c1", "metadata": {}, "outputs": [], "source": [ @@ -1131,7 +1131,7 @@ }, { "cell_type": "markdown", - "id": "c9cf8fb7", + "id": "20d6cbb6", "metadata": {}, "source": [ "# References" diff --git a/vignettes/vig2_visium.ipynb b/vignettes/vig2_visium.ipynb index ca53114ad..66049e903 100644 --- a/vignettes/vig2_visium.ipynb +++ b/vignettes/vig2_visium.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "raw", - "id": "9b82d954", + "id": "17c1d1e6", "metadata": {}, "source": [ "---\n", @@ -26,7 +26,7 @@ { "cell_type": "code", "execution_count": null, - "id": "018b1508", + "id": "a899913c", "metadata": { "tags": [ "remove_cell" @@ -43,7 +43,7 @@ { "cell_type": "code", "execution_count": null, - "id": "aa978ae5", + "id": "6fa7b759", "metadata": { "eval": false, "tags": [ @@ -80,7 +80,7 @@ }, { "cell_type": "markdown", - "id": "a4ffe8ab", + "id": "6bb54888", "metadata": {}, "source": [ "# Introduction \n", @@ -91,7 +91,7 @@ { "cell_type": "code", "execution_count": null, - "id": "73f35cf4", + "id": "d76ddaac", "metadata": { "message": false, "name": "setup" @@ -117,7 +117,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7c92b48f", + "id": "09d80a0b", "metadata": { "lines_to_next_cell": 2 }, @@ -134,7 +134,7 @@ }, { "cell_type": "markdown", - "id": "33366357", + "id": "440d97cd", "metadata": {}, "source": [ "# Dataset\n", @@ -148,7 +148,7 @@ { "cell_type": "code", "execution_count": null, - "id": "837bbd98", + "id": "54451319", "metadata": {}, "outputs": [], "source": [ @@ -157,7 +157,7 @@ }, { "cell_type": "markdown", - "id": "f026dc24", + "id": "ba634542", "metadata": {}, "source": [ "The H&E image of this section:\n", @@ -167,7 +167,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e6de733a", + "id": "96c51475", "metadata": {}, "outputs": [], "source": [ @@ -179,7 +179,7 @@ }, { "cell_type": "markdown", - "id": "8ada2c81", + "id": "a409bc9c", "metadata": { "lines_to_next_cell": 0 }, @@ -190,7 +190,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f02d57a3", + "id": "f54a5853", "metadata": {}, "outputs": [], "source": [ @@ -202,7 +202,7 @@ }, { "cell_type": "markdown", - "id": "fa62cf27", + "id": "4d75b3cb", "metadata": {}, "source": [ "# Exploratory data analysis\n", @@ -213,7 +213,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2c3a1d8c", + "id": "90105354", "metadata": {}, "outputs": [], "source": [ @@ -222,7 +222,7 @@ }, { "cell_type": "markdown", - "id": "0be9164a", + "id": "fa108262", "metadata": { "lines_to_next_cell": 0 }, @@ -237,7 +237,7 @@ { "cell_type": "code", "execution_count": null, - "id": "05c40840", + "id": "e51c88aa", "metadata": {}, "outputs": [], "source": [ @@ -248,7 +248,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d0deb8a9", + "id": "6f43326e", "metadata": {}, "outputs": [], "source": [ @@ -260,7 +260,7 @@ }, { "cell_type": "markdown", - "id": "084b6f5e", + "id": "353f7e73", "metadata": {}, "source": [ "Myofiber and nuclei segmentation polygons are available in this dataset in the `annotGeometries` field. Myofibers were manually segmented, and nuclei were segmented with [`StarDist`](https://github.com/stardist/stardist) trained with a manually segmented subset. " @@ -269,7 +269,7 @@ { "cell_type": "code", "execution_count": null, - "id": "cfd1e66e", + "id": "10cca675", "metadata": {}, "outputs": [], "source": [ @@ -278,7 +278,7 @@ }, { "cell_type": "markdown", - "id": "3be7ab4a", + "id": "7a30b128", "metadata": { "lines_to_next_cell": 0 }, @@ -292,7 +292,7 @@ { "cell_type": "code", "execution_count": null, - "id": "77277a64", + "id": "9488fae0", "metadata": { "fig.alt": "Plot of Visium spots in tissue and myofiber polygons in physical space. Visium spots are colored by nCounts, and myofibers are colored by area." }, @@ -307,7 +307,7 @@ }, { "cell_type": "markdown", - "id": "59c7ab7c", + "id": "23861808", "metadata": { "lines_to_next_cell": 0 }, @@ -320,7 +320,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b50b75cf", + "id": "ff0e5e88", "metadata": {}, "outputs": [], "source": [ @@ -332,7 +332,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e48deffc", + "id": "0c71fe8e", "metadata": { "fig.alt": "Plot of Visium spots in tissue in physical space, colored by number of myofibers intersecting each spot.", "fig.height": 4, @@ -347,7 +347,7 @@ }, { "cell_type": "markdown", - "id": "ac4847d9", + "id": "712e736c", "metadata": { "lines_to_next_cell": 0 }, @@ -358,7 +358,7 @@ { "cell_type": "code", "execution_count": null, - "id": "716dd40c", + "id": "569ab150", "metadata": {}, "outputs": [], "source": [ @@ -370,7 +370,7 @@ { "cell_type": "code", "execution_count": null, - "id": "bf75627f", + "id": "4b798dc1", "metadata": { "fig.alt": "Plot of Visium spots in tissue in physical space, colored by the average area of myofibers that intersect each spot. The average area is higher near the mid-top right part of the tissue." }, @@ -383,7 +383,7 @@ }, { "cell_type": "markdown", - "id": "f63c05d7", + "id": "3eb6ac3d", "metadata": { "lines_to_next_cell": 0 }, @@ -398,7 +398,7 @@ { "cell_type": "code", "execution_count": null, - "id": "82b0cc95", + "id": "54a98778", "metadata": {}, "outputs": [], "source": [ @@ -408,7 +408,7 @@ { "cell_type": "code", "execution_count": null, - "id": "056b8f8e", + "id": "7aa2fa66", "metadata": {}, "outputs": [], "source": [ @@ -417,7 +417,7 @@ }, { "cell_type": "markdown", - "id": "97315fee", + "id": "4e33ed9d", "metadata": { "lines_to_next_cell": 0 }, @@ -429,7 +429,7 @@ { "cell_type": "code", "execution_count": null, - "id": "24bd08a9", + "id": "5faba192", "metadata": {}, "outputs": [], "source": [ @@ -438,7 +438,7 @@ }, { "cell_type": "markdown", - "id": "d93f2507", + "id": "eb5bb552", "metadata": { "lines_to_next_cell": 0 }, @@ -449,7 +449,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2fa9022d", + "id": "1191fd54", "metadata": {}, "outputs": [], "source": [ @@ -461,7 +461,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8fcaa881", + "id": "48bf43bd", "metadata": {}, "outputs": [], "source": [ @@ -473,7 +473,7 @@ }, { "cell_type": "markdown", - "id": "0ef13dea", + "id": "a20bf6bd", "metadata": { "lines_to_next_cell": 0 }, @@ -486,7 +486,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e6ea36cd", + "id": "3bd8eef5", "metadata": {}, "outputs": [], "source": [ @@ -512,7 +512,7 @@ { "cell_type": "code", "execution_count": null, - "id": "73ac441d", + "id": "fe93c734", "metadata": { "fig.alt": "Raw and log normalized counts of Myh7, marker gene of type I myofiber, plotted side by side on Visium spots in space, with myofiber polygons colored by myofiber cross section area plotted in the background. Visium spots expressing Myh7 concentrate in the lower left part of the tissue where the myofibers tend to be smaller." }, @@ -523,7 +523,7 @@ }, { "cell_type": "markdown", - "id": "9d2d1c17", + "id": "309fa856", "metadata": { "lines_to_next_cell": 0 }, @@ -534,7 +534,7 @@ { "cell_type": "code", "execution_count": null, - "id": "144d8432", + "id": "87301f1d", "metadata": { "fig.alt": "Raw and log normalized counts of Myh2, a marker gene of type IIa myofiber, plotted side by side on Visium spots in space, with myofiber polygons colored by myofiber cross section area plotted in the background. Visium spots expressing Myh2 concentrate in the lower left and upper left parts of the tissue where the myofibers tend to be smaller. Log normalized counts show a wider region with higher expression." }, @@ -545,7 +545,7 @@ }, { "cell_type": "markdown", - "id": "6e5bc95c", + "id": "b4937d8e", "metadata": { "lines_to_next_cell": 0 }, @@ -558,7 +558,7 @@ { "cell_type": "code", "execution_count": null, - "id": "63380a3e", + "id": "cfa2a9f8", "metadata": { "fig.alt": "Scatter plot of mean area of myofibers intersecting each Visium spot in the x axis and proportion of mitochondrially encoded counts per spot in the y axis, with points colored by expression of Myh2." }, @@ -571,7 +571,7 @@ }, { "cell_type": "markdown", - "id": "8d60d6d7", + "id": "534a5ec0", "metadata": {}, "source": [ "Plotting proportion of mitochondrial counts vs. mean myofiber area, we see two clusters, one with higher proportion of mitochondrial counts and smaller area, and another with lower proportion of mitochondrial counts and on average slightly larger area. Type IIa myofibers tend to have smaller area and a larger proportion of mitochondrial counts.\n", @@ -585,7 +585,7 @@ { "cell_type": "code", "execution_count": null, - "id": "15029019", + "id": "5a443e2d", "metadata": {}, "outputs": [], "source": [ @@ -597,7 +597,7 @@ }, { "cell_type": "markdown", - "id": "aff58d08", + "id": "928f053b", "metadata": { "lines_to_next_cell": 0 }, @@ -608,7 +608,7 @@ { "cell_type": "code", "execution_count": null, - "id": "178b6e09", + "id": "e7254bf9", "metadata": { "fig.alt": "Spatial neighborhood graph of Visium spots that intersect tissue." }, @@ -620,7 +620,7 @@ }, { "cell_type": "markdown", - "id": "cc635733", + "id": "f1cef8ad", "metadata": { "lines_to_next_cell": 0 }, @@ -631,7 +631,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2e37fb6a", + "id": "9ff6fad0", "metadata": { "fig.alt": "Spatial neighborhood graph of myofibers, where each edge connects two myofibers that touch." }, @@ -643,7 +643,7 @@ }, { "cell_type": "markdown", - "id": "b817e197", + "id": "2100d74d", "metadata": { "lines_to_next_cell": 0 }, @@ -662,7 +662,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c0647fa2", + "id": "6b6bcb23", "metadata": {}, "outputs": [], "source": [ @@ -671,7 +671,7 @@ }, { "cell_type": "markdown", - "id": "799e1cb3", + "id": "d0edb03c", "metadata": { "lines_to_next_cell": 0 }, @@ -684,7 +684,7 @@ { "cell_type": "code", "execution_count": null, - "id": "36955fc4", + "id": "f72cde2a", "metadata": {}, "outputs": [], "source": [ @@ -694,7 +694,7 @@ }, { "cell_type": "markdown", - "id": "b5be3ee9", + "id": "4ba46a04", "metadata": { "lines_to_next_cell": 0 }, @@ -720,7 +720,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d70c01b1", + "id": "b62cbd58", "metadata": {}, "outputs": [], "source": [ @@ -732,7 +732,7 @@ }, { "cell_type": "markdown", - "id": "25dd19e6", + "id": "fed0a7dd", "metadata": { "lines_to_next_cell": 0 }, @@ -745,7 +745,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4b25f07f", + "id": "863349bf", "metadata": {}, "outputs": [], "source": [ @@ -756,7 +756,7 @@ }, { "cell_type": "markdown", - "id": "c1b4640a", + "id": "04cf02c0", "metadata": { "lines_to_next_cell": 0 }, @@ -769,7 +769,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3a96a831", + "id": "92a6e76d", "metadata": {}, "outputs": [], "source": [ @@ -784,7 +784,7 @@ }, { "cell_type": "markdown", - "id": "8bb31929", + "id": "9a8ae393", "metadata": { "lines_to_next_cell": 0 }, @@ -797,7 +797,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0497238f", + "id": "44d1476d", "metadata": {}, "outputs": [], "source": [ @@ -809,7 +809,7 @@ }, { "cell_type": "markdown", - "id": "408dbf8a", + "id": "b9fe856e", "metadata": { "lines_to_next_cell": 0 }, @@ -829,7 +829,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8df84955", + "id": "6177655c", "metadata": {}, "outputs": [], "source": [ @@ -840,7 +840,7 @@ }, { "cell_type": "markdown", - "id": "a7361063", + "id": "fde46692", "metadata": { "lines_to_next_cell": 0 }, @@ -858,7 +858,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b6136ee0", + "id": "d72d129f", "metadata": {}, "outputs": [], "source": [ @@ -871,7 +871,7 @@ }, { "cell_type": "markdown", - "id": "9fb7bada", + "id": "2478c93c", "metadata": { "lines_to_next_cell": 0 }, @@ -884,7 +884,7 @@ { "cell_type": "code", "execution_count": null, - "id": "af56f8e3", + "id": "76cecdde", "metadata": { "fig.alt": "Density plot of Moran's I values from 1000 simulations of nCounts and nGenes. The density plots center around 0 and deminish around 0.06 on the right. Vertical lines mark the actual Moran's I. For both nCounts and nGenes, the actual value, at 0.53 and 0.38 respectively, is far higher than the simulated ones, indicating positive spatial autocorrelation." }, @@ -895,7 +895,7 @@ }, { "cell_type": "markdown", - "id": "f4d35722", + "id": "e77abf7b", "metadata": {}, "source": [ "By default, the colorblind friendly palette from [`dittoSeq`](https://bioconductor.org/packages/release/bioc/html/dittoSeq.html) is used for categorical variables. The density plot is of Moran's I from the simulations where the values are permuted and disconnected from spatial locations, and the vertical line is the actual Moran's I value. The simulation indicates that the actual Moran's I is much higher than that from the simulations where the values are dissociated from spatial locations and permuted among the locations, indicating that spatial autocorrelation is very significant. \n", @@ -908,7 +908,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f73f62cf", + "id": "2515139d", "metadata": {}, "outputs": [], "source": [ @@ -919,7 +919,7 @@ }, { "cell_type": "markdown", - "id": "5a39f253", + "id": "9491431e", "metadata": {}, "source": [ "Now compare the p-values from permutation and analytical test; in both cases here, the default alternative hypothesis is positive spatial autocorrelation:" @@ -928,7 +928,7 @@ { "cell_type": "code", "execution_count": null, - "id": "731d1a7b", + "id": "76d1aafa", "metadata": {}, "outputs": [], "source": [ @@ -938,7 +938,7 @@ }, { "cell_type": "markdown", - "id": "17b184a0", + "id": "ac5f672a", "metadata": { "lines_to_next_cell": 0 }, @@ -956,7 +956,7 @@ { "cell_type": "code", "execution_count": null, - "id": "bd201a69", + "id": "54de236d", "metadata": {}, "outputs": [], "source": [ @@ -966,7 +966,7 @@ }, { "cell_type": "markdown", - "id": "6c356b3d", + "id": "dec66271", "metadata": { "lines_to_next_cell": 0 }, @@ -977,7 +977,7 @@ { "cell_type": "code", "execution_count": null, - "id": "801ea951", + "id": "eb137147", "metadata": { "fig.alt": "Line plot with order of neighbors (lags) in the x axis and Moran's I value at each lag in the y axis. The x axis ranges from 1 to 10, and the y axis ranges from 0 to 0.8. The lines show trends of decay of spatial autocorrelation with increasing distance of neighbors. Two genes, Car3 and Mb, are shown. Moran's I of both genes decay somewhat linearly from lag 1 to 10. Car3 decays from around 0.75 to around 0.23. Mb decays from around 0.7 to around 0.13. At each lag the error bars are tight (see next paragraph in the main text) and the p-values are less than 0.001 after Benjamini-Hochberg multiple testing correction over the 2 genes and 10 lags." }, @@ -988,7 +988,7 @@ }, { "cell_type": "markdown", - "id": "bbd65144", + "id": "dbed9e89", "metadata": { "lines_to_next_cell": 0 }, @@ -1006,7 +1006,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6f098ee6", + "id": "34b47f1d", "metadata": { "lines_to_next_cell": 2 }, @@ -1017,7 +1017,7 @@ }, { "cell_type": "markdown", - "id": "5506da78", + "id": "118ae1e7", "metadata": { "lines_to_next_cell": 0 }, @@ -1031,7 +1031,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8009da87", + "id": "29577772", "metadata": {}, "outputs": [], "source": [ @@ -1042,7 +1042,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b46ae7ab", + "id": "6bde99c0", "metadata": { "fig.alt": "Moran scatter plot of log normalized values of gene Myh2. This plot is described in the upcoming main text." }, @@ -1053,7 +1053,7 @@ }, { "cell_type": "markdown", - "id": "37252d3a", + "id": "f614ab9b", "metadata": {}, "source": [ "The dashed lines mark the mean in Myh2 and spatially lagged Myh2. There are no singletons here. Some Visium spots with lower Myh2 expression have neighbors that don't express Myh2 but spots that don't express Myh2 usually have at least some neighbors that do. There are twp main clusters for spots whose neighbors do express Myh2: those with high (above average) expression whose neighbors also have high expression, and those with low expression whose neighbors also have low expression. Other features may show different kinds of clusters. We can use k-means clustering to identify clusters, though any clustering method supported by the `bluster` package can be used." @@ -1062,7 +1062,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6c02bdcf", + "id": "a1e9d409", "metadata": {}, "outputs": [], "source": [ @@ -1073,7 +1073,7 @@ }, { "cell_type": "markdown", - "id": "317a87ad", + "id": "59b1ddc5", "metadata": { "lines_to_next_cell": 0 }, @@ -1084,7 +1084,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f47107e0", + "id": "46f7522a", "metadata": {}, "outputs": [], "source": [ @@ -1094,7 +1094,7 @@ { "cell_type": "code", "execution_count": null, - "id": "673d9f88", + "id": "cff79882", "metadata": { "fig.alt": "Moran scatter plot of log normalized value of Myh1, colored by 2 k-means clusters, which correspond to the high-high and low-low spots." }, @@ -1106,7 +1106,7 @@ }, { "cell_type": "markdown", - "id": "14b7e397", + "id": "bdf3c0f3", "metadata": { "lines_to_next_cell": 0 }, @@ -1117,7 +1117,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a33a370d", + "id": "7b79c53e", "metadata": { "fig.alt": "Visium spots in space colored by the k-means clusters. Cluster 2 (high-high) are mostly in the upper left and lower left parts of the tissue, and the rest of the spots are cluster 1." }, @@ -1130,7 +1130,7 @@ }, { "cell_type": "markdown", - "id": "16db7f8b", + "id": "bf4ff3f3", "metadata": {}, "source": [ "This can also be done for `colData`, `annotGeometry`, and etc. as in Moran's I and permutation testing. \n", @@ -1154,7 +1154,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6c51685b", + "id": "f5ff1ff9", "metadata": {}, "outputs": [], "source": [ @@ -1164,7 +1164,7 @@ }, { "cell_type": "markdown", - "id": "0f4dc420", + "id": "e9486d8e", "metadata": { "lines_to_next_cell": 0 }, @@ -1175,7 +1175,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f37896eb", + "id": "abe6d103", "metadata": {}, "outputs": [], "source": [ @@ -1187,7 +1187,7 @@ { "cell_type": "code", "execution_count": null, - "id": "14aef900", + "id": "ae59b395", "metadata": {}, "outputs": [], "source": [ @@ -1200,7 +1200,7 @@ }, { "cell_type": "markdown", - "id": "c230041f", + "id": "98a2af6c", "metadata": {}, "source": [ "We see that regions with higher Myh2 expression also have stronger spatial autocorrelation. It is interesting to see how spatial autocorrelation relates to gene expression level, much as finding how variance relates to mean in the expression of each gene, which usually indicates overdispersion compared to Poisson in scRNA-seq and Visium data:" @@ -1209,7 +1209,7 @@ { "cell_type": "code", "execution_count": null, - "id": "79ae9013", + "id": "35aeea61", "metadata": {}, "outputs": [], "source": [ @@ -1222,7 +1222,7 @@ }, { "cell_type": "markdown", - "id": "9086a0b7", + "id": "9504ec45", "metadata": { "lines_to_next_cell": 0 }, @@ -1235,7 +1235,7 @@ { "cell_type": "code", "execution_count": null, - "id": "22b2c829", + "id": "7356673a", "metadata": {}, "outputs": [], "source": [ @@ -1244,7 +1244,7 @@ }, { "cell_type": "markdown", - "id": "4475af18", + "id": "4abada72", "metadata": {}, "source": [ "Some local spatial methods return p-values at each location, in a column with name like `Pr(z != E(Ii))`, where the test is two sided (default, can be changed with the `alternative` argument in `runUnivariate()` which is passed to the relevant underlying function in `spdep`). Negative log of the p-value is computed to facilitate visualization, and the p-value is corrected for multiple hypothesis testing with `p.adjustSP()` in `spdep`, where the number of tests is the number of neighbors of each location rather than the total number of locations (`-log10p_adj`)." @@ -1253,7 +1253,7 @@ { "cell_type": "code", "execution_count": null, - "id": "307526fb", + "id": "dfc34c35", "metadata": {}, "outputs": [], "source": [ @@ -1266,7 +1266,7 @@ }, { "cell_type": "markdown", - "id": "33b7b7d4", + "id": "dedd3a20", "metadata": { "lines_to_next_cell": 0 }, @@ -1279,7 +1279,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9458acaa", + "id": "9ca28769", "metadata": {}, "outputs": [], "source": [ @@ -1291,7 +1291,7 @@ }, { "cell_type": "markdown", - "id": "73e01c00", + "id": "dce43d2b", "metadata": { "lines_to_next_cell": 0 }, @@ -1305,7 +1305,7 @@ { "cell_type": "code", "execution_count": null, - "id": "91edf77b", + "id": "b4127293", "metadata": {}, "outputs": [], "source": [ @@ -1315,7 +1315,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c417c530", + "id": "73b4a80c", "metadata": {}, "outputs": [], "source": [ @@ -1327,7 +1327,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ff261ee5", + "id": "2273aa92", "metadata": {}, "outputs": [], "source": [ @@ -1339,7 +1339,7 @@ }, { "cell_type": "markdown", - "id": "03ed3830", + "id": "cf65824c", "metadata": {}, "source": [ "High values of Gi\\* indicate hotspots, while low values of Gi\\* indicate coldspots." @@ -1348,7 +1348,7 @@ { "cell_type": "code", "execution_count": null, - "id": "263f2786", + "id": "677a73bc", "metadata": {}, "outputs": [], "source": [ @@ -1357,7 +1357,7 @@ }, { "cell_type": "markdown", - "id": "35db5981", + "id": "a99b4e02", "metadata": { "lines_to_next_cell": 0 }, @@ -1368,7 +1368,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4764a203", + "id": "cb9c3b8f", "metadata": {}, "outputs": [], "source": [ @@ -1381,7 +1381,7 @@ }, { "cell_type": "markdown", - "id": "2c1fa501", + "id": "10d8d149", "metadata": { "lines_to_next_cell": 0 }, @@ -1394,7 +1394,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a5d4da6b", + "id": "dce7aa57", "metadata": {}, "outputs": [], "source": [ @@ -1406,7 +1406,7 @@ { "cell_type": "code", "execution_count": null, - "id": "29fa6b3e", + "id": "3708d532", "metadata": {}, "outputs": [], "source": [ @@ -1419,7 +1419,7 @@ { "cell_type": "code", "execution_count": null, - "id": "206e3daf", + "id": "d37bdf99", "metadata": {}, "outputs": [], "source": [ @@ -1431,7 +1431,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ed10b494", + "id": "d842e22b", "metadata": {}, "outputs": [], "source": [ @@ -1443,7 +1443,7 @@ }, { "cell_type": "markdown", - "id": "1347b907", + "id": "a2f8bc76", "metadata": { "lines_to_next_cell": 0 }, @@ -1469,7 +1469,7 @@ { "cell_type": "code", "execution_count": null, - "id": "039accc8", + "id": "43792971", "metadata": {}, "outputs": [], "source": [ @@ -1480,7 +1480,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c413e20f", + "id": "0c0abb55", "metadata": {}, "outputs": [], "source": [ @@ -1491,7 +1491,7 @@ }, { "cell_type": "markdown", - "id": "f5faeac7", + "id": "c0a6f036", "metadata": {}, "source": [ "For this gene, it isn't clear whether LOSH relates to gene expression levels." @@ -1500,7 +1500,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b4debf6b", + "id": "2189ccd9", "metadata": {}, "outputs": [], "source": [ @@ -1509,7 +1509,7 @@ }, { "cell_type": "markdown", - "id": "584805dc", + "id": "0aa5a6df", "metadata": {}, "source": [ "While `Voyager` does wrap `LOSH.mc()` to perform permutation testing of LOSH, this is very time consuming. A chi-squared approximation is described in the 2012 LOSH paper to account for non-normality of the data and to approximate the mean and variance of the permutation distributions, so p-values of LOSH can be more quickly computed, with `LOSH.cs()`." @@ -1518,7 +1518,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c9644903", + "id": "81de62ac", "metadata": {}, "outputs": [], "source": [ @@ -1531,7 +1531,7 @@ }, { "cell_type": "markdown", - "id": "1b77f9aa", + "id": "0e6f1eef", "metadata": { "lines_to_next_cell": 0 }, @@ -1550,7 +1550,7 @@ { "cell_type": "code", "execution_count": null, - "id": "01e6bc41", + "id": "36d83804", "metadata": {}, "outputs": [], "source": [ @@ -1559,7 +1559,7 @@ }, { "cell_type": "markdown", - "id": "269ec000", + "id": "5201e409", "metadata": {}, "source": [ "# References" diff --git a/vignettes/vig3_slideseq_v2.ipynb b/vignettes/vig3_slideseq_v2.ipynb index a17b1aebf..75470ea22 100644 --- a/vignettes/vig3_slideseq_v2.ipynb +++ b/vignettes/vig3_slideseq_v2.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "raw", - "id": "5f821a27", + "id": "ded59cc2", "metadata": {}, "source": [ "---\n", @@ -26,7 +26,7 @@ { "cell_type": "code", "execution_count": null, - "id": "cf36ba4b", + "id": "4c57d609", "metadata": { "tags": [ "remove_cell" @@ -43,7 +43,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d329b546", + "id": "f7e9770e", "metadata": { "eval": false, "tags": [ @@ -77,7 +77,7 @@ }, { "cell_type": "markdown", - "id": "cf84a984", + "id": "f6adbaf2", "metadata": {}, "source": [ "## Introduction\n", @@ -90,7 +90,7 @@ { "cell_type": "code", "execution_count": null, - "id": "86a01af6", + "id": "0826102c", "metadata": { "name": "setup" }, @@ -114,7 +114,7 @@ { "cell_type": "code", "execution_count": null, - "id": "872025c2", + "id": "52c78f3a", "metadata": {}, "outputs": [], "source": [ @@ -123,7 +123,7 @@ }, { "cell_type": "markdown", - "id": "56be7103", + "id": "45c9ad8b", "metadata": {}, "source": [ "The SFE object in the `SFEData` package includes information for 27,566 features and 29,536 beads/barcodes.\n", @@ -136,7 +136,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4ddd52f5", + "id": "bad29201", "metadata": {}, "outputs": [], "source": [ @@ -145,7 +145,7 @@ }, { "cell_type": "markdown", - "id": "53e7c810", + "id": "879d5c37", "metadata": {}, "source": [ "Total UMI counts (`nCounts`), number of genes detected per spot (`nGenes`), and the proportion of mitochondrially encoded counts (`prop_mito`). Below, we plot the total number of UMI counts per barcode as a violin plot and in space. For the latter task, we leverage the function `plotSpatialFeature()` which uses `geom_sf()` to plot geometries where applicable. The first few lines compute the average number of UMI counts per barcode and this average is plotted as a red line in the violin plot. " @@ -154,7 +154,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c5e60f86", + "id": "041d798d", "metadata": {}, "outputs": [], "source": [ @@ -173,7 +173,7 @@ }, { "cell_type": "markdown", - "id": "59c95b65", + "id": "8698e9b5", "metadata": { "lines_to_next_cell": 0 }, @@ -186,7 +186,7 @@ { "cell_type": "code", "execution_count": null, - "id": "99c08860", + "id": "b2e2c2c7", "metadata": {}, "outputs": [], "source": [ @@ -203,7 +203,7 @@ }, { "cell_type": "markdown", - "id": "70f2705f", + "id": "f2f8a5a7", "metadata": {}, "source": [ "It is worthwhile to note that cell segmentation data were not included with this dataset. Even though Slide-Seq V2 does not profile gene expression at single cell resolution, cell segmentation data can be flexibly stored as `annotGeometries` in the `SFE` object. These geometries can be plotted with barcode-level data and can be used with `sf` for operations like finding the number of barcodes localized to a single cell." @@ -212,7 +212,7 @@ { "cell_type": "code", "execution_count": null, - "id": "96c91c5a", + "id": "ea0c354c", "metadata": {}, "outputs": [], "source": [ @@ -233,7 +233,7 @@ }, { "cell_type": "markdown", - "id": "08fdc48f", + "id": "809cd537", "metadata": {}, "source": [ "The plot above visualizes the number of UMI counts per barcode on a log scale. It appears that barcodes with higher counts are co-localized in regions throughout the tissue, however, these regions are rather small and may not suggest spatial autocorrelation.\n", @@ -244,7 +244,7 @@ { "cell_type": "code", "execution_count": null, - "id": "23a3962a", + "id": "ed4cf51a", "metadata": {}, "outputs": [], "source": [ @@ -260,7 +260,7 @@ }, { "cell_type": "markdown", - "id": "529d4a69", + "id": "2a4c1a53", "metadata": {}, "source": [ "Similar to the number of UMI counts per barcode, there seem to be small regions with higher number of genes throughout the tissue. These may correspond to regions of cellular diversity or high cellular density, as might be expected in the context of melanoma.\n", @@ -275,7 +275,7 @@ { "cell_type": "code", "execution_count": null, - "id": "67cec6ab", + "id": "5c0de575", "metadata": {}, "outputs": [], "source": [ @@ -286,7 +286,7 @@ }, { "cell_type": "markdown", - "id": "d609ca8d", + "id": "1a1cb915", "metadata": {}, "source": [ "Now compute Moran\\'s I for some barcode QC metrics using `colDataMoransI()`." @@ -295,7 +295,7 @@ { "cell_type": "code", "execution_count": null, - "id": "934b5a20", + "id": "3773b6c9", "metadata": {}, "outputs": [], "source": [ @@ -306,7 +306,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4d1442e5", + "id": "67bbad1f", "metadata": { "lines_to_next_cell": 0 }, @@ -317,7 +317,7 @@ }, { "cell_type": "markdown", - "id": "a2db1e44", + "id": "ec24b8e4", "metadata": {}, "source": [ "The results above do not substantiate the visual check for spatial autocorrelation. We will continue with investigating other QC metrics.\n", @@ -328,7 +328,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f22f8553", + "id": "c9419e10", "metadata": {}, "outputs": [], "source": [ @@ -344,7 +344,7 @@ }, { "cell_type": "markdown", - "id": "20051fb7", + "id": "424033a3", "metadata": {}, "source": [ "In keeping with expectations, barcodes associated with fewer counts appear to be associated with higher proportions of mitochondrial reads. We will exclude barcodes containing more than \\>10% mitochondrial reads for subsequent analysis. The second line removes barcodes with zero counts, but this is not necessary for this dataset as there are no barcodes with zero counts. We keep it here just to demonstrate the method. " @@ -353,7 +353,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0050bd75", + "id": "dec507e9", "metadata": {}, "outputs": [], "source": [ @@ -366,7 +366,7 @@ }, { "cell_type": "markdown", - "id": "756700b4", + "id": "2673fa0d", "metadata": {}, "source": [ "# Data Normalization\n", @@ -377,7 +377,7 @@ { "cell_type": "code", "execution_count": null, - "id": "894cb6dc", + "id": "623e6ee9", "metadata": {}, "outputs": [], "source": [ @@ -389,7 +389,7 @@ }, { "cell_type": "markdown", - "id": "0dc5a07a", + "id": "81af0cb7", "metadata": { "lines_to_next_cell": 0 }, @@ -401,7 +401,7 @@ { "cell_type": "code", "execution_count": null, - "id": "306230e1", + "id": "cd083fbf", "metadata": { "lines_to_next_cell": 0 }, @@ -415,7 +415,7 @@ }, { "cell_type": "markdown", - "id": "ced3b048", + "id": "f3922afb", "metadata": { "lines_to_next_cell": 0 }, @@ -426,7 +426,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1ee2984b", + "id": "84695a85", "metadata": {}, "outputs": [], "source": [ @@ -435,7 +435,7 @@ }, { "cell_type": "markdown", - "id": "2cdc4ef8", + "id": "60394249", "metadata": { "lines_to_next_cell": 0 }, @@ -446,7 +446,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1cf9611d", + "id": "dff79c29", "metadata": {}, "outputs": [], "source": [ @@ -457,7 +457,7 @@ }, { "cell_type": "markdown", - "id": "9c5673c8", + "id": "ac5b3cc3", "metadata": {}, "source": [ "Without the cellular overlays, we can only speculate about the potential relevance of the barcodes that seem to be separated by each PC, but each PC doe seem to separate distinct neighborhoods of barcodes. " @@ -465,7 +465,7 @@ }, { "cell_type": "markdown", - "id": "b1871fac", + "id": "35bae69e", "metadata": { "lines_to_next_cell": 0 }, @@ -476,7 +476,7 @@ { "cell_type": "code", "execution_count": null, - "id": "48924d6f", + "id": "ab97dd97", "metadata": {}, "outputs": [], "source": [ @@ -490,7 +490,7 @@ }, { "cell_type": "markdown", - "id": "cc77d63f", + "id": "2a3e95ac", "metadata": { "lines_to_next_cell": 0 }, @@ -501,7 +501,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c183a615", + "id": "b1efaebe", "metadata": {}, "outputs": [], "source": [ @@ -511,7 +511,7 @@ }, { "cell_type": "markdown", - "id": "a01690e6", + "id": "259133df", "metadata": { "lines_to_next_cell": 0 }, @@ -526,7 +526,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5e78b5d8", + "id": "07c55b92", "metadata": {}, "outputs": [], "source": [ @@ -536,7 +536,7 @@ }, { "cell_type": "markdown", - "id": "9d9b9167", + "id": "fe410fae", "metadata": { "lines_to_next_cell": 0 }, @@ -547,7 +547,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f8cc7c31", + "id": "9b1cfef8", "metadata": {}, "outputs": [], "source": [ @@ -559,7 +559,7 @@ }, { "cell_type": "markdown", - "id": "eff82003", + "id": "c3ecb9c0", "metadata": {}, "source": [ "Spatial variability can also be investigated using differential expression testing known anatomical regions complemented with spatial location. One potential drawback to this approach is the variability that is induced by the melanoma, rather than the native tissue architecture, which may preclude identification of typical structures. \n", @@ -572,7 +572,7 @@ }, { "cell_type": "markdown", - "id": "9ef25e2c", + "id": "5f6b1217", "metadata": {}, "source": [ "# Session Info" @@ -581,7 +581,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f2a7db78", + "id": "cf65bcb0", "metadata": {}, "outputs": [], "source": [ @@ -590,7 +590,7 @@ }, { "cell_type": "markdown", - "id": "0ed0e00d", + "id": "6f83dd66", "metadata": {}, "source": [ "# References" diff --git a/vignettes/vig4_cosmx.ipynb b/vignettes/vig4_cosmx.ipynb index 1c8c7f78a..35007e2d1 100644 --- a/vignettes/vig4_cosmx.ipynb +++ b/vignettes/vig4_cosmx.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "raw", - "id": "3229f31c", + "id": "7948c566", "metadata": {}, "source": [ "---\n", @@ -26,7 +26,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ba3087f7", + "id": "fafea95a", "metadata": { "tags": [ "remove_cell" @@ -43,7 +43,7 @@ { "cell_type": "code", "execution_count": null, - "id": "58521c3c", + "id": "1d866b2e", "metadata": { "eval": false, "tags": [ @@ -77,7 +77,7 @@ }, { "cell_type": "markdown", - "id": "c972737a", + "id": "f78ae1b2", "metadata": {}, "source": [ "# Introduction\n", @@ -90,7 +90,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6229a0af", + "id": "51d8c5ea", "metadata": { "name": "setup" }, @@ -115,7 +115,7 @@ { "cell_type": "code", "execution_count": null, - "id": "dceea89d", + "id": "4b337b84", "metadata": {}, "outputs": [], "source": [ @@ -124,7 +124,7 @@ }, { "cell_type": "markdown", - "id": "40a4fc77", + "id": "3c170398", "metadata": { "lines_to_next_cell": 0 }, @@ -135,7 +135,7 @@ { "cell_type": "code", "execution_count": null, - "id": "cb1382ca", + "id": "ed09de36", "metadata": {}, "outputs": [], "source": [ @@ -144,7 +144,7 @@ }, { "cell_type": "markdown", - "id": "737e6c6a", + "id": "8d4e8126", "metadata": { "lines_to_next_cell": 0 }, @@ -157,7 +157,7 @@ { "cell_type": "code", "execution_count": null, - "id": "90b087bd", + "id": "03e31826", "metadata": {}, "outputs": [], "source": [ @@ -166,7 +166,7 @@ }, { "cell_type": "markdown", - "id": "d2400e71", + "id": "ebc45c29", "metadata": {}, "source": [ "# Quality control (QC)\n", @@ -180,7 +180,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d25e90b5", + "id": "f53a74a7", "metadata": { "lines_to_next_cell": 0 }, @@ -191,7 +191,7 @@ }, { "cell_type": "markdown", - "id": "f3a33ab0", + "id": "5bdc4fd9", "metadata": { "lines_to_next_cell": 0 }, @@ -204,7 +204,7 @@ { "cell_type": "code", "execution_count": null, - "id": "97d1ac74", + "id": "9971e158", "metadata": {}, "outputs": [], "source": [ @@ -220,7 +220,7 @@ }, { "cell_type": "markdown", - "id": "364cd63a", + "id": "c314e7fd", "metadata": { "lines_to_next_cell": 0 }, @@ -231,7 +231,7 @@ { "cell_type": "code", "execution_count": null, - "id": "755136cf", + "id": "c79ff981", "metadata": { "fig.height": 4, "fig.width": 8 @@ -244,7 +244,7 @@ { "cell_type": "code", "execution_count": null, - "id": "243d54e3", + "id": "c2604be9", "metadata": {}, "outputs": [], "source": [ @@ -253,7 +253,7 @@ }, { "cell_type": "markdown", - "id": "3590d0fd", + "id": "52183a09", "metadata": {}, "source": [ "To make nCounts and nGenes more comparable across datasets, we divide them by the number of genes probed. In this dataset, there are 960 genes, and 20 negative controls. However, because different genes may be probed in different datasets, which can be from different tissues, this does not make nCounts and nGenes completely comparable across datasets. However, it may still be somewhat comparable, since genes highly expressed in major cell types in the tissue tend to be selected for the gene panel." @@ -262,7 +262,7 @@ { "cell_type": "code", "execution_count": null, - "id": "cbfc4d6c", + "id": "dd3a3437", "metadata": {}, "outputs": [], "source": [ @@ -274,7 +274,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ed00861f", + "id": "b812178f", "metadata": {}, "outputs": [], "source": [ @@ -283,7 +283,7 @@ }, { "cell_type": "markdown", - "id": "c54e283b", + "id": "fc622074", "metadata": { "lines_to_next_cell": 0 }, @@ -296,7 +296,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e424de6e", + "id": "1e3f91a8", "metadata": { "fig.height": 4, "fig.width": 8 @@ -309,7 +309,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b026f159", + "id": "9440a94a", "metadata": {}, "outputs": [], "source": [ @@ -318,7 +318,7 @@ }, { "cell_type": "markdown", - "id": "66126568", + "id": "29f65751", "metadata": { "lines_to_next_cell": 0 }, @@ -331,7 +331,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7b8202c6", + "id": "776c4cf8", "metadata": {}, "outputs": [], "source": [ @@ -340,7 +340,7 @@ }, { "cell_type": "markdown", - "id": "106f87c3", + "id": "d49d48b4", "metadata": { "lines_to_next_cell": 0 }, @@ -351,7 +351,7 @@ { "cell_type": "code", "execution_count": null, - "id": "dd714bf5", + "id": "462b1b1b", "metadata": {}, "outputs": [], "source": [ @@ -361,7 +361,7 @@ { "cell_type": "code", "execution_count": null, - "id": "dccaf0dd", + "id": "40524af7", "metadata": {}, "outputs": [], "source": [ @@ -370,7 +370,7 @@ }, { "cell_type": "markdown", - "id": "733b72ff", + "id": "9e9fe170", "metadata": { "lines_to_next_cell": 0 }, @@ -381,7 +381,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0e8ab2f6", + "id": "405c1830", "metadata": {}, "outputs": [], "source": [ @@ -390,7 +390,7 @@ }, { "cell_type": "markdown", - "id": "8756aeb1", + "id": "08fd01eb", "metadata": { "lines_to_next_cell": 0 }, @@ -403,7 +403,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4f3ac428", + "id": "5cd9d6fa", "metadata": { "fig.height": 4, "fig.width": 8 @@ -415,7 +415,7 @@ }, { "cell_type": "markdown", - "id": "c9a46ee3", + "id": "58ebea8e", "metadata": { "lines_to_next_cell": 0 }, @@ -428,7 +428,7 @@ { "cell_type": "code", "execution_count": null, - "id": "31ad2036", + "id": "4615042c", "metadata": {}, "outputs": [], "source": [ @@ -437,7 +437,7 @@ }, { "cell_type": "markdown", - "id": "650c163c", + "id": "7d4ec855", "metadata": { "lines_to_next_cell": 0 }, @@ -450,7 +450,7 @@ { "cell_type": "code", "execution_count": null, - "id": "bcb82efc", + "id": "4d1f7c88", "metadata": {}, "outputs": [], "source": [ @@ -463,7 +463,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6622416e", + "id": "00083bc9", "metadata": { "fig.height": 4, "fig.width": 8 @@ -475,7 +475,7 @@ }, { "cell_type": "markdown", - "id": "a9d0a174", + "id": "92afaec1", "metadata": {}, "source": [ "The NA's are empty cells, and the proportion is very low except for a few outliers. How does prop_neg relate to nCounts?" @@ -484,7 +484,7 @@ { "cell_type": "code", "execution_count": null, - "id": "bd743aca", + "id": "9e830acd", "metadata": {}, "outputs": [], "source": [ @@ -494,7 +494,7 @@ }, { "cell_type": "markdown", - "id": "b41d0c59", + "id": "410dee74", "metadata": { "lines_to_next_cell": 0 }, @@ -505,7 +505,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8e28d529", + "id": "e16d1b25", "metadata": {}, "outputs": [], "source": [ @@ -516,7 +516,7 @@ }, { "cell_type": "markdown", - "id": "b55c617a", + "id": "282199e6", "metadata": {}, "source": [ "The distribution is not obviously bimodal, and since the x-axis is log transformed to better visualize the distribution, the 0's have been removed. It's kind of arbitrary; for now we'll remove cells with more than 10% of transcripts from negative controls." @@ -525,7 +525,7 @@ { "cell_type": "code", "execution_count": null, - "id": "06163fd0", + "id": "be16ad01", "metadata": {}, "outputs": [], "source": [ @@ -535,7 +535,7 @@ }, { "cell_type": "markdown", - "id": "92cf24a7", + "id": "9bb8a20b", "metadata": { "lines_to_next_cell": 0 }, @@ -549,7 +549,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f1ce70fc", + "id": "e108459d", "metadata": {}, "outputs": [], "source": [ @@ -558,7 +558,7 @@ }, { "cell_type": "markdown", - "id": "54a3a37c", + "id": "67d2fba4", "metadata": { "lines_to_next_cell": 0 }, @@ -569,7 +569,7 @@ { "cell_type": "code", "execution_count": null, - "id": "bc7d1a04", + "id": "3c5a703a", "metadata": { "fig.height": 9, "fig.width": 10 @@ -583,7 +583,7 @@ }, { "cell_type": "markdown", - "id": "15699312", + "id": "83763ccd", "metadata": { "lines_to_next_cell": 0 }, @@ -594,7 +594,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3c63ac82", + "id": "0268be72", "metadata": {}, "outputs": [], "source": [ @@ -606,7 +606,7 @@ { "cell_type": "code", "execution_count": null, - "id": "fa947414", + "id": "b177c4ef", "metadata": {}, "outputs": [], "source": [ @@ -619,7 +619,7 @@ }, { "cell_type": "markdown", - "id": "a7826ccc", + "id": "951f607e", "metadata": {}, "source": [ "The red line $y = x$ is expected from Poisson data. Gene expression in this dataset has more variance than expected from Poisson, even for gene with lower expression. Zoom into the negative controls" @@ -628,7 +628,7 @@ { "cell_type": "code", "execution_count": null, - "id": "89d717eb", + "id": "4a04b5bd", "metadata": {}, "outputs": [], "source": [ @@ -643,7 +643,7 @@ }, { "cell_type": "markdown", - "id": "ec0f9b9d", + "id": "6605fa29", "metadata": { "lines_to_next_cell": 0 }, @@ -656,7 +656,7 @@ { "cell_type": "code", "execution_count": null, - "id": "920eab94", + "id": "b35feaf1", "metadata": {}, "outputs": [], "source": [ @@ -667,7 +667,7 @@ }, { "cell_type": "markdown", - "id": "f1467f4d", + "id": "286d9172", "metadata": {}, "source": [ "The negative controls have lower mean \"expression\" than the vast majority of real genes.\n", @@ -697,7 +697,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b86ef28e", + "id": "2678101b", "metadata": {}, "outputs": [], "source": [ @@ -710,7 +710,7 @@ }, { "cell_type": "markdown", - "id": "6ed63871", + "id": "2b7a1415", "metadata": { "lines_to_next_cell": 0 }, @@ -721,7 +721,7 @@ { "cell_type": "code", "execution_count": null, - "id": "83c87b25", + "id": "b60cc5c0", "metadata": {}, "outputs": [], "source": [ @@ -732,7 +732,7 @@ { "cell_type": "code", "execution_count": null, - "id": "39866528", + "id": "5a499b28", "metadata": {}, "outputs": [], "source": [ @@ -741,7 +741,7 @@ }, { "cell_type": "markdown", - "id": "3e8a8f38", + "id": "56729727", "metadata": {}, "source": [ "Positive spatial autocorrelation is suggested, which is stronger in nCounts and nGenes.\n", @@ -752,7 +752,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b1cbc590", + "id": "fb3d0b5e", "metadata": {}, "outputs": [], "source": [ @@ -765,7 +765,7 @@ }, { "cell_type": "markdown", - "id": "6ee9f839", + "id": "794a8225", "metadata": {}, "source": [ "Note that `MulticoreParam()` doesn't work on Windows; this vignette was built on Linux. Use `SnowParam()` or `DoparParam()` for Windows. See `?BiocParallelParam` for the available parallel processing backends. We did not notice significant performance differences between `ShowParam()` and `MulticoreParam()` in this context." @@ -774,7 +774,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3fb30ff5", + "id": "abf4d7e7", "metadata": {}, "outputs": [], "source": [ @@ -783,7 +783,7 @@ }, { "cell_type": "markdown", - "id": "835ee4a1", + "id": "978af1c8", "metadata": { "lines_to_next_cell": 0 }, @@ -796,7 +796,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a19aa291", + "id": "b96134f3", "metadata": {}, "outputs": [], "source": [ @@ -805,7 +805,7 @@ }, { "cell_type": "markdown", - "id": "3651a804", + "id": "a5db4202", "metadata": { "lines_to_next_cell": 0 }, @@ -816,7 +816,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f71bfe47", + "id": "c1787a19", "metadata": { "fig.height": 7, "fig.width": 8 @@ -830,7 +830,7 @@ }, { "cell_type": "markdown", - "id": "f853f7e7", + "id": "b298bc5e", "metadata": { "lines_to_next_cell": 0 }, @@ -843,7 +843,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5b3badaa", + "id": "a8e33309", "metadata": {}, "outputs": [], "source": [ @@ -853,7 +853,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1e778e91", + "id": "61b8d13e", "metadata": {}, "outputs": [], "source": [ @@ -863,7 +863,7 @@ }, { "cell_type": "markdown", - "id": "b146f02d", + "id": "7caad847", "metadata": {}, "source": [ "Cool, it appears that the epithelial regions tend to be more homogenous in nCounts.\n", @@ -875,7 +875,7 @@ { "cell_type": "code", "execution_count": null, - "id": "91100e56", + "id": "f3b1e0d1", "metadata": {}, "outputs": [], "source": [ @@ -884,7 +884,7 @@ }, { "cell_type": "markdown", - "id": "9dfb39a5", + "id": "53a9bd2e", "metadata": { "lines_to_next_cell": 0 }, @@ -897,7 +897,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5c50fd82", + "id": "c23d4043", "metadata": {}, "outputs": [], "source": [ @@ -909,7 +909,7 @@ }, { "cell_type": "markdown", - "id": "9052e1ec", + "id": "d565478a", "metadata": { "lines_to_next_cell": 0 }, @@ -920,7 +920,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3c9d7a0c", + "id": "3a5e6f4b", "metadata": {}, "outputs": [], "source": [ @@ -930,7 +930,7 @@ }, { "cell_type": "markdown", - "id": "edf5e178", + "id": "02573fea", "metadata": { "lines_to_next_cell": 0 }, @@ -943,7 +943,7 @@ { "cell_type": "code", "execution_count": null, - "id": "68dcfff8", + "id": "4cde2def", "metadata": { "fig.height": 9, "fig.width": 9 @@ -957,7 +957,7 @@ }, { "cell_type": "markdown", - "id": "a0ddc6a2", + "id": "3140616b", "metadata": { "lines_to_next_cell": 0 }, @@ -970,7 +970,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f6b6c777", + "id": "a1e2131c", "metadata": {}, "outputs": [], "source": [ @@ -981,7 +981,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d4cf7b7f", + "id": "2cafa9b8", "metadata": {}, "outputs": [], "source": [ @@ -991,7 +991,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3ee816a1", + "id": "99df67b5", "metadata": {}, "outputs": [], "source": [ @@ -1001,7 +1001,7 @@ { "cell_type": "code", "execution_count": null, - "id": "bf3c865f", + "id": "1ee2d5e4", "metadata": { "fig.height": 9, "fig.width": 9 @@ -1014,7 +1014,7 @@ }, { "cell_type": "markdown", - "id": "0bfcfac1", + "id": "84a3183d", "metadata": { "lines_to_next_cell": 0 }, @@ -1027,7 +1027,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1f078b0e", + "id": "06f5086c", "metadata": {}, "outputs": [], "source": [ @@ -1042,7 +1042,7 @@ { "cell_type": "code", "execution_count": null, - "id": "697b1aa7", + "id": "1615ae8b", "metadata": {}, "outputs": [], "source": [ @@ -1052,7 +1052,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a96397bd", + "id": "4619662d", "metadata": { "fig.height": 8, "fig.width": 8 @@ -1066,7 +1066,7 @@ { "cell_type": "code", "execution_count": null, - "id": "cbae6a5c", + "id": "a8c62295", "metadata": {}, "outputs": [], "source": [ @@ -1075,7 +1075,7 @@ }, { "cell_type": "markdown", - "id": "b9fd661b", + "id": "f3a187fa", "metadata": { "lines_to_next_cell": 0 }, @@ -1093,7 +1093,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f642ce94", + "id": "e75fd7b2", "metadata": {}, "outputs": [], "source": [ @@ -1103,7 +1103,7 @@ }, { "cell_type": "markdown", - "id": "01d561cd", + "id": "6d09cb5c", "metadata": { "lines_to_next_cell": 0 }, @@ -1114,7 +1114,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0db88faa", + "id": "8be05bf1", "metadata": {}, "outputs": [], "source": [ @@ -1123,7 +1123,7 @@ }, { "cell_type": "markdown", - "id": "d99933c9", + "id": "c19b61cb", "metadata": { "lines_to_next_cell": 0 }, @@ -1134,7 +1134,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e309c8d0", + "id": "5d6d4094", "metadata": {}, "outputs": [], "source": [ @@ -1144,7 +1144,7 @@ }, { "cell_type": "markdown", - "id": "366e438e", + "id": "76762559", "metadata": { "lines_to_next_cell": 0 }, @@ -1155,7 +1155,7 @@ { "cell_type": "code", "execution_count": null, - "id": "95c3e09c", + "id": "72351a9b", "metadata": { "fig.height": 7, "fig.width": 6 @@ -1168,7 +1168,7 @@ }, { "cell_type": "markdown", - "id": "6f8dccc0", + "id": "2f327e40", "metadata": { "lines_to_next_cell": 0 }, @@ -1180,7 +1180,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5ab6c3f7", + "id": "485f3ce5", "metadata": { "fig.height": 12, "fig.width": 8 @@ -1193,7 +1193,7 @@ }, { "cell_type": "markdown", - "id": "7b60a3a9", + "id": "ffa5bbac", "metadata": {}, "source": [ "Moran's I of these marker genes" @@ -1202,7 +1202,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6cedbf3d", + "id": "1516d9b1", "metadata": {}, "outputs": [], "source": [ @@ -1211,7 +1211,7 @@ }, { "cell_type": "markdown", - "id": "2b9d83c9", + "id": "9123230c", "metadata": { "lines_to_next_cell": 0 }, @@ -1222,7 +1222,7 @@ { "cell_type": "code", "execution_count": null, - "id": "bb315b6c", + "id": "75d22db7", "metadata": {}, "outputs": [], "source": [ @@ -1233,7 +1233,7 @@ { "cell_type": "code", "execution_count": null, - "id": "bfcaca23", + "id": "2a86365b", "metadata": { "fig.height": 12, "fig.width": 8 @@ -1247,7 +1247,7 @@ }, { "cell_type": "markdown", - "id": "39216157", + "id": "7b810142", "metadata": { "lines_to_next_cell": 0 }, @@ -1260,7 +1260,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d1a5c980", + "id": "07cfa57d", "metadata": {}, "outputs": [], "source": [ @@ -1271,7 +1271,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f936552e", + "id": "231f91fe", "metadata": { "fig.height": 12, "fig.width": 8 @@ -1284,7 +1284,7 @@ }, { "cell_type": "markdown", - "id": "d51e10b2", + "id": "2ea73a60", "metadata": { "lines_to_next_cell": 0 }, @@ -1297,7 +1297,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2db04bb7", + "id": "714147de", "metadata": {}, "outputs": [], "source": [ @@ -1306,7 +1306,7 @@ }, { "cell_type": "markdown", - "id": "ed0a5d07", + "id": "eca9cff1", "metadata": {}, "source": [ "# References" diff --git a/vignettes/vig5_xenium.ipynb b/vignettes/vig5_xenium.ipynb index ffab4210f..8902fab99 100644 --- a/vignettes/vig5_xenium.ipynb +++ b/vignettes/vig5_xenium.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "raw", - "id": "1e12b082", + "id": "88b32e62", "metadata": {}, "source": [ "---\n", @@ -26,7 +26,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d5dfe633", + "id": "8251bea5", "metadata": { "tags": [ "remove_cell" @@ -43,7 +43,7 @@ { "cell_type": "code", "execution_count": null, - "id": "915a7f5e", + "id": "7701aeef", "metadata": { "eval": false, "tags": [ @@ -77,7 +77,7 @@ }, { "cell_type": "markdown", - "id": "bb92414b", + "id": "7920ce98", "metadata": {}, "source": [ "# Introduction\n", @@ -94,7 +94,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2d474f78", + "id": "1171edcb", "metadata": { "name": "setup" }, @@ -120,7 +120,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f621b476", + "id": "53bacf32", "metadata": {}, "outputs": [], "source": [ @@ -129,7 +129,7 @@ }, { "cell_type": "markdown", - "id": "f0e277b8", + "id": "a7cc9baf", "metadata": { "lines_to_next_cell": 0 }, @@ -142,7 +142,7 @@ { "cell_type": "code", "execution_count": null, - "id": "26875b35", + "id": "6bce776c", "metadata": {}, "outputs": [], "source": [ @@ -151,7 +151,7 @@ }, { "cell_type": "markdown", - "id": "860d373d", + "id": "74c8a1ba", "metadata": {}, "source": [ "This is what the tissue, with the cell outlines, looks like" @@ -160,7 +160,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0d428cf2", + "id": "471832c7", "metadata": {}, "outputs": [], "source": [ @@ -169,7 +169,7 @@ }, { "cell_type": "markdown", - "id": "ccd4fefc", + "id": "ace99d04", "metadata": { "lines_to_next_cell": 0 }, @@ -180,7 +180,7 @@ { "cell_type": "code", "execution_count": null, - "id": "051c273b", + "id": "1d376aec", "metadata": {}, "outputs": [], "source": [ @@ -189,7 +189,7 @@ }, { "cell_type": "markdown", - "id": "329e46fa", + "id": "84520fdc", "metadata": {}, "source": [ "# Quality control\n", @@ -200,7 +200,7 @@ { "cell_type": "code", "execution_count": null, - "id": "249d2f84", + "id": "58633d04", "metadata": {}, "outputs": [], "source": [ @@ -209,7 +209,7 @@ }, { "cell_type": "markdown", - "id": "59996c12", + "id": "95c531f6", "metadata": {}, "source": [ "Since there're more cells, it would be better to plot the tissue larger, so we'll plot the histogram of QC metrics and the spatial plots separately, unlike in the CosMx vignette." @@ -218,7 +218,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7633a190", + "id": "d750acdd", "metadata": {}, "outputs": [], "source": [ @@ -229,7 +229,7 @@ }, { "cell_type": "markdown", - "id": "b5fba254", + "id": "e2f5d0bc", "metadata": {}, "source": [ "Here we divided nCounts by the total number of genes probed, so this histogram is comparable to those from other smFISH-based datasets. " @@ -238,7 +238,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6a24cbd1", + "id": "26f16fe6", "metadata": {}, "outputs": [], "source": [ @@ -247,7 +247,7 @@ }, { "cell_type": "markdown", - "id": "b2d34322", + "id": "ce92780e", "metadata": {}, "source": [ "Compared to the [FFPE CosMX non-small cell lung cancer dataset](https://pachterlab.github.io/voyager/articles/vig4_cosmx.html#cells), more transcripts per gene on average and a larger proportion of all genes are detected in this dataset, which is also FFPE. However, this should be interpreted with care, since these two datasets are from different tissues and have different gene panels, so this may or may not indicate that Xenium has better detection efficiency than CosMX." @@ -256,7 +256,7 @@ { "cell_type": "code", "execution_count": null, - "id": "63af0a0f", + "id": "c2cbb49f", "metadata": {}, "outputs": [], "source": [ @@ -265,7 +265,7 @@ }, { "cell_type": "markdown", - "id": "a05c1321", + "id": "f3b0130d", "metadata": {}, "source": [ "There seem to be FOV artifacts. However, the cell ID and FOV information were unavailable so we cannot examine them. " @@ -274,7 +274,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f578b43c", + "id": "93ea6a14", "metadata": {}, "outputs": [], "source": [ @@ -283,7 +283,7 @@ }, { "cell_type": "markdown", - "id": "17ddf1fa", + "id": "929a8b3e", "metadata": { "lines_to_next_cell": 0 }, @@ -294,7 +294,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b4726a6e", + "id": "fb1b2160", "metadata": {}, "outputs": [], "source": [ @@ -303,7 +303,7 @@ }, { "cell_type": "markdown", - "id": "29807684", + "id": "16ae0cb9", "metadata": { "lines_to_next_cell": 0 }, @@ -316,7 +316,7 @@ { "cell_type": "code", "execution_count": null, - "id": "15c54f92", + "id": "161b6fe5", "metadata": {}, "outputs": [], "source": [ @@ -325,7 +325,7 @@ }, { "cell_type": "markdown", - "id": "fc440e0e", + "id": "8622aa94", "metadata": { "lines_to_next_cell": 0 }, @@ -338,7 +338,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d6749a7b", + "id": "90afdac5", "metadata": {}, "outputs": [], "source": [ @@ -347,7 +347,7 @@ }, { "cell_type": "markdown", - "id": "06af99b7", + "id": "2cf6580d", "metadata": { "lines_to_next_cell": 0 }, @@ -360,7 +360,7 @@ { "cell_type": "code", "execution_count": null, - "id": "efe0fc6e", + "id": "00cff501", "metadata": {}, "outputs": [], "source": [ @@ -369,7 +369,7 @@ }, { "cell_type": "markdown", - "id": "b43f55fe", + "id": "56e05acf", "metadata": { "lines_to_next_cell": 0 }, @@ -382,7 +382,7 @@ { "cell_type": "code", "execution_count": null, - "id": "96bf2370", + "id": "f3db2eb7", "metadata": {}, "outputs": [], "source": [ @@ -392,7 +392,7 @@ }, { "cell_type": "markdown", - "id": "2ef13a75", + "id": "0fe70930", "metadata": {}, "source": [ "Again, there are two branches, probably related to cell density and cell type. The nucleus outlier also has large cell area, though it is not as much an outlier in cell area. However, it is a spatial outlier as it's unusually large compared to its neighbors (scroll up two plots back). \n", @@ -403,7 +403,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ed5f0bdd", + "id": "e1fbe2d1", "metadata": {}, "outputs": [], "source": [ @@ -413,7 +413,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b1aee442", + "id": "8b43b62f", "metadata": {}, "outputs": [], "source": [ @@ -422,7 +422,7 @@ }, { "cell_type": "markdown", - "id": "f9b429fb", + "id": "d0ea73ad", "metadata": { "lines_to_next_cell": 0 }, @@ -433,7 +433,7 @@ { "cell_type": "code", "execution_count": null, - "id": "47922d33", + "id": "73f27d3a", "metadata": {}, "outputs": [], "source": [ @@ -445,7 +445,7 @@ }, { "cell_type": "markdown", - "id": "1d75e539", + "id": "a98b9d10", "metadata": { "lines_to_next_cell": 0 }, @@ -456,7 +456,7 @@ { "cell_type": "code", "execution_count": null, - "id": "744f73c8", + "id": "0161089e", "metadata": {}, "outputs": [], "source": [ @@ -465,7 +465,7 @@ }, { "cell_type": "markdown", - "id": "c11bbacc", + "id": "a1d41bc1", "metadata": { "lines_to_next_cell": 0 }, @@ -478,7 +478,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e656c543", + "id": "0324d9eb", "metadata": {}, "outputs": [], "source": [ @@ -488,7 +488,7 @@ }, { "cell_type": "markdown", - "id": "4f3b065d", + "id": "0408d9dc", "metadata": { "lines_to_next_cell": 0 }, @@ -501,7 +501,7 @@ { "cell_type": "code", "execution_count": null, - "id": "57624f52", + "id": "d3cefed4", "metadata": {}, "outputs": [], "source": [ @@ -511,7 +511,7 @@ }, { "cell_type": "markdown", - "id": "6fceafc8", + "id": "72af0ea1", "metadata": { "lines_to_next_cell": 0 }, @@ -525,7 +525,7 @@ { "cell_type": "code", "execution_count": null, - "id": "063050a0", + "id": "cf317e1f", "metadata": {}, "outputs": [], "source": [ @@ -534,7 +534,7 @@ }, { "cell_type": "markdown", - "id": "75e589f2", + "id": "1b419ab2", "metadata": {}, "source": [ "According to the Xenium paper [@Janesick2022-rp], there are 3 types of controls:\n", @@ -549,7 +549,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7122dc09", + "id": "159bb165", "metadata": {}, "outputs": [], "source": [ @@ -559,7 +559,7 @@ }, { "cell_type": "markdown", - "id": "48015d91", + "id": "ab519852", "metadata": { "lines_to_next_cell": 0 }, @@ -570,7 +570,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a8559a95", + "id": "58649bd9", "metadata": {}, "outputs": [], "source": [ @@ -580,7 +580,7 @@ }, { "cell_type": "markdown", - "id": "9242afdb", + "id": "8784f236", "metadata": { "lines_to_next_cell": 0 }, @@ -591,7 +591,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c1ce065c", + "id": "d29765b0", "metadata": {}, "outputs": [], "source": [ @@ -601,7 +601,7 @@ }, { "cell_type": "markdown", - "id": "26f70ee6", + "id": "1a733c1b", "metadata": { "lines_to_next_cell": 0 }, @@ -612,7 +612,7 @@ { "cell_type": "code", "execution_count": null, - "id": "eabe9461", + "id": "26b593e8", "metadata": {}, "outputs": [], "source": [ @@ -622,7 +622,7 @@ }, { "cell_type": "markdown", - "id": "5961a707", + "id": "7b8ae9ef", "metadata": { "lines_to_next_cell": 0 }, @@ -633,7 +633,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3ed389ef", + "id": "a47b6b0a", "metadata": {}, "outputs": [], "source": [ @@ -642,7 +642,7 @@ }, { "cell_type": "markdown", - "id": "5746517c", + "id": "36fe0771", "metadata": { "lines_to_next_cell": 0 }, @@ -653,7 +653,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c23fabf3", + "id": "a03011b9", "metadata": {}, "outputs": [], "source": [ @@ -667,7 +667,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2e5c3d9e", + "id": "01f34f04", "metadata": {}, "outputs": [], "source": [ @@ -676,7 +676,7 @@ }, { "cell_type": "markdown", - "id": "31af2cb4", + "id": "0137d744", "metadata": {}, "source": [ "Next we plot the proportion of transcript counts coming from any negative control. " @@ -685,7 +685,7 @@ { "cell_type": "code", "execution_count": null, - "id": "31b18a4d", + "id": "40e0d6f5", "metadata": {}, "outputs": [], "source": [ @@ -695,7 +695,7 @@ }, { "cell_type": "markdown", - "id": "d4a97550", + "id": "9b48db13", "metadata": { "lines_to_next_cell": 0 }, @@ -706,7 +706,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d506eea9", + "id": "8757f5cc", "metadata": {}, "outputs": [], "source": [ @@ -717,7 +717,7 @@ }, { "cell_type": "markdown", - "id": "de50aaee", + "id": "81a65838", "metadata": { "lines_to_next_cell": 0 }, @@ -730,7 +730,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c70b872d", + "id": "95b6803a", "metadata": {}, "outputs": [], "source": [ @@ -742,7 +742,7 @@ }, { "cell_type": "markdown", - "id": "22cdca74", + "id": "a2168792", "metadata": {}, "source": [ "The counts are low, mostly zero, but there are outliers with up to 10 counts of all types aggregated. Then the outlier with 50% of counts from negative controls must have very low total real transcript counts to begin with.\n", @@ -755,7 +755,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d2c1c33e", + "id": "5d7dc3a8", "metadata": {}, "outputs": [], "source": [ @@ -775,7 +775,7 @@ { "cell_type": "code", "execution_count": null, - "id": "741062cf", + "id": "194c55b0", "metadata": {}, "outputs": [], "source": [ @@ -788,7 +788,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c8ff3896", + "id": "b5320ab3", "metadata": {}, "outputs": [], "source": [ @@ -797,7 +797,7 @@ }, { "cell_type": "markdown", - "id": "bf5d21e6", + "id": "50c038d4", "metadata": { "lines_to_next_cell": 0 }, @@ -808,7 +808,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f30e5b85", + "id": "7154b2a0", "metadata": {}, "outputs": [], "source": [ @@ -817,7 +817,7 @@ }, { "cell_type": "markdown", - "id": "5f80dcc7", + "id": "8ed6756d", "metadata": { "lines_to_next_cell": 0 }, @@ -828,7 +828,7 @@ { "cell_type": "code", "execution_count": null, - "id": "40bdba21", + "id": "1eabcfc5", "metadata": {}, "outputs": [], "source": [ @@ -838,7 +838,7 @@ }, { "cell_type": "markdown", - "id": "5715deb3", + "id": "7449d109", "metadata": { "lines_to_next_cell": 0 }, @@ -849,7 +849,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8f427058", + "id": "873bec09", "metadata": {}, "outputs": [], "source": [ @@ -858,7 +858,7 @@ }, { "cell_type": "markdown", - "id": "852572d8", + "id": "0f724d5f", "metadata": {}, "source": [ "Now that we have identified the outliers, we can remove them along with empty cells before proceeding to further analysis:" @@ -867,7 +867,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2cd06b99", + "id": "90c1a429", "metadata": {}, "outputs": [], "source": [ @@ -878,7 +878,7 @@ }, { "cell_type": "markdown", - "id": "b67bfa7e", + "id": "57946362", "metadata": { "lines_to_next_cell": 0 }, @@ -891,7 +891,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b0af38d9", + "id": "4e5c16a9", "metadata": {}, "outputs": [], "source": [ @@ -902,7 +902,7 @@ }, { "cell_type": "markdown", - "id": "0d5e9d82", + "id": "cf3984ab", "metadata": { "lines_to_next_cell": 0 }, @@ -916,7 +916,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c1e35f63", + "id": "c1a2e691", "metadata": {}, "outputs": [], "source": [ @@ -926,7 +926,7 @@ }, { "cell_type": "markdown", - "id": "ea0397d6", + "id": "0a7bee77", "metadata": { "lines_to_next_cell": 0 }, @@ -937,7 +937,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e8bff15c", + "id": "7f694f12", "metadata": {}, "outputs": [], "source": [ @@ -949,7 +949,7 @@ }, { "cell_type": "markdown", - "id": "dbeffb85", + "id": "40c5d696", "metadata": { "lines_to_next_cell": 0 }, @@ -960,7 +960,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6826dd09", + "id": "91f527d6", "metadata": {}, "outputs": [], "source": [ @@ -975,7 +975,7 @@ }, { "cell_type": "markdown", - "id": "a353e72b", + "id": "b5dc4783", "metadata": {}, "source": [ "The red line $y = x$ is expected if the data follows a Poisson distribution. Negative controls and real genes form mostly separate clusters. Negative controls stick close to the line, while real genes are overdispersed. Unlike in the [CosMX dataset](https://pachterlab.github.io/voyager/articles/vig4_cosmx.html#genes), the negative controls don't seem overdispersed.\n", @@ -990,7 +990,7 @@ { "cell_type": "code", "execution_count": null, - "id": "324174e3", + "id": "3ee28b4e", "metadata": {}, "outputs": [], "source": [ @@ -1004,7 +1004,7 @@ { "cell_type": "code", "execution_count": null, - "id": "da1d4e6f", + "id": "90715be5", "metadata": {}, "outputs": [], "source": [ @@ -1015,7 +1015,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d7137411", + "id": "b6ceecb3", "metadata": {}, "outputs": [], "source": [ @@ -1024,7 +1024,7 @@ }, { "cell_type": "markdown", - "id": "3782f905", + "id": "69897ac7", "metadata": {}, "source": [ "Global Moran's I indicatse positive spatial autocorrelation. As the strength of spatial autocorrelation can vary spatially, we also run local Moran's I." @@ -1033,7 +1033,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3696df4e", + "id": "574342ff", "metadata": {}, "outputs": [], "source": [ @@ -1045,7 +1045,7 @@ }, { "cell_type": "markdown", - "id": "f69ebc11", + "id": "76f6aa64", "metadata": { "lines_to_next_cell": 0 }, @@ -1056,7 +1056,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a21d3d6d", + "id": "fbced35b", "metadata": { "fig.height": 6, "fig.width": 9 @@ -1071,7 +1071,7 @@ }, { "cell_type": "markdown", - "id": "308e36bc", + "id": "8683bae7", "metadata": { "lines_to_next_cell": 0 }, @@ -1084,7 +1084,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a826fbba", + "id": "248a6178", "metadata": {}, "outputs": [], "source": [ @@ -1094,7 +1094,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ef7c18b9", + "id": "34a1ff7c", "metadata": { "fig.height": 7, "fig.width": 8 @@ -1108,7 +1108,7 @@ }, { "cell_type": "markdown", - "id": "68fe2ba5", + "id": "2ed8fe5b", "metadata": {}, "source": [ "There are no obvious clusters here. In the lower panel, the 2D histogram of influential points is plotted in red.\n", @@ -1121,7 +1121,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9e5cf100", + "id": "f5cd1d04", "metadata": {}, "outputs": [], "source": [ @@ -1130,7 +1130,7 @@ }, { "cell_type": "markdown", - "id": "f7e6a3ee", + "id": "32f252c3", "metadata": { "lines_to_next_cell": 0 }, @@ -1141,7 +1141,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c58e0b30", + "id": "246d6b4e", "metadata": {}, "outputs": [], "source": [ @@ -1153,7 +1153,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8d065c12", + "id": "bb593742", "metadata": {}, "outputs": [], "source": [ @@ -1163,7 +1163,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a4d59f55", + "id": "5bfdd920", "metadata": {}, "outputs": [], "source": [ @@ -1172,7 +1172,7 @@ }, { "cell_type": "markdown", - "id": "3e1a5059", + "id": "68262912", "metadata": { "lines_to_next_cell": 0 }, @@ -1185,7 +1185,7 @@ { "cell_type": "code", "execution_count": null, - "id": "564a3b12", + "id": "f9d29354", "metadata": { "fig.height": 3, "fig.width": 9 @@ -1200,7 +1200,7 @@ }, { "cell_type": "markdown", - "id": "986e92e5", + "id": "491d53fa", "metadata": { "lines_to_next_cell": 0 }, @@ -1213,7 +1213,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7429f251", + "id": "8ef8bb94", "metadata": {}, "outputs": [], "source": [ @@ -1222,7 +1222,7 @@ }, { "cell_type": "markdown", - "id": "20e1b7a8", + "id": "6fecab7d", "metadata": { "lines_to_next_cell": 0 }, @@ -1233,7 +1233,7 @@ { "cell_type": "code", "execution_count": null, - "id": "664299a4", + "id": "860f96be", "metadata": { "fig.height": 9, "fig.width": 9 @@ -1247,7 +1247,7 @@ }, { "cell_type": "markdown", - "id": "7a82de4b", + "id": "dcb701ff", "metadata": { "lines_to_next_cell": 0 }, @@ -1258,7 +1258,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0c70e908", + "id": "20db0fb4", "metadata": {}, "outputs": [], "source": [ @@ -1267,7 +1267,7 @@ }, { "cell_type": "markdown", - "id": "4d18dcab", + "id": "26aa2e08", "metadata": { "lines_to_next_cell": 0 }, @@ -1282,7 +1282,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0aa719a1", + "id": "3899d7c5", "metadata": {}, "outputs": [], "source": [ @@ -1293,7 +1293,7 @@ { "cell_type": "code", "execution_count": null, - "id": "64ec2c66", + "id": "046bd20b", "metadata": {}, "outputs": [], "source": [ @@ -1303,7 +1303,7 @@ { "cell_type": "code", "execution_count": null, - "id": "05da1e01", + "id": "71270658", "metadata": {}, "outputs": [], "source": [ @@ -1313,7 +1313,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6d6ea093", + "id": "52f51808", "metadata": { "fig.height": 9, "fig.width": 9 @@ -1326,7 +1326,7 @@ }, { "cell_type": "markdown", - "id": "93b4fd3c", + "id": "88047f38", "metadata": { "lines_to_next_cell": 0 }, @@ -1339,7 +1339,7 @@ { "cell_type": "code", "execution_count": null, - "id": "308142d1", + "id": "b4eecd3a", "metadata": {}, "outputs": [], "source": [ @@ -1353,7 +1353,7 @@ }, { "cell_type": "markdown", - "id": "9d775bc4", + "id": "753274e9", "metadata": { "lines_to_next_cell": 0 }, @@ -1364,7 +1364,7 @@ { "cell_type": "code", "execution_count": null, - "id": "fdfd49d0", + "id": "6bb7b547", "metadata": { "fig.height": 8, "fig.width": 8 @@ -1376,7 +1376,7 @@ }, { "cell_type": "markdown", - "id": "a34beaac", + "id": "909af499", "metadata": { "lines_to_next_cell": 0 }, @@ -1387,7 +1387,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b4639aba", + "id": "657eeba0", "metadata": {}, "outputs": [], "source": [ @@ -1396,7 +1396,7 @@ }, { "cell_type": "markdown", - "id": "d9fb78c0", + "id": "06f3d85f", "metadata": { "lines_to_next_cell": 0 }, @@ -1408,7 +1408,7 @@ { "cell_type": "code", "execution_count": null, - "id": "39626f54", + "id": "0e5e8324", "metadata": {}, "outputs": [], "source": [ @@ -1418,7 +1418,7 @@ }, { "cell_type": "markdown", - "id": "f2b6b542", + "id": "7a868714", "metadata": { "lines_to_next_cell": 0 }, @@ -1429,7 +1429,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0582fdff", + "id": "4fa88c4b", "metadata": {}, "outputs": [], "source": [ @@ -1438,7 +1438,7 @@ }, { "cell_type": "markdown", - "id": "e39af363", + "id": "d5ec620f", "metadata": { "lines_to_next_cell": 0 }, @@ -1449,7 +1449,7 @@ { "cell_type": "code", "execution_count": null, - "id": "17ceb355", + "id": "b1f01e48", "metadata": {}, "outputs": [], "source": [ @@ -1459,7 +1459,7 @@ }, { "cell_type": "markdown", - "id": "ef642fc9", + "id": "b8d56b74", "metadata": { "lines_to_next_cell": 0 }, @@ -1470,7 +1470,7 @@ { "cell_type": "code", "execution_count": null, - "id": "397fb813", + "id": "634e337b", "metadata": { "fig.height": 8, "fig.width": 6 @@ -1483,7 +1483,7 @@ }, { "cell_type": "markdown", - "id": "ae3f3d66", + "id": "2d1deff9", "metadata": { "lines_to_next_cell": 0 }, @@ -1496,7 +1496,7 @@ { "cell_type": "code", "execution_count": null, - "id": "53d2f750", + "id": "943f5325", "metadata": { "fig.height": 9, "fig.width": 9 @@ -1509,7 +1509,7 @@ }, { "cell_type": "markdown", - "id": "92f35d18", + "id": "ece01e99", "metadata": {}, "source": [ "Global Moran's I of these marker genes is shown below:" @@ -1518,7 +1518,7 @@ { "cell_type": "code", "execution_count": null, - "id": "61d94c60", + "id": "bb24e2e9", "metadata": {}, "outputs": [], "source": [ @@ -1527,7 +1527,7 @@ }, { "cell_type": "markdown", - "id": "745d90df", + "id": "a83a4994", "metadata": { "lines_to_next_cell": 0 }, @@ -1540,7 +1540,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9ef3694c", + "id": "f0d8d9fd", "metadata": {}, "outputs": [], "source": [ @@ -1551,7 +1551,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3d2da81b", + "id": "631b4f3a", "metadata": { "fig.height": 9, "fig.width": 9 @@ -1565,7 +1565,7 @@ }, { "cell_type": "markdown", - "id": "984a5ca0", + "id": "65fc3e83", "metadata": { "lines_to_next_cell": 0 }, @@ -1578,7 +1578,7 @@ { "cell_type": "code", "execution_count": null, - "id": "22b45116", + "id": "2c669a2b", "metadata": {}, "outputs": [], "source": [ @@ -1589,7 +1589,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1374e344", + "id": "d57ee235", "metadata": { "fig.height": 9, "fig.width": 9 @@ -1603,7 +1603,7 @@ }, { "cell_type": "markdown", - "id": "57e48d04", + "id": "6b9ab423", "metadata": { "lines_to_next_cell": 0 }, @@ -1616,7 +1616,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a527bbfd", + "id": "76bba142", "metadata": {}, "outputs": [], "source": [ @@ -1625,7 +1625,7 @@ }, { "cell_type": "markdown", - "id": "32dffb65", + "id": "5f05e18a", "metadata": {}, "source": [ "# References" diff --git a/vignettes/vig6_merfish.ipynb b/vignettes/vig6_merfish.ipynb index 20cb98a4f..5685b0e3d 100644 --- a/vignettes/vig6_merfish.ipynb +++ b/vignettes/vig6_merfish.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "raw", - "id": "c271fd05", + "id": "783a6a76", "metadata": {}, "source": [ "---\n", @@ -26,7 +26,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d8093d33", + "id": "8550b8bd", "metadata": { "tags": [ "remove_cell" @@ -43,7 +43,7 @@ { "cell_type": "code", "execution_count": null, - "id": "31bdd803", + "id": "d2a6dee0", "metadata": { "eval": false, "tags": [ @@ -77,7 +77,7 @@ }, { "cell_type": "markdown", - "id": "cd6648ce", + "id": "069e4af4", "metadata": { "lines_to_next_cell": 0 }, @@ -97,7 +97,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4a625c3f", + "id": "e74279d2", "metadata": { "name": "setup" }, @@ -124,7 +124,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7ed1c957", + "id": "05c43ad1", "metadata": {}, "outputs": [], "source": [ @@ -133,7 +133,7 @@ }, { "cell_type": "markdown", - "id": "58befb7e", + "id": "ef31295b", "metadata": { "lines_to_next_cell": 0 }, @@ -144,7 +144,7 @@ { "cell_type": "code", "execution_count": null, - "id": "034fd861", + "id": "28ce53c1", "metadata": { "fig.height": 6, "fig.width": 9 @@ -156,7 +156,7 @@ }, { "cell_type": "markdown", - "id": "0a2477dc", + "id": "892d3664", "metadata": { "lines_to_next_cell": 0 }, @@ -169,7 +169,7 @@ { "cell_type": "code", "execution_count": null, - "id": "08725b64", + "id": "697aa28a", "metadata": { "fig.height": 6, "fig.width": 9 @@ -181,7 +181,7 @@ }, { "cell_type": "markdown", - "id": "83e91fab", + "id": "4683eb32", "metadata": { "lines_to_next_cell": 0 }, @@ -194,7 +194,7 @@ { "cell_type": "code", "execution_count": null, - "id": "199f4617", + "id": "d230e0be", "metadata": {}, "outputs": [], "source": [ @@ -203,7 +203,7 @@ }, { "cell_type": "markdown", - "id": "c35f3c0e", + "id": "f514e221", "metadata": { "lines_to_next_cell": 0 }, @@ -214,7 +214,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b05ec9cd", + "id": "66738313", "metadata": {}, "outputs": [], "source": [ @@ -225,7 +225,7 @@ }, { "cell_type": "markdown", - "id": "660efdf8", + "id": "11d54655", "metadata": {}, "source": [ "Here nCounts kind of looks like salt and pepper. Using the [`scattermore`](https://github.com/exaexa/scattermore) package can speed up plotting a large number of points. In this non-interactive plot, the cell polygons are too small to see anyway, so plotting cell centroid points should be fine. " @@ -234,7 +234,7 @@ { "cell_type": "code", "execution_count": null, - "id": "edc67a4c", + "id": "95cc6bd9", "metadata": {}, "outputs": [], "source": [ @@ -246,7 +246,7 @@ }, { "cell_type": "markdown", - "id": "ecc11e89", + "id": "8915fa8f", "metadata": {}, "source": [ "When run on our server, plotting almost 400,000 polygons took around 23 seconds, while using `geom_scattermore()` (`scattermore = TRUE`) took about 2 seconds. Since `geom_scattermore()` rasterizes the plot, the plot will be pixelated when zoomed in. \n", @@ -257,7 +257,7 @@ { "cell_type": "code", "execution_count": null, - "id": "bfa8b377", + "id": "844919c0", "metadata": {}, "outputs": [], "source": [ @@ -267,7 +267,7 @@ { "cell_type": "code", "execution_count": null, - "id": "36246a3b", + "id": "0d075d46", "metadata": {}, "outputs": [], "source": [ @@ -276,7 +276,7 @@ }, { "cell_type": "markdown", - "id": "4578bf26", + "id": "2c48aebe", "metadata": { "lines_to_next_cell": 0 }, @@ -291,7 +291,7 @@ { "cell_type": "code", "execution_count": null, - "id": "39f5a4b2", + "id": "1481b859", "metadata": {}, "outputs": [], "source": [ @@ -300,7 +300,7 @@ }, { "cell_type": "markdown", - "id": "9a516ab0", + "id": "566846a6", "metadata": {}, "source": [ "The number of real genes is 347." @@ -309,7 +309,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8295181b", + "id": "893c6bb8", "metadata": {}, "outputs": [], "source": [ @@ -318,7 +318,7 @@ }, { "cell_type": "markdown", - "id": "2fa2cce8", + "id": "595769a0", "metadata": { "lines_to_next_cell": 0 }, @@ -329,7 +329,7 @@ { "cell_type": "code", "execution_count": null, - "id": "eef091d7", + "id": "d06c6477", "metadata": {}, "outputs": [], "source": [ @@ -340,7 +340,7 @@ { "cell_type": "code", "execution_count": null, - "id": "eb69f51d", + "id": "a196c343", "metadata": {}, "outputs": [], "source": [ @@ -349,7 +349,7 @@ }, { "cell_type": "markdown", - "id": "9cc8c2ef", + "id": "9d130d38", "metadata": { "lines_to_next_cell": 0 }, @@ -362,7 +362,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1a616b6e", + "id": "6fb73bbb", "metadata": {}, "outputs": [], "source": [ @@ -371,7 +371,7 @@ }, { "cell_type": "markdown", - "id": "ea68d52b", + "id": "d8ea3a5b", "metadata": { "lines_to_next_cell": 0 }, @@ -384,7 +384,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c09c9469", + "id": "d8a9d809", "metadata": {}, "outputs": [], "source": [ @@ -393,7 +393,7 @@ }, { "cell_type": "markdown", - "id": "2a226f07", + "id": "af2324ea", "metadata": { "lines_to_next_cell": 0 }, @@ -404,7 +404,7 @@ { "cell_type": "code", "execution_count": null, - "id": "da345b35", + "id": "2791c336", "metadata": {}, "outputs": [], "source": [ @@ -413,7 +413,7 @@ }, { "cell_type": "markdown", - "id": "cb8150df", + "id": "8ba87950", "metadata": { "lines_to_next_cell": 0 }, @@ -426,7 +426,7 @@ { "cell_type": "code", "execution_count": null, - "id": "bbf4fdcf", + "id": "4b7dc8f6", "metadata": {}, "outputs": [], "source": [ @@ -435,7 +435,7 @@ }, { "cell_type": "markdown", - "id": "613d4d21", + "id": "46b134bb", "metadata": { "lines_to_next_cell": 0 }, @@ -448,7 +448,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2fc1d997", + "id": "8f85944e", "metadata": {}, "outputs": [], "source": [ @@ -457,7 +457,7 @@ }, { "cell_type": "markdown", - "id": "393c593a", + "id": "07c951e4", "metadata": { "lines_to_next_cell": 0 }, @@ -471,7 +471,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f926ecd0", + "id": "526a75ff", "metadata": {}, "outputs": [], "source": [ @@ -481,7 +481,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1c460e9e", + "id": "afe0eae3", "metadata": {}, "outputs": [], "source": [ @@ -491,7 +491,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5bced8fe", + "id": "d947383b", "metadata": {}, "outputs": [], "source": [ @@ -500,7 +500,7 @@ }, { "cell_type": "markdown", - "id": "e02e58ff", + "id": "a2dac203", "metadata": { "lines_to_next_cell": 0 }, @@ -511,7 +511,7 @@ { "cell_type": "code", "execution_count": null, - "id": "dc8ecf27", + "id": "1b26b2cd", "metadata": {}, "outputs": [], "source": [ @@ -521,7 +521,7 @@ }, { "cell_type": "markdown", - "id": "add1f0b4", + "id": "1b403b12", "metadata": { "lines_to_next_cell": 0 }, @@ -532,7 +532,7 @@ { "cell_type": "code", "execution_count": null, - "id": "33561e62", + "id": "7be33c97", "metadata": {}, "outputs": [], "source": [ @@ -542,7 +542,7 @@ }, { "cell_type": "markdown", - "id": "74680b14", + "id": "de47a3ac", "metadata": { "lines_to_next_cell": 0 }, @@ -553,7 +553,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0c1edeaf", + "id": "fc733c0a", "metadata": {}, "outputs": [], "source": [ @@ -563,7 +563,7 @@ }, { "cell_type": "markdown", - "id": "78d2d366", + "id": "ce0db4d6", "metadata": { "lines_to_next_cell": 0 }, @@ -576,7 +576,7 @@ { "cell_type": "code", "execution_count": null, - "id": "78d807f3", + "id": "17dbee8f", "metadata": {}, "outputs": [], "source": [ @@ -585,7 +585,7 @@ }, { "cell_type": "markdown", - "id": "3d3c6d0f", + "id": "a065d998", "metadata": { "lines_to_next_cell": 0 }, @@ -596,7 +596,7 @@ { "cell_type": "code", "execution_count": null, - "id": "aecbac8e", + "id": "37b1cf94", "metadata": {}, "outputs": [], "source": [ @@ -605,7 +605,7 @@ }, { "cell_type": "markdown", - "id": "9daeaa62", + "id": "af8cdbde", "metadata": { "lines_to_next_cell": 0 }, @@ -616,7 +616,7 @@ { "cell_type": "code", "execution_count": null, - "id": "125fa252", + "id": "451ba42f", "metadata": {}, "outputs": [], "source": [ @@ -627,7 +627,7 @@ }, { "cell_type": "markdown", - "id": "18ecac56", + "id": "7b16cf2e", "metadata": {}, "source": [ "A small percentage of blank counts is acceptable. So we will remove the outlier based on the distribution of the percentage when it's greater than zero. How does the blank percentage relate to total counts?" @@ -636,7 +636,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f5262cb7", + "id": "f5c557fa", "metadata": {}, "outputs": [], "source": [ @@ -646,7 +646,7 @@ }, { "cell_type": "markdown", - "id": "735859b5", + "id": "c3c9d0ac", "metadata": { "lines_to_next_cell": 0 }, @@ -657,7 +657,7 @@ { "cell_type": "code", "execution_count": null, - "id": "acdfbb4d", + "id": "68afe2c0", "metadata": {}, "outputs": [], "source": [ @@ -677,7 +677,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0734037d", + "id": "84fa2600", "metadata": {}, "outputs": [], "source": [ @@ -686,7 +686,7 @@ }, { "cell_type": "markdown", - "id": "d19c22d1", + "id": "0518376f", "metadata": { "lines_to_next_cell": 0 }, @@ -697,7 +697,7 @@ { "cell_type": "code", "execution_count": null, - "id": "93e6108a", + "id": "9c166b75", "metadata": {}, "outputs": [], "source": [ @@ -706,7 +706,7 @@ }, { "cell_type": "markdown", - "id": "4376ad25", + "id": "2cabc1cd", "metadata": { "lines_to_next_cell": 0 }, @@ -717,7 +717,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8fc3497c", + "id": "2521f0ba", "metadata": {}, "outputs": [], "source": [ @@ -726,7 +726,7 @@ }, { "cell_type": "markdown", - "id": "e486a0c7", + "id": "3a168ac5", "metadata": { "lines_to_next_cell": 0 }, @@ -737,7 +737,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c9263837", + "id": "ec624c8e", "metadata": {}, "outputs": [], "source": [ @@ -746,7 +746,7 @@ }, { "cell_type": "markdown", - "id": "e7eb564c", + "id": "93f68735", "metadata": { "lines_to_next_cell": 0 }, @@ -760,7 +760,7 @@ { "cell_type": "code", "execution_count": null, - "id": "13796970", + "id": "a8bfb256", "metadata": {}, "outputs": [], "source": [ @@ -771,7 +771,7 @@ { "cell_type": "code", "execution_count": null, - "id": "28acd187", + "id": "1ecd3111", "metadata": {}, "outputs": [], "source": [ @@ -783,7 +783,7 @@ }, { "cell_type": "markdown", - "id": "2a5e9bec", + "id": "ae5ef702", "metadata": { "lines_to_next_cell": 0 }, @@ -796,7 +796,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0926eab3", + "id": "9496583b", "metadata": {}, "outputs": [], "source": [ @@ -809,7 +809,7 @@ }, { "cell_type": "markdown", - "id": "a3209480", + "id": "f8f33adc", "metadata": { "lines_to_next_cell": 0 }, @@ -820,7 +820,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1482b166", + "id": "4972e60c", "metadata": {}, "outputs": [], "source": [ @@ -835,7 +835,7 @@ }, { "cell_type": "markdown", - "id": "26e88932", + "id": "0df039ca", "metadata": { "lines_to_next_cell": 0 }, @@ -850,7 +850,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0cb36acd", + "id": "f859b306", "metadata": { "lines_to_next_cell": 2 }, @@ -861,7 +861,7 @@ }, { "cell_type": "markdown", - "id": "1c1fe4c2", + "id": "08791bec", "metadata": {}, "source": [ "There are quite a few cells that are not contiguous to any other cell, and cell segmentation is imperfect, so purely using `poly2nb()` is problematic. In the next release, we might implement a way to blend a polygon contiguity graph with some other graph in case of singletons. For now, we use k nearest neighbors with $k = 5$, which seems like a reasonable approximation of contiguity based on the visual inspection. \n", @@ -872,7 +872,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b864039a", + "id": "359e2f87", "metadata": {}, "outputs": [], "source": [ @@ -885,7 +885,7 @@ }, { "cell_type": "markdown", - "id": "e51a032b", + "id": "e06dcccf", "metadata": {}, "source": [ "With the spatial neighborhood graph, we can compute Moran's I for QC metrics." @@ -894,7 +894,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d79098d6", + "id": "d0209b8f", "metadata": {}, "outputs": [], "source": [ @@ -905,7 +905,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e08db6e9", + "id": "7498e83e", "metadata": {}, "outputs": [], "source": [ @@ -914,7 +914,7 @@ }, { "cell_type": "markdown", - "id": "968046fe", + "id": "e2d5ef41", "metadata": { "lines_to_next_cell": 0 }, @@ -927,7 +927,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5c8b0618", + "id": "ed7300db", "metadata": {}, "outputs": [], "source": [ @@ -939,7 +939,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b44b34cc", + "id": "d9d3b30c", "metadata": { "fig.height": 7, "fig.width": 9 @@ -953,7 +953,7 @@ }, { "cell_type": "markdown", - "id": "cb4f2c29", + "id": "9a060ced", "metadata": { "lines_to_next_cell": 0 }, @@ -966,7 +966,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9c30d741", + "id": "98d92381", "metadata": {}, "outputs": [], "source": [ @@ -976,7 +976,7 @@ { "cell_type": "code", "execution_count": null, - "id": "eb030b6c", + "id": "e44732e6", "metadata": {}, "outputs": [], "source": [ @@ -987,7 +987,7 @@ }, { "cell_type": "markdown", - "id": "42cc398d", + "id": "8ab44f72", "metadata": {}, "source": [ "It's actually not as slow as I thought for almost 400,000 cells. How are Moran's I's distributed for real genes and blank probes?" @@ -996,7 +996,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d44b2a77", + "id": "e10be7cf", "metadata": {}, "outputs": [], "source": [ @@ -1006,7 +1006,7 @@ }, { "cell_type": "markdown", - "id": "6955b23e", + "id": "670e8f0b", "metadata": {}, "source": [ "The blanks are clustered tightly around 0. The vast majority of real genes have positive spatial autocorrelation, some quite strong. But some genes have negative spatial autocorrelation, although it may or may not be statistically significant.\n", @@ -1017,7 +1017,7 @@ { "cell_type": "code", "execution_count": null, - "id": "593b0340", + "id": "be5a5a03", "metadata": { "fig.height": 12, "fig.width": 9 @@ -1031,7 +1031,7 @@ }, { "cell_type": "markdown", - "id": "d2d64ca5", + "id": "48cfa402", "metadata": {}, "source": [ "Unlike in the other smFISH-based cancer datasets on this dataset, the genes with the highest Moran's I highlight different histological regions. Some probably for zones in the hepatic lobule, and some for blood vessels. It would be interesting to compare spatial autocorrelation of marker genes among different tissues and cell types.\n", @@ -1042,7 +1042,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3de9b346", + "id": "1a1f8e47", "metadata": { "fig.height": 5, "fig.width": 9 @@ -1057,7 +1057,7 @@ }, { "cell_type": "markdown", - "id": "3f3abd7d", + "id": "f70cf93e", "metadata": { "lines_to_next_cell": 0 }, @@ -1074,7 +1074,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3a55136e", + "id": "7edd024a", "metadata": {}, "outputs": [], "source": [ @@ -1083,7 +1083,7 @@ }, { "cell_type": "markdown", - "id": "51c704fb", + "id": "182690fb", "metadata": { "lines_to_next_cell": 0 }, @@ -1094,7 +1094,7 @@ { "cell_type": "code", "execution_count": null, - "id": "96d50f17", + "id": "02f9a56e", "metadata": {}, "outputs": [], "source": [ @@ -1106,7 +1106,7 @@ }, { "cell_type": "markdown", - "id": "4dd37a21", + "id": "20baa6b9", "metadata": { "lines_to_next_cell": 0 }, @@ -1117,7 +1117,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ddce9037", + "id": "f5e2b31e", "metadata": { "fig.height": 7, "fig.width": 9 @@ -1134,7 +1134,7 @@ }, { "cell_type": "markdown", - "id": "4ffe90b1", + "id": "f2ff7630", "metadata": { "lines_to_next_cell": 0 }, @@ -1147,7 +1147,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c02ed70f", + "id": "60c60e12", "metadata": {}, "outputs": [], "source": [ @@ -1158,7 +1158,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0b3df60f", + "id": "0a296e33", "metadata": {}, "outputs": [], "source": [ @@ -1168,7 +1168,7 @@ }, { "cell_type": "markdown", - "id": "ecbf00d2", + "id": "738be66a", "metadata": {}, "source": [ "At a larger length scale, Moran's I becomes positive. Comparing Moran's I across different sized bins can give a sense of the length scale of spatial autocorrelation. However, there are problems with binning to watch out for:\n", @@ -1200,7 +1200,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b1dd01fd", + "id": "f81345ee", "metadata": { "warning": false }, @@ -1213,7 +1213,7 @@ }, { "cell_type": "markdown", - "id": "dd644acc", + "id": "41f78c9b", "metadata": { "lines_to_next_cell": 0 }, @@ -1226,7 +1226,7 @@ { "cell_type": "code", "execution_count": null, - "id": "bda81c3e", + "id": "45aa3f5f", "metadata": {}, "outputs": [], "source": [ @@ -1236,7 +1236,7 @@ }, { "cell_type": "markdown", - "id": "1e4a332d", + "id": "3842640f", "metadata": { "lines_to_next_cell": 0 }, @@ -1249,7 +1249,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1729770c", + "id": "6eeaec2c", "metadata": {}, "outputs": [], "source": [ @@ -1260,7 +1260,7 @@ }, { "cell_type": "markdown", - "id": "634dfcc9", + "id": "9a9ffba8", "metadata": {}, "source": [ "The variogram rises when going beyond 2000 at 30 and 90 degrees and drops at 150 degrees. This is consistent with the variogram map. These differences are averaged out in the omni-directional variogram. `gstat` does not fit anisotropy parameters, so the fitted curve is omni-directional. It fits pretty well below 2000. This is only for nCounts, and may differ for other QC metrics and genes. What if anisotropy varies in space? A problem with the variogram is that it's global, giving one result for the entire dataset, albeit more nuanced than just a number as in Moran's I, because kriging assumes that the data is intrinsically stationary, meaning that the same variogram model applies everywhere, and that spatial dependence only depends on lag between two observations.\n", @@ -1274,7 +1274,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4fd7b709", + "id": "fbe9a668", "metadata": {}, "outputs": [], "source": [ @@ -1289,7 +1289,7 @@ }, { "cell_type": "markdown", - "id": "da99a489", + "id": "c0b3e0b5", "metadata": {}, "source": [ "That's pretty quick for almost 400,000 cells, but there aren't that many genes here. Use the elbow plot to see variance explained by each PC:" @@ -1298,7 +1298,7 @@ { "cell_type": "code", "execution_count": null, - "id": "581d374b", + "id": "5f88716c", "metadata": {}, "outputs": [], "source": [ @@ -1307,7 +1307,7 @@ }, { "cell_type": "markdown", - "id": "43ee1169", + "id": "86cd6de6", "metadata": { "lines_to_next_cell": 0 }, @@ -1318,7 +1318,7 @@ { "cell_type": "code", "execution_count": null, - "id": "927f6155", + "id": "36a4ea93", "metadata": {}, "outputs": [], "source": [ @@ -1327,7 +1327,7 @@ }, { "cell_type": "markdown", - "id": "23d44e9d", + "id": "00d2bcaf", "metadata": { "lines_to_next_cell": 0 }, @@ -1340,7 +1340,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a5a1a21e", + "id": "078d0737", "metadata": { "fig.height": 7, "fig.width": 9 @@ -1353,7 +1353,7 @@ }, { "cell_type": "markdown", - "id": "6e0555fe", + "id": "f688d2a8", "metadata": { "lines_to_next_cell": 0 }, @@ -1366,7 +1366,7 @@ { "cell_type": "code", "execution_count": null, - "id": "07f56fc3", + "id": "54842ba3", "metadata": { "fig.height": 5, "fig.width": 9 @@ -1379,7 +1379,7 @@ }, { "cell_type": "markdown", - "id": "030ef2b5", + "id": "b30f0176", "metadata": {}, "source": [ "There's some spatial structure in PC2 and PC3 at a smaller scale, perhaps some negative spatial autocorrelation.\n", @@ -1404,7 +1404,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d89e2f73", + "id": "52ce2f25", "metadata": {}, "outputs": [], "source": [ @@ -1413,7 +1413,7 @@ }, { "cell_type": "markdown", - "id": "16c263db", + "id": "13525537", "metadata": {}, "source": [ "# References" diff --git a/vignettes/vig7_seqfish.ipynb b/vignettes/vig7_seqfish.ipynb index 8d124b21e..ef7ab1fa4 100644 --- a/vignettes/vig7_seqfish.ipynb +++ b/vignettes/vig7_seqfish.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "raw", - "id": "862af467", + "id": "d2a5f511", "metadata": {}, "source": [ "---\n", @@ -26,7 +26,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ec389d43", + "id": "396fd4c3", "metadata": { "tags": [ "remove_cell" @@ -43,7 +43,7 @@ { "cell_type": "code", "execution_count": null, - "id": "580026d2", + "id": "37766eb9", "metadata": { "eval": false, "tags": [ @@ -81,7 +81,7 @@ }, { "cell_type": "markdown", - "id": "716c51bc", + "id": "20a7476b", "metadata": { "lines_to_next_cell": 0 }, @@ -99,7 +99,7 @@ { "cell_type": "code", "execution_count": null, - "id": "37a45a8b", + "id": "ef730f9f", "metadata": { "message": false, "name": "setup" @@ -130,7 +130,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b8d6b977", + "id": "2daf6661", "metadata": {}, "outputs": [], "source": [ @@ -140,7 +140,7 @@ }, { "cell_type": "markdown", - "id": "63c759e0", + "id": "14306116", "metadata": { "lines_to_next_cell": 0 }, @@ -151,7 +151,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f05defbd", + "id": "e2b95682", "metadata": {}, "outputs": [], "source": [ @@ -161,7 +161,7 @@ { "cell_type": "code", "execution_count": null, - "id": "144670ee", + "id": "369b0063", "metadata": {}, "outputs": [], "source": [ @@ -171,7 +171,7 @@ }, { "cell_type": "markdown", - "id": "6adfaabd", + "id": "9a2cecd6", "metadata": { "lines_to_next_cell": 0 }, @@ -184,7 +184,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ef44c15e", + "id": "255c9acd", "metadata": {}, "outputs": [], "source": [ @@ -202,7 +202,7 @@ }, { "cell_type": "markdown", - "id": "166700bc", + "id": "8a8ccecc", "metadata": { "lines_to_next_cell": 0 }, @@ -215,7 +215,7 @@ { "cell_type": "code", "execution_count": null, - "id": "32cc4dae", + "id": "5d2ed64e", "metadata": {}, "outputs": [], "source": [ @@ -250,7 +250,7 @@ }, { "cell_type": "markdown", - "id": "f42b4f11", + "id": "b70694de", "metadata": {}, "source": [ "There is some variability in the total number of counts in each field of view. It is not completely apparent what accounts for the low number of counts in some FOVs. For example, FOV 22 has the fewest number of cells, but comparably more counts are detected there than in regions with more cells (e.g. FOV 18). \n", @@ -261,7 +261,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7e33f7c5", + "id": "1e92fd15", "metadata": {}, "outputs": [], "source": [ @@ -280,7 +280,7 @@ }, { "cell_type": "markdown", - "id": "70aafdc9", + "id": "4ffcfe57", "metadata": { "lines_to_next_cell": 0 }, @@ -293,7 +293,7 @@ { "cell_type": "code", "execution_count": null, - "id": "db3750b3", + "id": "2db856bb", "metadata": {}, "outputs": [], "source": [ @@ -314,7 +314,7 @@ }, { "cell_type": "markdown", - "id": "546a8d93", + "id": "29b62f54", "metadata": {}, "source": [ "This plot mirrors the plot above for total counts. No single FOV stands out as an obvious outlier. \n", @@ -325,7 +325,7 @@ { "cell_type": "code", "execution_count": null, - "id": "142f131f", + "id": "a52452d5", "metadata": { "lines_to_next_cell": 0 }, @@ -352,7 +352,7 @@ }, { "cell_type": "markdown", - "id": "f8217ae2", + "id": "40eb15a0", "metadata": { "lines_to_next_cell": 0 }, @@ -365,7 +365,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2b55698c", + "id": "f580973f", "metadata": { "fig.height": 6, "fig.width": 9 @@ -385,7 +385,7 @@ }, { "cell_type": "markdown", - "id": "d1be14c1", + "id": "1706fbd9", "metadata": { "lines_to_next_cell": 0 }, @@ -396,7 +396,7 @@ { "cell_type": "code", "execution_count": null, - "id": "cce52707", + "id": "74f1bc6e", "metadata": { "lines_to_next_cell": 0 }, @@ -412,7 +412,7 @@ }, { "cell_type": "markdown", - "id": "56115944", + "id": "bc7abe6d", "metadata": { "lines_to_next_cell": 0 }, @@ -423,7 +423,7 @@ { "cell_type": "code", "execution_count": null, - "id": "54e99064", + "id": "b16e3cdb", "metadata": { "fig.height": 6, "fig.width": 9 @@ -444,7 +444,7 @@ }, { "cell_type": "markdown", - "id": "62f25216", + "id": "c7b6a654", "metadata": { "lines_to_next_cell": 0 }, @@ -462,7 +462,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b181b6d8", + "id": "7916df0d", "metadata": {}, "outputs": [], "source": [ @@ -472,7 +472,7 @@ }, { "cell_type": "markdown", - "id": "87e78eb3", + "id": "6bbd7ab6", "metadata": { "lines_to_next_cell": 0 }, @@ -483,7 +483,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c478d877", + "id": "a189ec24", "metadata": {}, "outputs": [], "source": [ @@ -493,7 +493,7 @@ }, { "cell_type": "markdown", - "id": "4845af4f", + "id": "1095c32b", "metadata": { "lines_to_next_cell": 0 }, @@ -504,7 +504,7 @@ { "cell_type": "code", "execution_count": null, - "id": "861e8f42", + "id": "f04e1335", "metadata": {}, "outputs": [], "source": [ @@ -513,7 +513,7 @@ }, { "cell_type": "markdown", - "id": "16ff1c14", + "id": "bf20d65e", "metadata": { "lines_to_next_cell": 0 }, @@ -527,7 +527,7 @@ { "cell_type": "code", "execution_count": null, - "id": "167e87a6", + "id": "735ac68b", "metadata": {}, "outputs": [], "source": [ @@ -544,7 +544,7 @@ }, { "cell_type": "markdown", - "id": "5dd8308d", + "id": "dde15823", "metadata": { "lines_to_next_cell": 0 }, @@ -555,7 +555,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d07e594b", + "id": "23e5194b", "metadata": { "fig.height": 5, "fig.width": 10 @@ -568,7 +568,7 @@ }, { "cell_type": "markdown", - "id": "2d9c7676", + "id": "182d509d", "metadata": {}, "source": [ "The authors have assigned cells to more types than are identified in the clustering step. In any case, the clustering results seem to recapitulate the major cell niches from the previous annotations. We can compute the [Rand index](https://en.wikipedia.org/wiki/Rand_index) using a function from the `fossil` package to assess the similarity between the two clustering results. A value of 1 would suggest the clustering results are identical, while a value of 0 would suggest that the results do not agree at all. " @@ -577,7 +577,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4f544e21", + "id": "e48656a6", "metadata": {}, "outputs": [], "source": [ @@ -589,7 +589,7 @@ }, { "cell_type": "markdown", - "id": "93f6d733", + "id": "1099bdf6", "metadata": {}, "source": [ "The relatively large Rand index suggests that cells are often found in the same cluster in both cases. \n", @@ -603,7 +603,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1e0cf428", + "id": "02c6309d", "metadata": {}, "outputs": [], "source": [ @@ -614,7 +614,7 @@ }, { "cell_type": "markdown", - "id": "d3de0a09", + "id": "1f673644", "metadata": { "lines_to_next_cell": 0 }, @@ -625,7 +625,7 @@ { "cell_type": "code", "execution_count": null, - "id": "138d59f3", + "id": "94242857", "metadata": {}, "outputs": [], "source": [ @@ -635,7 +635,7 @@ }, { "cell_type": "markdown", - "id": "d03e70e7", + "id": "abc8e646", "metadata": { "lines_to_next_cell": 0 }, @@ -646,7 +646,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8a9bcd07", + "id": "013fe36a", "metadata": {}, "outputs": [], "source": [ @@ -658,7 +658,7 @@ { "cell_type": "code", "execution_count": null, - "id": "edffbd68", + "id": "9d34261b", "metadata": {}, "outputs": [], "source": [ @@ -673,7 +673,7 @@ }, { "cell_type": "markdown", - "id": "f6abf515", + "id": "ec0e3ca3", "metadata": { "lines_to_next_cell": 0 }, @@ -684,7 +684,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a43746cd", + "id": "57e34a64", "metadata": {}, "outputs": [], "source": [ @@ -693,7 +693,7 @@ }, { "cell_type": "markdown", - "id": "6a1facbc", + "id": "3428704e", "metadata": { "lines_to_next_cell": 0 }, @@ -708,7 +708,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d2aa255b", + "id": "fcd8e81b", "metadata": { "fig.height": 8, "fig.width": 8 @@ -722,7 +722,7 @@ }, { "cell_type": "markdown", - "id": "dc706e45", + "id": "014657cc", "metadata": { "lines_to_next_cell": 0 }, @@ -739,7 +739,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9c031f0b", + "id": "5e28ae13", "metadata": {}, "outputs": [], "source": [ @@ -748,7 +748,7 @@ }, { "cell_type": "markdown", - "id": "3705bcb0", + "id": "df1a7383", "metadata": {}, "source": [ "# References" diff --git a/vignettes/vig8_codex.ipynb b/vignettes/vig8_codex.ipynb index ae75545b8..643ac1a00 100644 --- a/vignettes/vig8_codex.ipynb +++ b/vignettes/vig8_codex.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "raw", - "id": "c28b594a", + "id": "6ceee77b", "metadata": {}, "source": [ "---\n", @@ -26,7 +26,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d325b5d7", + "id": "4b1fa9a4", "metadata": { "tags": [ "remove_cell" @@ -44,7 +44,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4d958500", + "id": "3553a3fb", "metadata": { "eval": false, "tags": [ @@ -83,7 +83,7 @@ }, { "cell_type": "markdown", - "id": "61d2556c", + "id": "02c4017f", "metadata": {}, "source": [ "# Introduction" @@ -92,7 +92,7 @@ { "cell_type": "code", "execution_count": null, - "id": "33874450", + "id": "1aba671f", "metadata": { "lines_to_next_cell": 0, "name": "setup" @@ -123,7 +123,7 @@ }, { "cell_type": "markdown", - "id": "c4c57502", + "id": "2338b9e3", "metadata": { "lines_to_next_cell": 0 }, @@ -144,7 +144,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f92f98f8", + "id": "77a92b0f", "metadata": { "lines_to_next_cell": 0 }, @@ -158,7 +158,7 @@ }, { "cell_type": "markdown", - "id": "275df924", + "id": "0b33d280", "metadata": { "lines_to_next_cell": 0 }, @@ -171,7 +171,7 @@ { "cell_type": "code", "execution_count": null, - "id": "03173214", + "id": "7d5b87cc", "metadata": { "lines_to_next_cell": 0 }, @@ -183,7 +183,7 @@ }, { "cell_type": "markdown", - "id": "c7e972ce", + "id": "cbfe9c53", "metadata": {}, "source": [ "## Exploratory Data Analysis" @@ -192,7 +192,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9f3a58b5", + "id": "753c9d05", "metadata": { "lines_to_next_cell": 0 }, @@ -205,7 +205,7 @@ }, { "cell_type": "markdown", - "id": "64c92df4", + "id": "f589ddcc", "metadata": { "lines_to_next_cell": 0 }, @@ -218,7 +218,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3c070277", + "id": "3035dfbd", "metadata": { "lines_to_next_cell": 0 }, @@ -232,7 +232,7 @@ }, { "cell_type": "markdown", - "id": "89934ae2", + "id": "be776ea4", "metadata": { "lines_to_next_cell": 0 }, @@ -245,7 +245,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3b6d3545", + "id": "7c21de61", "metadata": { "lines_to_next_cell": 0 }, @@ -261,7 +261,7 @@ }, { "cell_type": "markdown", - "id": "05e15b7b", + "id": "b216b521", "metadata": {}, "source": [ "There appears to be a sigmoid relationship between the mean and variance of the protein expression. The pattern is reminiscent of what might be expected if the intensity values were derived from a Gamma distribution, the continuous analog of the Negative Binomial distribution that is typically used to describe count data from scRNA-seq experiments. This may have implications for how CODEX data is variance stabilized in the future. \n", @@ -272,7 +272,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8326cdbc", + "id": "b96c6432", "metadata": {}, "outputs": [], "source": [ @@ -284,7 +284,7 @@ }, { "cell_type": "markdown", - "id": "f01b772c", + "id": "5856886a", "metadata": { "lines_to_next_cell": 0 }, @@ -301,7 +301,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1f59df17", + "id": "d27c0158", "metadata": {}, "outputs": [], "source": [ @@ -312,7 +312,7 @@ }, { "cell_type": "markdown", - "id": "65c509e4", + "id": "8a517480", "metadata": { "lines_to_next_cell": 0 }, @@ -323,7 +323,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c4f2ca34", + "id": "9faa0b50", "metadata": { "lines_to_next_cell": 0 }, @@ -334,7 +334,7 @@ }, { "cell_type": "markdown", - "id": "d463c042", + "id": "43da2f4f", "metadata": { "lines_to_next_cell": 0 }, @@ -347,7 +347,7 @@ { "cell_type": "code", "execution_count": null, - "id": "33a18d2b", + "id": "24562947", "metadata": {}, "outputs": [], "source": [ @@ -363,7 +363,7 @@ }, { "cell_type": "markdown", - "id": "237df23c", + "id": "39416e43", "metadata": { "lines_to_next_cell": 0 }, @@ -374,7 +374,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ac4bde26", + "id": "5250bfbe", "metadata": { "lines_to_next_cell": 0 }, @@ -385,7 +385,7 @@ }, { "cell_type": "markdown", - "id": "1c679d65", + "id": "ce624c66", "metadata": { "lines_to_next_cell": 0 }, @@ -396,7 +396,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f6405352", + "id": "5a971857", "metadata": { "lines_to_next_cell": 0 }, @@ -413,7 +413,7 @@ }, { "cell_type": "markdown", - "id": "cf3f7f43", + "id": "94521aa4", "metadata": {}, "source": [ "The vertical line in each plot represents the observed Moran's I while the density represents the Moran's I statistic for each of the random permutations of the data. Each of these plots suggests that the Moran's I statistic is significant. We can plot the normalized intensity for these genes in space. " @@ -422,7 +422,7 @@ { "cell_type": "code", "execution_count": null, - "id": "bf4b3981", + "id": "3ef410e8", "metadata": { "fig.height": 7, "fig.width": 12, @@ -437,7 +437,7 @@ }, { "cell_type": "markdown", - "id": "14f1b303", + "id": "6901e3ae", "metadata": {}, "source": [ "While most of these genes appear to have some spatial distribution, it also seems that it may overlap with cell type. The cells that appear to express the genes of interest seem to be spatially restricted to known boundaries in the tissue. \n", @@ -448,7 +448,7 @@ { "cell_type": "code", "execution_count": null, - "id": "748d2124", + "id": "0f76e3c0", "metadata": {}, "outputs": [], "source": [ @@ -457,7 +457,7 @@ }, { "cell_type": "markdown", - "id": "86e5302c", + "id": "56539c84", "metadata": {}, "source": [ "# Differential Expression\n", @@ -470,7 +470,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5b1651fd", + "id": "ce49b9df", "metadata": {}, "outputs": [], "source": [ @@ -483,7 +483,7 @@ }, { "cell_type": "markdown", - "id": "f857e6d7", + "id": "e286be01", "metadata": { "lines_to_next_cell": 0 }, @@ -494,7 +494,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7a01dc14", + "id": "f28dd7c4", "metadata": {}, "outputs": [], "source": [ @@ -509,7 +509,7 @@ }, { "cell_type": "markdown", - "id": "0025df85", + "id": "e419db54", "metadata": { "lines_to_next_cell": 0 }, @@ -524,7 +524,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f2ee25f7", + "id": "4ccbd265", "metadata": {}, "outputs": [], "source": [ @@ -533,7 +533,7 @@ }, { "cell_type": "markdown", - "id": "fdb605ff", + "id": "a915c439", "metadata": {}, "source": [ "# References" diff --git a/vignettes/visium_10x.ipynb b/vignettes/visium_10x.ipynb index f27b0aeb4..bbadc91b2 100644 --- a/vignettes/visium_10x.ipynb +++ b/vignettes/visium_10x.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "raw", - "id": "920784bc", + "id": "c3e6198b", "metadata": {}, "source": [ "---\n", @@ -26,7 +26,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d605b0bb", + "id": "82a949fd", "metadata": { "tags": [ "remove_cell" @@ -43,7 +43,7 @@ { "cell_type": "code", "execution_count": null, - "id": "cafec978", + "id": "d45c816e", "metadata": { "eval": false, "tags": [ @@ -77,7 +77,7 @@ }, { "cell_type": "markdown", - "id": "79d93268", + "id": "5066e12c", "metadata": { "lines_to_next_cell": 0 }, @@ -96,7 +96,7 @@ { "cell_type": "code", "execution_count": null, - "id": "fcbcd224", + "id": "c5b578b1", "metadata": { "name": "setup" }, @@ -119,7 +119,7 @@ }, { "cell_type": "markdown", - "id": "e6d8bc75", + "id": "f2f8bec0", "metadata": { "lines_to_next_cell": 0 }, @@ -130,7 +130,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f91d1f70", + "id": "ba5467eb", "metadata": {}, "outputs": [], "source": [ @@ -141,7 +141,7 @@ }, { "cell_type": "markdown", - "id": "9a32211c", + "id": "c4c5ec6c", "metadata": { "lines_to_next_cell": 0 }, @@ -152,7 +152,7 @@ { "cell_type": "code", "execution_count": null, - "id": "02837f2a", + "id": "c9e4c971", "metadata": {}, "outputs": [], "source": [ @@ -163,7 +163,7 @@ }, { "cell_type": "markdown", - "id": "3fb38c5b", + "id": "d6c9f249", "metadata": { "lines_to_next_cell": 0 }, @@ -174,7 +174,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7f442895", + "id": "aa0468fd", "metadata": {}, "outputs": [], "source": [ @@ -187,7 +187,7 @@ }, { "cell_type": "markdown", - "id": "6d76c319", + "id": "25385a00", "metadata": { "lines_to_next_cell": 0 }, @@ -198,7 +198,7 @@ { "cell_type": "code", "execution_count": null, - "id": "117eff1a", + "id": "182b6cc6", "metadata": {}, "outputs": [], "source": [ @@ -207,7 +207,7 @@ }, { "cell_type": "markdown", - "id": "ef3f60a2", + "id": "1966c83d", "metadata": { "lines_to_next_cell": 0 }, @@ -218,7 +218,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ae9fd809", + "id": "a4e91e8d", "metadata": {}, "outputs": [], "source": [ @@ -227,7 +227,7 @@ }, { "cell_type": "markdown", - "id": "771555c9", + "id": "dc46db6d", "metadata": {}, "source": [ "In the spatial directory:" @@ -236,7 +236,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a70160a3", + "id": "eb12282c", "metadata": {}, "outputs": [], "source": [ @@ -245,7 +245,7 @@ }, { "cell_type": "markdown", - "id": "a03ac488", + "id": "1c6ff78b", "metadata": {}, "source": [ "The outputs in the spatial directory is explained [here on the 10X website](https://support.10xgenomics.com/spatial-gene-expression/software/pipelines/latest/output/spatial).\n", @@ -261,7 +261,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5651fd0f", + "id": "04db221f", "metadata": { "lines_to_next_cell": 0 }, @@ -272,7 +272,7 @@ }, { "cell_type": "markdown", - "id": "e113009f", + "id": "d71a38ca", "metadata": { "lines_to_next_cell": 0 }, @@ -285,7 +285,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a032b395", + "id": "620c5dd1", "metadata": {}, "outputs": [], "source": [ @@ -294,7 +294,7 @@ }, { "cell_type": "markdown", - "id": "33979412", + "id": "283a1129", "metadata": { "lines_to_next_cell": 0 }, @@ -305,7 +305,7 @@ { "cell_type": "code", "execution_count": null, - "id": "25960b4e", + "id": "709f43d0", "metadata": {}, "outputs": [], "source": [ @@ -314,7 +314,7 @@ }, { "cell_type": "markdown", - "id": "75a2cdd7", + "id": "38ddafb5", "metadata": { "lines_to_next_cell": 0 }, @@ -325,7 +325,7 @@ { "cell_type": "code", "execution_count": null, - "id": "70199998", + "id": "92d0010b", "metadata": {}, "outputs": [], "source": [ @@ -334,7 +334,7 @@ }, { "cell_type": "markdown", - "id": "fc5befbf", + "id": "21dc2916", "metadata": { "lines_to_next_cell": 0 }, @@ -345,7 +345,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6736e616", + "id": "b7bd5419", "metadata": {}, "outputs": [], "source": [ @@ -355,7 +355,7 @@ { "cell_type": "code", "execution_count": null, - "id": "29576f48", + "id": "1e65fa8c", "metadata": {}, "outputs": [], "source": [ @@ -365,7 +365,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5a203180", + "id": "4bf9a3ff", "metadata": { "lines_to_next_cell": 0 }, @@ -376,7 +376,7 @@ }, { "cell_type": "markdown", - "id": "fd221116", + "id": "fc90007b", "metadata": {}, "source": [ "The mouse olfactory bulb is conventionally plotted horizontally. The entire SFE object can be transposed in histologial space to make the olfactory bulb horizontal." @@ -385,7 +385,7 @@ { "cell_type": "code", "execution_count": null, - "id": "76d95d03", + "id": "3e17415f", "metadata": {}, "outputs": [], "source": [ @@ -395,7 +395,7 @@ { "cell_type": "code", "execution_count": null, - "id": "afa48931", + "id": "8bcf0583", "metadata": { "fig.height": 6, "fig.width": 8 @@ -408,7 +408,7 @@ }, { "cell_type": "markdown", - "id": "97c60977", + "id": "306fc6ae", "metadata": { "lines_to_next_cell": 0 }, @@ -419,7 +419,7 @@ { "cell_type": "code", "execution_count": null, - "id": "58e0591e", + "id": "689301a2", "metadata": {}, "outputs": [], "source": [ @@ -431,7 +431,7 @@ }, { "cell_type": "markdown", - "id": "1f631a43", + "id": "9cdc9534", "metadata": {}, "source": [ "3 peaks, apparently histologically relevant. Also no obvious outliers." @@ -440,7 +440,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ee34dcf2", + "id": "f9985651", "metadata": {}, "outputs": [], "source": [ @@ -450,7 +450,7 @@ }, { "cell_type": "markdown", - "id": "37ad3622", + "id": "34b947b2", "metadata": {}, "source": [ "This is unlike scRNA-seq data. Spots not in tissue have a wide range of mitocondrial percentage. Spots in tissue fall into 3 clusters in this plot, seemingly related to histological regions." @@ -459,7 +459,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d74ef671", + "id": "804389dd", "metadata": {}, "outputs": [], "source": [ @@ -469,7 +469,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d41a0e1d", + "id": "490f268c", "metadata": {}, "outputs": [], "source": [ @@ -479,7 +479,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c88e7e9a", + "id": "5d72ce7d", "metadata": {}, "outputs": [], "source": [ @@ -492,7 +492,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6df76904", + "id": "7419ee1f", "metadata": {}, "outputs": [], "source": [ @@ -502,7 +502,7 @@ }, { "cell_type": "markdown", - "id": "f4c5da3c", + "id": "659ae1f2", "metadata": { "lines_to_next_cell": 0 }, @@ -513,7 +513,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c51c6bd4", + "id": "17f183dd", "metadata": {}, "outputs": [], "source": [ @@ -524,7 +524,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e5a255df", + "id": "1fc092a0", "metadata": {}, "outputs": [], "source": [ @@ -534,7 +534,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4c6a67ed", + "id": "355beb43", "metadata": {}, "outputs": [], "source": [ @@ -544,7 +544,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4369c7ed", + "id": "6d2b5096", "metadata": {}, "outputs": [], "source": [ @@ -554,7 +554,7 @@ }, { "cell_type": "markdown", - "id": "ef55db7c", + "id": "9d017f4f", "metadata": { "lines_to_next_cell": 0 }, @@ -565,7 +565,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a4492fbd", + "id": "cf619a6d", "metadata": {}, "outputs": [], "source": [ @@ -581,7 +581,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4e1ce0f5", + "id": "53024b93", "metadata": { "fig.height": 9, "fig.width": 9 @@ -594,7 +594,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e17f791d", + "id": "6b2c6bc9", "metadata": {}, "outputs": [], "source": [ @@ -605,7 +605,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e6f4cebe", + "id": "7b3aec80", "metadata": { "fig.height": 8, "fig.width": 8 @@ -621,7 +621,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d7d3f1d5", + "id": "b7435785", "metadata": {}, "outputs": [], "source": [ @@ -631,7 +631,7 @@ }, { "cell_type": "markdown", - "id": "99f44101", + "id": "a85b7499", "metadata": { "lines_to_next_cell": 0 }, @@ -642,7 +642,7 @@ { "cell_type": "code", "execution_count": null, - "id": "cad16f9f", + "id": "83580797", "metadata": {}, "outputs": [], "source": [ @@ -653,7 +653,7 @@ }, { "cell_type": "markdown", - "id": "cb719496", + "id": "8acd7691", "metadata": { "lines_to_next_cell": 0 }, @@ -664,7 +664,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f2b77ac6", + "id": "dd9ea6fc", "metadata": { "fig.height": 8, "fig.width": 8 @@ -677,7 +677,7 @@ }, { "cell_type": "markdown", - "id": "a490f33b", + "id": "7223927e", "metadata": { "lines_to_next_cell": 0 }, @@ -690,7 +690,7 @@ { "cell_type": "code", "execution_count": null, - "id": "22467cc9", + "id": "12389e23", "metadata": {}, "outputs": [], "source": [ diff --git a/vignettes/visium_10x_spatial.ipynb b/vignettes/visium_10x_spatial.ipynb index e71b729a5..6f7b76982 100644 --- a/vignettes/visium_10x_spatial.ipynb +++ b/vignettes/visium_10x_spatial.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "raw", - "id": "3eaf5bfa", + "id": "c809c36c", "metadata": {}, "source": [ "---\n", @@ -26,7 +26,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ab1f5d79", + "id": "6bc8b90d", "metadata": { "tags": [ "remove_cell" @@ -43,7 +43,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f16a6905", + "id": "65db638e", "metadata": { "eval": false, "tags": [ @@ -84,7 +84,7 @@ }, { "cell_type": "markdown", - "id": "22981371", + "id": "3595a447", "metadata": { "lines_to_next_cell": 0 }, @@ -98,7 +98,7 @@ { "cell_type": "code", "execution_count": null, - "id": "15415f8a", + "id": "a13020be", "metadata": {}, "outputs": [], "source": [ @@ -128,7 +128,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7df5440b", + "id": "402363d6", "metadata": {}, "outputs": [], "source": [ @@ -141,7 +141,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7aaad902", + "id": "1192447e", "metadata": { "eval": false, "tags": [ @@ -156,7 +156,7 @@ { "cell_type": "code", "execution_count": null, - "id": "36e7fcf3", + "id": "86cbc2a1", "metadata": {}, "outputs": [], "source": [ @@ -165,7 +165,7 @@ }, { "cell_type": "markdown", - "id": "4ec78b06", + "id": "000afc4a", "metadata": { "lines_to_next_cell": 0 }, @@ -176,7 +176,7 @@ { "cell_type": "code", "execution_count": null, - "id": "854cf035", + "id": "43b9414d", "metadata": {}, "outputs": [], "source": [ @@ -187,7 +187,7 @@ }, { "cell_type": "markdown", - "id": "f0c71116", + "id": "6292c23d", "metadata": { "lines_to_next_cell": 0 }, @@ -198,7 +198,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2a7fb248", + "id": "86c5ca23", "metadata": {}, "outputs": [], "source": [ @@ -209,7 +209,7 @@ }, { "cell_type": "markdown", - "id": "edb20246", + "id": "d802b9fc", "metadata": { "lines_to_next_cell": 0 }, @@ -220,7 +220,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e8ee815c", + "id": "294c76bb", "metadata": {}, "outputs": [], "source": [ @@ -233,7 +233,7 @@ }, { "cell_type": "markdown", - "id": "8b29aa65", + "id": "fee6ca80", "metadata": { "lines_to_next_cell": 0 }, @@ -246,7 +246,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6facdc4b", + "id": "20c0092c", "metadata": {}, "outputs": [], "source": [ @@ -255,7 +255,7 @@ }, { "cell_type": "markdown", - "id": "b62c4226", + "id": "12ec5b0b", "metadata": {}, "source": [ "Here we add QC metrics, already plotted in the introductory vignette." @@ -264,7 +264,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9d35a3f3", + "id": "f28233d8", "metadata": {}, "outputs": [], "source": [ @@ -274,7 +274,7 @@ { "cell_type": "code", "execution_count": null, - "id": "cb6512cf", + "id": "b3219fbc", "metadata": {}, "outputs": [], "source": [ @@ -283,7 +283,7 @@ }, { "cell_type": "markdown", - "id": "abe22c44", + "id": "7e4f585a", "metadata": {}, "source": [ "# Tissue segmentation\n", @@ -297,7 +297,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ab258a6f", + "id": "a887a59e", "metadata": {}, "outputs": [], "source": [ @@ -307,7 +307,7 @@ }, { "cell_type": "markdown", - "id": "15b2aaba", + "id": "fb5a3f69", "metadata": { "lines_to_next_cell": 0 }, @@ -320,7 +320,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6789f9c2", + "id": "9529f47d", "metadata": {}, "outputs": [], "source": [ @@ -332,7 +332,7 @@ { "cell_type": "code", "execution_count": null, - "id": "addd74ec", + "id": "a90fd617", "metadata": {}, "outputs": [], "source": [ @@ -341,7 +341,7 @@ }, { "cell_type": "markdown", - "id": "3fffe9a7", + "id": "0378ab89", "metadata": {}, "source": [ "The tissue can be discerned with thresholding. The tall peak on the right is the background. The much lower peaks from around 0.6 to 0.85 must be the tissue. To capture the faint bluish region, the blue channel is used for thresholding. The threshold here is chosen based on the histogram and experimenting with nearby values." @@ -350,7 +350,7 @@ { "cell_type": "code", "execution_count": null, - "id": "bf0fe575", + "id": "f5a6506f", "metadata": {}, "outputs": [], "source": [ @@ -360,7 +360,7 @@ }, { "cell_type": "markdown", - "id": "abef175f", + "id": "bcbbb905", "metadata": { "lines_to_next_cell": 0 }, @@ -371,7 +371,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b57e1593", + "id": "86e3c171", "metadata": {}, "outputs": [], "source": [ @@ -382,7 +382,7 @@ }, { "cell_type": "markdown", - "id": "c8352cdc", + "id": "6256fa1d", "metadata": { "lines_to_next_cell": 0 }, @@ -393,7 +393,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c7c9ad60", + "id": "6b286133", "metadata": {}, "outputs": [], "source": [ @@ -403,7 +403,7 @@ }, { "cell_type": "markdown", - "id": "0a8b8075", + "id": "a500d984", "metadata": {}, "source": [ "There are some larger holes in the tissue mask, which may be real holes or faint regions with few nuclei missed by thresholding. They might not be large enough to affect which Visium spots intersect the tissue.\n", @@ -414,7 +414,7 @@ { "cell_type": "code", "execution_count": null, - "id": "fee5032f", + "id": "999d6b05", "metadata": {}, "outputs": [], "source": [ @@ -425,7 +425,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2a51301f", + "id": "0bc98053", "metadata": {}, "outputs": [], "source": [ @@ -435,7 +435,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f8b24008", + "id": "8f52fee7", "metadata": {}, "outputs": [], "source": [ @@ -445,7 +445,7 @@ { "cell_type": "code", "execution_count": null, - "id": "23bb3bb4", + "id": "470c6f7b", "metadata": {}, "outputs": [], "source": [ @@ -457,7 +457,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1a266ab2", + "id": "aec9c39c", "metadata": {}, "outputs": [], "source": [ @@ -470,7 +470,7 @@ }, { "cell_type": "markdown", - "id": "60b50de4", + "id": "d7d09bb2", "metadata": { "lines_to_next_cell": 0 }, @@ -481,7 +481,7 @@ { "cell_type": "code", "execution_count": null, - "id": "03f02b32", + "id": "ca738091", "metadata": {}, "outputs": [], "source": [ @@ -491,7 +491,7 @@ { "cell_type": "code", "execution_count": null, - "id": "907facef", + "id": "a6aa9cb7", "metadata": {}, "outputs": [], "source": [ @@ -502,7 +502,7 @@ { "cell_type": "code", "execution_count": null, - "id": "52dea998", + "id": "6614a4d3", "metadata": {}, "outputs": [], "source": [ @@ -512,7 +512,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c5c2995a", + "id": "b24c524c", "metadata": {}, "outputs": [], "source": [ @@ -521,7 +521,7 @@ }, { "cell_type": "markdown", - "id": "df92f613", + "id": "e3dc21e9", "metadata": {}, "source": [ "Object number 797 is a piece of debris at the bottom left. The other pieces with area over 100 pixels are tissue. Since debris really is small bits of tissue, so the boundary between debris and tissue can be blurry. Here the two are distinguished by morphology on the H&E image and proximity to the main tissue." @@ -530,7 +530,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d44f4e18", + "id": "fafa56d4", "metadata": {}, "outputs": [], "source": [ @@ -539,7 +539,7 @@ }, { "cell_type": "markdown", - "id": "244c84dc", + "id": "2f2ed2ff", "metadata": { "lines_to_next_cell": 0 }, @@ -550,7 +550,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7d429883", + "id": "908433e7", "metadata": {}, "outputs": [], "source": [ @@ -559,7 +559,7 @@ }, { "cell_type": "markdown", - "id": "a1996347", + "id": "19b48a14", "metadata": { "lines_to_next_cell": 0 }, @@ -570,7 +570,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8b9e816d", + "id": "e91b8d45", "metadata": {}, "outputs": [], "source": [ @@ -580,7 +580,7 @@ { "cell_type": "code", "execution_count": null, - "id": "63bca35f", + "id": "cc6f7147", "metadata": {}, "outputs": [], "source": [ @@ -589,7 +589,7 @@ }, { "cell_type": "markdown", - "id": "cc14f09b", + "id": "316b7d9e", "metadata": {}, "source": [ "This segmentation process took a lot of manual oversight, in choosing the threshold, choosing kernel size and shape in the opening and closing operations, deciding whether to fill the holes, and deciding what is debris and what is tissue. \n", @@ -601,7 +601,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5d827743", + "id": "88e4f835", "metadata": {}, "outputs": [], "source": [ @@ -619,7 +619,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8da22742", + "id": "1d2e46f0", "metadata": {}, "outputs": [], "source": [ @@ -628,7 +628,7 @@ }, { "cell_type": "markdown", - "id": "9cbafc69", + "id": "72ea374a", "metadata": { "lines_to_next_cell": 0 }, @@ -639,7 +639,7 @@ { "cell_type": "code", "execution_count": null, - "id": "351eca42", + "id": "e31a5ca8", "metadata": {}, "outputs": [], "source": [ @@ -649,7 +649,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7fb77534", + "id": "faed86dc", "metadata": {}, "outputs": [], "source": [ @@ -659,7 +659,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5e98f253", + "id": "2b027dc6", "metadata": {}, "outputs": [], "source": [ @@ -669,7 +669,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0c456ad2", + "id": "a39454e5", "metadata": {}, "outputs": [], "source": [ @@ -681,7 +681,7 @@ }, { "cell_type": "markdown", - "id": "0e73170b", + "id": "2644619e", "metadata": {}, "source": [ "The mouse olfactory bulb is conventionally plotted horizontally. The entire SFE object can be transposed in histologial space to make the olfactory bulb horizontal." @@ -690,7 +690,7 @@ { "cell_type": "code", "execution_count": null, - "id": "94a30a31", + "id": "39fd1870", "metadata": {}, "outputs": [], "source": [ @@ -700,7 +700,7 @@ { "cell_type": "code", "execution_count": null, - "id": "507952b1", + "id": "91d30ddf", "metadata": {}, "outputs": [], "source": [ @@ -711,7 +711,7 @@ }, { "cell_type": "markdown", - "id": "35cf5d47", + "id": "ada5a58f", "metadata": {}, "source": [ "Then we can use geometric operations to find which spots intersect tissue, which spots are covered by tissue, and how much of each spot intersects tissue." @@ -720,7 +720,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4d862b81", + "id": "aa1220dc", "metadata": {}, "outputs": [], "source": [ @@ -735,7 +735,7 @@ }, { "cell_type": "markdown", - "id": "c223091c", + "id": "509b5b35", "metadata": { "lines_to_next_cell": 0 }, @@ -746,7 +746,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7301d020", + "id": "0650cb74", "metadata": {}, "outputs": [], "source": [ @@ -762,7 +762,7 @@ }, { "cell_type": "markdown", - "id": "5e8a68a7", + "id": "dc5af2ed", "metadata": { "lines_to_next_cell": 0 }, @@ -773,7 +773,7 @@ { "cell_type": "code", "execution_count": null, - "id": "16a2ad8f", + "id": "3e0b1803", "metadata": {}, "outputs": [], "source": [ @@ -785,7 +785,7 @@ }, { "cell_type": "markdown", - "id": "45e051cf", + "id": "9a23db0f", "metadata": {}, "source": [ "We can also get the geometries of the intersections between the tissue and the Visium spots, and then calculate what percentage of each spot is in tissue. However, this percentage may not be very useful if the tissue segmentation is subject to error. This percentage may be more useful for pathologist annotated histological regions or objects such as nuclei and myofibers." @@ -794,7 +794,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c28d968a", + "id": "c1d67821", "metadata": {}, "outputs": [], "source": [ @@ -805,7 +805,7 @@ }, { "cell_type": "markdown", - "id": "d29204ee", + "id": "daddd609", "metadata": { "lines_to_next_cell": 0 }, @@ -816,7 +816,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d49bd293", + "id": "57cb38ee", "metadata": {}, "outputs": [], "source": [ @@ -826,7 +826,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e1a2fa84", + "id": "a2b6088a", "metadata": {}, "outputs": [], "source": [ @@ -836,7 +836,7 @@ }, { "cell_type": "markdown", - "id": "e2ed3458", + "id": "d232e3c2", "metadata": { "lines_to_next_cell": 0 }, @@ -849,7 +849,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9849cf7b", + "id": "23b5d7d2", "metadata": {}, "outputs": [], "source": [ @@ -859,7 +859,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f5e41175", + "id": "4dc06e30", "metadata": {}, "outputs": [], "source": [ @@ -869,7 +869,7 @@ { "cell_type": "code", "execution_count": null, - "id": "543f78c4", + "id": "d435a289", "metadata": {}, "outputs": [], "source": [ @@ -879,7 +879,7 @@ { "cell_type": "code", "execution_count": null, - "id": "724822eb", + "id": "71faad05", "metadata": {}, "outputs": [], "source": [ @@ -889,7 +889,7 @@ { "cell_type": "code", "execution_count": null, - "id": "be731057", + "id": "a21cef79", "metadata": {}, "outputs": [], "source": [ @@ -900,7 +900,7 @@ { "cell_type": "code", "execution_count": null, - "id": "967928e8", + "id": "b94b8797", "metadata": {}, "outputs": [], "source": [ @@ -910,7 +910,7 @@ { "cell_type": "code", "execution_count": null, - "id": "240e660a", + "id": "6d00fdd1", "metadata": {}, "outputs": [], "source": [ @@ -920,7 +920,7 @@ { "cell_type": "code", "execution_count": null, - "id": "78dacb5b", + "id": "6ca62cb0", "metadata": { "fig.height": 6, "fig.width": 8 @@ -935,7 +935,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d1a9cf40", + "id": "b846dcb6", "metadata": {}, "outputs": [], "source": [ @@ -945,7 +945,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3972f67e", + "id": "526484ba", "metadata": { "fig.height": 6, "fig.width": 8 @@ -959,7 +959,7 @@ { "cell_type": "code", "execution_count": null, - "id": "be677138", + "id": "45ff265e", "metadata": {}, "outputs": [], "source": [ @@ -969,7 +969,7 @@ { "cell_type": "code", "execution_count": null, - "id": "51777d39", + "id": "ee16af2b", "metadata": {}, "outputs": [], "source": [ @@ -978,7 +978,7 @@ }, { "cell_type": "markdown", - "id": "36124973", + "id": "217676d7", "metadata": { "lines_to_next_cell": 0 }, @@ -991,7 +991,7 @@ { "cell_type": "code", "execution_count": null, - "id": "405610f0", + "id": "990df70a", "metadata": {}, "outputs": [], "source": [ @@ -1004,7 +1004,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f68a2b6c", + "id": "29367611", "metadata": {}, "outputs": [], "source": [ @@ -1014,7 +1014,7 @@ }, { "cell_type": "markdown", - "id": "b2f90a50", + "id": "607925d2", "metadata": { "lines_to_next_cell": 0 }, @@ -1025,7 +1025,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e427aa83", + "id": "63266e5b", "metadata": {}, "outputs": [], "source": [ @@ -1035,7 +1035,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3b8b84a1", + "id": "621a28f3", "metadata": {}, "outputs": [], "source": [ @@ -1044,7 +1044,7 @@ }, { "cell_type": "markdown", - "id": "1c19ecf7", + "id": "4b4916f3", "metadata": { "lines_to_next_cell": 0 }, @@ -1055,7 +1055,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c7fd627c", + "id": "01c75af9", "metadata": {}, "outputs": [], "source": [ @@ -1065,7 +1065,7 @@ }, { "cell_type": "markdown", - "id": "93d90cd8", + "id": "931c4be7", "metadata": { "lines_to_next_cell": 0 }, @@ -1076,7 +1076,7 @@ { "cell_type": "code", "execution_count": null, - "id": "01c075a8", + "id": "8b7025bc", "metadata": {}, "outputs": [], "source": [ @@ -1088,7 +1088,7 @@ }, { "cell_type": "markdown", - "id": "0898e26d", + "id": "0a646460", "metadata": { "lines_to_next_cell": 0 }, @@ -1099,7 +1099,7 @@ { "cell_type": "code", "execution_count": null, - "id": "afcd88ec", + "id": "56a5d110", "metadata": { "fig.height": 5, "fig.width": 9 @@ -1112,7 +1112,7 @@ }, { "cell_type": "markdown", - "id": "f7c147b6", + "id": "19601b19", "metadata": { "lines_to_next_cell": 0 }, @@ -1125,7 +1125,7 @@ { "cell_type": "code", "execution_count": null, - "id": "65bd4d06", + "id": "ce598007", "metadata": {}, "outputs": [], "source": [ @@ -1136,7 +1136,7 @@ { "cell_type": "code", "execution_count": null, - "id": "47ece42b", + "id": "f6d06e12", "metadata": {}, "outputs": [], "source": [ @@ -1150,7 +1150,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0577f915", + "id": "199ed0ad", "metadata": { "fig.height": 5, "fig.width": 9 @@ -1164,7 +1164,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ffb1c173", + "id": "24495382", "metadata": {}, "outputs": [], "source": [ @@ -1175,7 +1175,7 @@ { "cell_type": "code", "execution_count": null, - "id": "22abfd44", + "id": "3d265150", "metadata": {}, "outputs": [], "source": [ @@ -1185,7 +1185,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1eb1c38b", + "id": "849e0b3e", "metadata": {}, "outputs": [], "source": [ @@ -1194,7 +1194,7 @@ }, { "cell_type": "markdown", - "id": "4c7b0037", + "id": "fd197f50", "metadata": {}, "source": [ "As there are 2000 highly variable genes and 2000 tests, these would no longer be significant after correcting for multiple testing. \n", @@ -1205,7 +1205,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3d1b9f14", + "id": "a2dfb5f0", "metadata": {}, "outputs": [], "source": [ @@ -1216,7 +1216,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0ffcc7d8", + "id": "16e4b355", "metadata": {}, "outputs": [], "source": [ @@ -1228,7 +1228,7 @@ }, { "cell_type": "markdown", - "id": "1c570f05", + "id": "cda9f849", "metadata": { "lines_to_next_cell": 0 }, @@ -1242,7 +1242,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7c54e143", + "id": "68ea7644", "metadata": {}, "outputs": [], "source": [ @@ -1253,7 +1253,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d487d97a", + "id": "5eb59a72", "metadata": {}, "outputs": [], "source": [ @@ -1280,7 +1280,7 @@ { "cell_type": "code", "execution_count": null, - "id": "262fc410", + "id": "7261f059", "metadata": {}, "outputs": [], "source": [ @@ -1290,7 +1290,7 @@ { "cell_type": "code", "execution_count": null, - "id": "87f35360", + "id": "98f66add", "metadata": {}, "outputs": [], "source": [ @@ -1300,7 +1300,7 @@ }, { "cell_type": "markdown", - "id": "06bb55f5", + "id": "ec135078", "metadata": { "lines_to_next_cell": 0 }, @@ -1313,7 +1313,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6a93cd4a", + "id": "150f860d", "metadata": {}, "outputs": [], "source": [ @@ -1324,7 +1324,7 @@ { "cell_type": "code", "execution_count": null, - "id": "79dea44b", + "id": "6fea2586", "metadata": {}, "outputs": [], "source": [ @@ -1338,7 +1338,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d1f140bf", + "id": "c54de0e5", "metadata": { "fig.height": 6, "fig.width": 9 @@ -1351,7 +1351,7 @@ }, { "cell_type": "markdown", - "id": "1a2ff22c", + "id": "6a30d627", "metadata": {}, "source": [ "Although this Moran's I was not computed in histological space, these genes with the highest Moran's I in PCA space also show spatial structure, as different cell types reside in different spatial regions.\n", @@ -1362,7 +1362,7 @@ { "cell_type": "code", "execution_count": null, - "id": "31afd220", + "id": "3428f151", "metadata": { "lines_to_next_cell": 0 }, @@ -1373,7 +1373,7 @@ }, { "cell_type": "markdown", - "id": "ea9b29ec", + "id": "332824a7", "metadata": {}, "source": [] }