ISCHIA
Framework for analysis of cell-types and Ligand-Receptor cooccurrences
Install / Use
/learn @ati-lz/ISCHIAREADME
<!-- README.md is generated from README.Rmd. Please edit that file -->
ISCHIA
<!-- badges: start --> <!-- badges: end -->ISCHIA is a framework for analysis of cell-types and Ligand-Receptor cooccurrences in spatial transcriptomics/proteomics data
Installation
You can install the development version of ISCHIA from GitHub with:
# install.packages("devtools")
devtools::install_github("ati-lz/ISCHIA")
Example
Here we present an example analysis of Visium IBD samples as presented in the manuscript
# Loading required packages
library(ISCHIA)
library(robustbase)
library(data.table)
library(ggplot2)
library(Seurat)
library(dplyr)
## You can download the example dataset from Zenodo repository,[10.5281/zenodo.7589581] IBD_Visium_SeuratObj.RData
# here we will subset the dataset to only one sample
load(url("https://zenodo.org/record/7636442/files/IBD_visium_SeuratObj_small.RData?download=1"))
IBD.visium.P4
#> An object of class Seurat
#> 55545 features across 2185 samples within 3 assays
#> Active assay: SCT (18910 features, 12000 variable features)
#> 2 other assays present: Spatial, predictions
#> 2 dimensional reductions calculated: pca, umap
#> 1 image present: P4.noninf
# Extracting the deconvoluted cell type probability matrix from metadata
deconv.mat <- as.matrix(IBD.visium.P4@meta.data[,9:28])
colnames(deconv.mat) <- sapply(colnames(deconv.mat), function(x) unlist(strsplit(x, split = "_"))[2])
head(deconv.mat)
#> B CD4.T CD8..T DC
#> P4.noninf_AAACAAGTATCTCCCA-1 1.108271e-01 0.0362490681 6.290875e-02 0.000000000
#> P4.noninf_AAACACCAATAACTGC-1 9.073125e-18 0.0002448368 5.678951e-02 0.002088078
#> P4.noninf_AAACAGAGCGACTCCT-1 1.829942e-01 0.1402780551 2.331465e-01 0.010488728
#> P4.noninf_AAACAGCTTTCAGAAG-1 1.621216e-01 0.0352554936 5.044957e-02 0.000000000
#> P4.noninf_AAACAGGGTCTATATT-1 3.582042e-02 0.0209850943 3.002905e-02 0.000000000
#> P4.noninf_AAACCACTACACAGAT-1 2.507848e-02 0.0000000000 2.366519e-17 0.000000000
#> Endothelial Enterocytes Fibroblasts Goblet
#> P4.noninf_AAACAAGTATCTCCCA-1 0.004099481 0.046614486 0.006422975 0.08758596
#> P4.noninf_AAACACCAATAACTGC-1 0.017366582 0.045454252 0.011204734 0.01505300
#> P4.noninf_AAACAGAGCGACTCCT-1 0.066871597 0.000000000 0.019993125 0.00414359
#> P4.noninf_AAACAGCTTTCAGAAG-1 0.023326680 0.000000000 0.021278051 0.09004006
#> P4.noninf_AAACAGGGTCTATATT-1 0.153044498 0.005291094 0.022228189 0.04005296
#> P4.noninf_AAACCACTACACAGAT-1 0.030983112 0.000000000 0.079750813 0.15073662
#> ILCs Inflammatory.Fibroblasts Macrophages
#> P4.noninf_AAACAAGTATCTCCCA-1 0.000000000 0.009060087 0.00000000
#> P4.noninf_AAACACCAATAACTGC-1 0.013246080 0.021456711 0.32066116
#> P4.noninf_AAACAGAGCGACTCCT-1 0.030934220 0.035149799 0.07700440
#> P4.noninf_AAACAGCTTTCAGAAG-1 0.005617524 0.098616402 0.05451802
#> P4.noninf_AAACAGGGTCTATATT-1 0.025515429 0.114602744 0.09867344
#> P4.noninf_AAACCACTACACAGAT-1 0.008695323 0.019398533 0.03754245
#> Mast Mcells Monocytes Neutrophils
#> P4.noninf_AAACAAGTATCTCCCA-1 2.528502e-02 6.898513e-03 0.051761842 0.04649214
#> P4.noninf_AAACACCAATAACTGC-1 1.543687e-17 1.234458e-03 0.009640913 0.05838494
#> P4.noninf_AAACAGAGCGACTCCT-1 2.227816e-02 1.461596e-03 0.017412413 0.02549091
#> P4.noninf_AAACAGCTTTCAGAAG-1 5.593614e-18 6.384781e-05 0.033565754 0.03329163
#> P4.noninf_AAACAGGGTCTATATT-1 4.437177e-02 7.575785e-03 0.048926182 0.11569575
#> P4.noninf_AAACCACTACACAGAT-1 4.090900e-03 9.435438e-20 0.023606947 0.09512971
#> NK Plasma TA Tregs Tuft
#> P4.noninf_AAACAAGTATCTCCCA-1 0 0.03629586 0.46949870 0.00000000 0.000000000
#> P4.noninf_AAACACCAATAACTGC-1 0 0.06631910 0.26288117 0.04539367 0.052580802
#> P4.noninf_AAACAGAGCGACTCCT-1 0 0.00000000 0.01157489 0.12077778 0.000000000
#> P4.noninf_AAACAGCTTTCAGAAG-1 0 0.02627739 0.36557794 0.00000000 0.000000000
#> P4.noninf_AAACAGGGTCTATATT-1 0 0.03422890 0.19499771 0.00000000 0.007960981
#> P4.noninf_AAACCACTACACAGAT-1 0 0.02713631 0.37750862 0.12034218 0.000000000
Celltype Composition clustering
# Deciding about the k
Composition.cluster.k(deconv.mat, 20)
<img src="man/figures/README-Composition_clustering-1.png" width="100%" />
# Composition clustering of the deconvoluted spatial spots
IBD.visium.P4 <- Composition.cluster(IBD.visium.P4, deconv.mat, 8)
#not good...Idents(IBD.visium.P4) <- "CompositionCluster_CC"
table(IBD.visium.P4$CompositionCluster_CC)
#>
#> CC1 CC2 CC3 CC4 CC5 CC6 CC7 CC8
#> 302 296 274 382 108 238 426 159
SpatialDimPlot(IBD.visium.P4, group.by = c("CompositionCluster_CC")) + scale_fill_manual(values = c("cyan", "orange", "purple","green","yellow","blue", "red","black"))
#> Scale for fill is already present.
#> Adding another scale for fill, which will replace the existing scale.
<img src="man/figures/README-Composition_clustering-2.png" width="100%" />
We can check the leading cell types of each CC
Composition_cluster_enrichedCelltypes(IBD.visium.P4,"CC4", deconv.mat)
<img src="man/figures/README-Celltype_enrichment-1.png" width="100%" />
Composition_cluster_enrichedCelltypes(IBD.visium.P4,"CC7", deconv.mat)
<img src="man/figures/README-Celltype_enrichment-2.png" width="100%" />
We can explore the UMAP representation of the spot based on their
deconvoluted cell type composition
IBD.visium.P4.umap <- Composition_cluster_umap(IBD.visium.P4, deconv.mat)
#> Plotting scatterpies for 2185 pixels with 20 cell-types...this could take a while if the dataset is large.
IBD.visium.P4.umap$umap.cluster.gg
<img src="man/figures/README-umap-1.png" width="100%" />
IBD.visium.P4.umap$umap.deconv.gg
<img src="man/figures/README-umap-2.png" width="100%" />
Celltype Cooccurrence analysis
We choose CC4 and CC7 to check the celltype cooccurrences
CC4.celltype.cooccur <- spatial.celltype.cooccurence(spatial.object=IBD.visium.P4,
deconv.prob.mat=deconv.mat,
COI="CC4", prob.th= 0.05, Condition=unique(IBD.visium.P4$orig.ident))
#> | | | 0% | |= | 1% | |= | 2% | |== | 2% | |== | 3% | |=== | 4% | |=== | 5% | |==== | 5% | |==== | 6% | |===== | 7% | |===== | 8% | |====== | 8% | |====== | 9% | |======= | 10% | |======== | 11% | |======== | 12% | |========= | 12% | |========= | 13% | |========== | 14% | |========== | 15% | |=========== | 15% | |=========== | 16% |
