library(Seurat)
## Attaching SeuratObject
library(SpaTrio)
library(ggsci)
library(ggplot2)
library(readr)
library(reshape2)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
We collected single-cell multi-omics data and spatial transcriptome data of human steatosis liver. Datasets were obtained from Liver Cell Atlas.
spatial_object <- readRDS("data/Human_steatosis_liver/spatial_object.rds")
multi_object <- readRDS("data/Human_steatosis_liver/multi_object.rds")
dim(multi_object)
## [1] 32738 5393
dim(spatial_object)
## [1] 32738 1248
UMAP projection of input single-cell multi-omics data colored by the RNA annotation.
multi_object$cell_type=factor(multi_object$cell_type,levels = c("Hepatocytes","Fibroblasts","Endothelial cells","Macrophages","Cholangiocytes"))
Idents(multi_object)<-multi_object$my_type2
color<-c("#E8D7A9","#DC863B","#3B9AB1","#AD90AC","#81A88D")
DimPlot(multi_object)+scale_color_manual(values = color)
Spatial plot of input ST data colored by liver zonations.
Idents(spatial_object)<-spatial_object$zonationGroup
Idents(spatial_object)=factor(Idents(spatial_object),levels = c("Central","Mid","Periportal","Portal"))
sdplot(spatial_object,pt.size = 2,stroke = 0.2,image.alpha = 1)
We enter the following data into SpaTrio, which will build spatial maps of single cells
- Gene expression count matrix of cells and spots (multi_rna.csv & spatial_rna.csv)
- Cluster/Cell-type information of cells and spots (multi_meta.csv & spatial_meta.csv)
- Low-dimensional representation of protein assay (emb.csv)
- Spatial position coordinates of spots (pos.csv)
spatrio(spatrio_path="/home/yph/SpaTrio-main",
py_path="/home/yph/anaconda3/envs/spatrio/bin/python",
input_path="data/Human_steatosis_liver",
output_path="data/Human_steatosis_liver",
top_num =3)
## [1] "Using the Python interpreter with a path of /home/yph/anaconda3/envs/spatrio/bin/python"
Read in output and create single-cell spatial multi-omics data reconstructed by SpaTrio.
output <- read_csv("data/Human_steatosis_liver/output.csv")
## New names:
## Rows: 3744 Columns: 10
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (4): spot, cell, spot_type, cell_type dbl (6): ...1, value, x, y, Cell_xcoord,
## Cell_ycoord
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `` -> `...1`
pred<-subset(multi_object,cell=output$cell)
coordinate = output[,c("Cell_xcoord","Cell_ycoord")]
coordinate<-as.data.frame(coordinate)
colnames(coordinate)<-c("x","y")
rownames(coordinate)<-output$cell
pred@images[["slice1"]]=NULL
pred@images$image = new(
Class = 'SlideSeq',
assay = "RNA",
key = "image_",
coordinates = coordinate)
output<-as.data.frame(output)
rownames(output)<-output$cell
pred<-AddMetaData(pred, output[,2:10])
Spatial plot of single-cell spatial multi-omics data reconstructed by SpaTrio.
pred$cell_type=factor(multi_object$cell_type,levels = c("Hepatocytes","Fibroblasts","Endothelial cells","Macrophages","Cholangiocytes"))
Idents(pred)<-pred$cell_type
color<-c("#E8D7A9","#DC863B","#3B9AB1","#AD90AC","#81A88D")
sdplot(pred,pt.size = 4,stroke = 0.2)+scale_fill_manual(values = color)
## Scale for fill is already present.
## Adding another scale for fill, which will replace the existing scale.
Heatmap of scaled Pearson correlation coefficient between the gene expression of cell markers and the percent for each cell type.
library(psych)
##
## Attaching package: 'psych'
## The following objects are masked from 'package:ggplot2':
##
## %+%, alpha
library(pheatmap)
library(ggplot2)
exp<-as.data.frame(spatial_object@assays$Spatial@data[c("CDH5","CYP3A4","ANXA4","ACTA2","AXL"),])
for (i in 1:nrow(exp)) {
exp[i,]<-as.numeric(scale(as.numeric(exp[i,])))
}
cell.prop<-as.data.frame(prop.table(table(output$cell_type, output$spot),2))
prop <- as.data.frame(reshape2::dcast(cell.prop, Var1~Var2))
## Using Freq as value column: use value.var to override.
rownames(prop)<-prop$Var1
prop<-prop[,2:ncol(prop)]
exp<-t(exp)
prop<-t(prop)
exp<-exp[,c("CDH5","CYP3A4","ANXA4","ACTA2","AXL")]
prop<-prop[,c("Endothelial cells","Hepatocytes","Cholangiocytes","Fibroblasts","Macrophages")]
coorda<-corr.test(exp,prop,method="pearson")
plot<-coorda$r
pheatmap(plot,
scale = "none",
color = c(colorRampPalette(colors = c("#002FA7","white"))(100)),
legend_breaks=seq(-0.5,0.5,0.2),cluster_rows = F,cluster_cols = F,border_color = NA)
Spatial pattern of selected markers in input ST data.
sfplot(spatial_object,features = c("CYP3A4","ANXA4","ACTA2"),ncol=3,image.alpha=0,pt.size.factor = 2)
## Scale for fill is already present.
## Adding another scale for fill, which will replace the existing scale.
## Scale for fill is already present.
## Adding another scale for fill, which will replace the existing scale.
## Scale for fill is already present.
## Adding another scale for fill, which will replace the existing scale.
## Warning: CombinePlots is being deprecated. Plots should now be combined using
## the patchwork system.
Spatial pattern of selected markers in SpaTrio maps.
sfplot(pred,features = c("CYP3A4","ANXA4","ACTA2"),ncol=3,image.alpha=0,pt.size.factor = 4)
## Scale for fill is already present.
## Adding another scale for fill, which will replace the existing scale.
## Scale for fill is already present.
## Adding another scale for fill, which will replace the existing scale.
## Scale for fill is already present.
## Adding another scale for fill, which will replace the existing scale.
## Warning: CombinePlots is being deprecated. Plots should now be combined using
## the patchwork system.
Spatial gene module analysis of hepatocytes Since hepatocytes accounted for the largest proportion, we analyzed hepatocytes first.
Idents(pred)<-pred$my_type2
object<-subset(pred,idents ="Hepatocytes")
# Calculate the value of sigma
spatial_object$xcoord<-spatial_object@images$slice1@coordinates$imagerow
spatial_object$ycoord<-spatial_object@images$slice1@coordinates$imagecol
kNN_dist <- dbscan::kNN(na.omit(spatial_object@meta.data[, c('xcoord', 'ycoord')]), k=6)$dist
spot_dist <- median(kNN_dist) %>% round
spot_dist
## [1] 227
object$xcoord<-object@images$image@coordinates$x
object$ycoord<-object@images$image@coordinates$y
DefaultAssay(object)<-"RNA"
object<-NormalizeData(object)
object<-FindVariableFeatures(object,nfeatures = 2000)
feature_select <- VariableFeatures(object)
object<-ScaleData(object,features =feature_select)%>%RunPCA()%>%FindNeighbors(reduction = "pca", dims = 1:30)%>%RunUMAP(reduction = "pca",dims = 1:30)%>%FindClusters(resolution=0.1)
## Centering and scaling data matrix
## PC_ 1
## Positive: CYP3A4, CAMK1D, ACSS3, GLUL, RHOBTB1, GPAM, MYRIP, SLC13A3, SPRN, SNTG1
## TBC1D1, ARHGEF28, ALDH1L1, GS1-122H1.2, DPP4, SLC16A7, WDPCP, LGR5, NEK10, NRG1
## TTC7B, PDLIM1, AKR1C3, RANBP3L, SLC25A33, HMGCS1, PDK4, TBL1Y, ELOVL6, TRHDE
## Negative: SDS, HAL, C9, NNMT, CUX2, PDE7B, MTHFD2L, AFF3, RAPGEF5, KCNT2
## GPR125, SLC38A4, ASS1, AMDHD1, NAMPT, SLC7A2, FGFR2, AC016682.1, RP11-256L6.3, FNIP2
## GLDC, FGB, SLC2A9, PKHD1, MAP3K5, GPC5, CLPTM1L, IGF1, FGL1, CYP2A7
## PC_ 2
## Positive: PPARGC1A, GLIS3, RP11-136K7.2, SAMD12, GPR125, CHST9, WDPCP, RAPGEF5, MLIP, ABLIM1
## LEPR, LPIN2, NEDD4L, 7SK.2, ABCB11, RBPMS, FOXO1, ANKH, PPM1L, FOXO3
## PDE7B, ALDH1A2, ARL15, AC016768.1, STPG2, KCNT2, SLC2A9, LURAP1L, FNIP2, RP11-624L4.1
## Negative: MT-CO1, HSP90AA1, FABP1, PTPRB, CYP2B6, CTD-2515C13.2, DOCK2, ROBO2, AL592494.5, GABRB3
## CHST11, CELF2, RP11-767I20.1, FGB, MEF2C, SAA1, RP11-669M16.1, FGF12, TENM3, RP11-25H12.1
## IGLL5, HDAC9, CYP3A4, CRP, VEPH1, RSPO2, PRKG1, HSPA1B, CASC15, AC012593.1
## PC_ 3
## Positive: DTNA, BICC1, DAPK2, CTD-3037G24.3, BCL2, BIRC3, FGFR2, PLA2G4C, RP11-215N21.1, RP11-770E5.1
## TNFAIP8, ABCC1, SOD2, GLUL, KLHL29, FAT1, FGF13, CAP2, FABP1, HKDC1
## PTPN14, ARNTL2, ADRBK2, SUSD1, PRICKLE2, WIPF3, AC096559.1, CREB5, NEDD4L, STAT4
## Negative: CPS1, AASS, CTNNA3, G6PC, KCNN2, NEK10, CYP2C19, OAT, ABCB11, RP11-118B18.1
## CYP2B6, AGPAT9, SNTG1, NCAM2, PPARGC1A, APLP2, MAN1C1, MME, C9, SLC38A4
## IL1RAPL2, SH3RF2, RP11-701P16.2, AC006369.2, CCRN4L, AKR1D1, MAP3K5, MOGAT1, RANBP3L, PDE11A
## PC_ 4
## Positive: FOXO3, ZC3H13, AGPAT9, PPARGC1A, 7SK.2, LURAP1L, G6PC, PPM1L, ABCB11, TGFBR2
## CHST9, RP11-215N21.1, DTNA, LINC00886, APLP2, GS1-122H1.2, FOXO1, TMEM56-RWDD3, SLC41A3, DLEU1
## C5orf17, ADRBK2, MAN1C1, GPR125, RP11-426C22.5, GPR128, NRG1, RP11-770E5.1, FGB, SIMC1
## Negative: SDC2, LBP, SDC4, ARRDC3, FDFT1, KCNK5, UGP2, TOX3, GCH1, PPP1R3B
## ZNRF3, ELOVL5, FABP1, DAPK1, ATP11C, RNF144B, ATF3, GPAM, GS1-179L18.1, GLCCI1
## PXDC1, MEIS2, GLDC, POU6F2, SAMD5, AUTS2, FIGN, EVL, ACSL4, CYP2C19
## PC_ 5
## Positive: HMGCS1, SERPINE1, CRY1, RP11-30J20.1, NREP, KLF6, ZSWIM6, AKR1C1, ACSS2, ELOVL5
## PLOD2, MYO1E, WDR72, GPAM, GLUD1, PPAP2A, FDFT1, DUSP10, PPARGC1A, CHST9
## TGFBR2, NEDD9, NRG1, RP5-1043L13.1, LINC00470, LPIN2, GLDC, ELOVL6, GCH1, XDH
## Negative: GS1-179L18.1, ZNF827, TCF4, LRP1B, SORT1, PCLO, ICA1, PTPN14, DPH6-AS1, PAM
## AC009120.4, FSIP2, EPB41L4A, COL4A5, SV2B, RP11-475O6.1, BICD1, PRKD1, RP11-284M14.1, VSNL1
## PBX1, RP11-611E13.2, AC092594.1, DIRC3, LINC00271, ADD3, LRRC1, SPAG16, ASB4, RASGRF2
## Computing nearest neighbor graph
## Computing SNN
## Warning: The default method for RunUMAP has changed from calling Python UMAP via reticulate to the R-native UWOT using the cosine metric
## To use Python UMAP via reticulate, set umap.method to 'umap-learn' and metric to 'correlation'
## This message will be shown once per session
## 17:03:24 UMAP embedding parameters a = 0.9922 b = 1.112
## 17:03:24 Read 2938 rows and found 30 numeric columns
## 17:03:24 Using Annoy for neighbor search, n_neighbors = 30
## 17:03:24 Building Annoy index with metric = cosine, n_trees = 50
## 0% 10 20 30 40 50 60 70 80 90 100%
## [----|----|----|----|----|----|----|----|----|----|
## **************************************************|
## 17:03:25 Writing NN index file to temp file /tmp/Rtmpnq8ub5/file3fc349a27194
## 17:03:25 Searching Annoy index using 1 thread, search_k = 3000
## 17:03:25 Annoy recall = 100%
## 17:03:25 Commencing smooth kNN distance calibration using 1 thread with target n_neighbors = 30
## 17:03:26 Initializing from normalized Laplacian + noise (using irlba)
## 17:03:26 Commencing optimization for 500 epochs, with 127720 positive edges
## 17:03:30 Optimization finished
## Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
##
## Number of nodes: 2938
## Number of edges: 136927
##
## Running Louvain algorithm...
## Maximum modularity in 10 random starts: 0.9043
## Number of communities: 2
## Elapsed time: 0 seconds
rm(module_list)
## Warning in rm(module_list): object 'module_list' not found
allfile <- dir("untitled_consensus_cluster")
file.remove(paste("untitled_consensus_cluster",allfile,sep = "/"))
## [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
# Detection of spatial protein modules
module_list<-spatrio_resonance(object,
sigma=230,
assay='RNA',
feature_select=feature_select,
correlation='pearson',
maxK=8,
k=8,
min_avg_con=0.5,
min_avg_cor=0.5,
min_featuer=20,
max_featuer=1000,
smooth = "reduction",
reduction = "umap",
smooth_k = 10,
min_pct_cutoff = 0.1)
## Feature filtering...
## Filtering features...
## Data smoothing
## Smoothing with reduction...
## Loading required package: foreach
## Loading required package: iterators
## Loading required package: parallel
## | | | 0%Running in parallel using 5 cores ..
## | | | 1% | |= | 1% | |= | 2% | |== | 2% | |== | 3% | |== | 4% | |=== | 4% | |=== | 5% | |==== | 5% | |==== | 6% | |===== | 6% | |===== | 7% | |===== | 8% | |====== | 8% | |====== | 9% | |======= | 9% | |======= | 10% | |======= | 11% | |======== | 11% | |======== | 12% | |========= | 12% | |========= | 13% | |========= | 14% | |========== | 14% | |========== | 15% | |=========== | 15% | |=========== | 16% | |============ | 16% | |============ | 17% | |============ | 18% | |============= | 18% | |============= | 19% | |============== | 19% | |============== | 20% | |============== | 21% | |=============== | 21% | |=============== | 22% | |================ | 22% | |================ | 23% | |================ | 24% | |================= | 24% | |================= | 25% | |================== | 25% | |================== | 26% | |=================== | 26% | |=================== | 27% | |=================== | 28% | |==================== | 28% | |==================== | 29% | |===================== | 29% | |===================== | 30% | |===================== | 31% | |====================== | 31% | |====================== | 32% | |======================= | 32% | |======================= | 33% | |======================= | 34% | |======================== | 34% | |======================== | 35% | |========================= | 35% | |========================= | 36% | |========================== | 36% | |========================== | 37% | |========================== | 38% | |=========================== | 38% | |=========================== | 39% | |============================ | 39% | |============================ | 40% | |============================ | 41% | |============================= | 41% | |============================= | 42% | |============================== | 42% | |============================== | 43% | |============================== | 44% | |=============================== | 44% | |=============================== | 45% | |================================ | 45% | |================================ | 46% | |================================= | 46% | |================================= | 47% | |================================= | 48% | |================================== | 48% | |================================== | 49% | |=================================== | 49% | |=================================== | 50% | |=================================== | 51% | |==================================== | 51% | |==================================== | 52% | |===================================== | 52% | |===================================== | 53% | |===================================== | 54% | |====================================== | 54% | |====================================== | 55% | |======================================= | 55% | |======================================= | 56% | |======================================== | 56% | |======================================== | 57% | |======================================== | 58% | |========================================= | 58% | |========================================= | 59% | |========================================== | 59% | |========================================== | 60% | |========================================== | 61% | |=========================================== | 61% | |=========================================== | 62% | |============================================ | 62% | |============================================ | 63% | |============================================ | 64% | |============================================= | 64% | |============================================= | 65% | |============================================== | 65% | |============================================== | 66% | |=============================================== | 66% | |=============================================== | 67% | |=============================================== | 68% | |================================================ | 68% | |================================================ | 69% | |================================================= | 69% | |================================================= | 70% | |================================================= | 71% | |================================================== | 71% | |================================================== | 72% | |=================================================== | 72% | |=================================================== | 73% | |=================================================== | 74% | |==================================================== | 74% | |==================================================== | 75% | |===================================================== | 75% | |===================================================== | 76% | |====================================================== | 76% | |====================================================== | 77% | |====================================================== | 78% | |======================================================= | 78% | |======================================================= | 79% | |======================================================== | 79% | |======================================================== | 80% | |======================================================== | 81% | |========================================================= | 81% | |========================================================= | 82% | |========================================================== | 82% | |========================================================== | 83% | |========================================================== | 84% | |=========================================================== | 84% | |=========================================================== | 85% | |============================================================ | 85% | |============================================================ | 86% | |============================================================= | 86% | |============================================================= | 87% | |============================================================= | 88% | |============================================================== | 88% | |============================================================== | 89% | |=============================================================== | 89% | |=============================================================== | 90% | |=============================================================== | 91% | |================================================================ | 91% | |================================================================ | 92% | |================================================================= | 92% | |================================================================= | 93% | |================================================================= | 94% | |================================================================== | 94% | |================================================================== | 95% | |=================================================================== | 95% | |=================================================================== | 96% | |==================================================================== | 96% | |==================================================================== | 97% | |==================================================================== | 98% | |===================================================================== | 98% | |===================================================================== | 99% | |======================================================================| 99% | |======================================================================| 100%
## Merging results ..
##
## Time Elapsed: 37.8403875827789 secs
## Calculating with 836 features...
## Data scaling...
## Centering and scaling data matrix
## Spatially weighted correlation calculating...
## Consensus clustering...
## end fraction
## clustered
## clustered
## clustered
## clustered
## clustered
## clustered
## clustered
## Feature module calculating...
## [1] 20
spatrio_heatmap(module_list,ann_cols = pal_d3()(length(module_list$group)))
## $Group
## Module1 Module2
## "#1F77B4FF" "#FF7F0EFF"
object<-spatrio_score(object,module_list,nbin = 5,ctrl = 20,clean=T)
sfplot(object, grep('Module', colnames(object@meta.data), value=T),stroke = NA,pt.size.factor = 4,option = "D",max.cutoff='q90',min.cutoff='q10')
## Scale for fill is already present.
## Adding another scale for fill, which will replace the existing scale.
## Scale for fill is already present.
## Adding another scale for fill, which will replace the existing scale.
## Warning: CombinePlots is being deprecated. Plots should now be combined using
## the patchwork system.
After SpaTrio maps the transcriptome and proteome to space simultaneously, the understanding of more dimensions of cell interaction follows. We selected some cells in the portal and periportal areas, and used SpaTrio to analyze the multi-modal spatial interactions of cells between these two areas.
For proteome-based analysis of cellular communication, we utilize the results of the modular analysis. And in the subsequent analysis, based on the abundance of proteins in the module, the protein interaction score is calculated.
cci_object_index <- readRDS("data/Human_steatosis_liver/cci_object_index.rds")
cci_object<-subset(pred,cell=cci_object_index)
sdplot(pred,highlight.cell = colnames(cci_object),pt.size.factor = 3)
DefaultAssay(cci_object)<-"ADT"
VariableFeatures(cci_object)<-rownames(cci_object)
cci_object<-NormalizeData(cci_object, normalization.method = "CLR", margin = 2)%>%ScaleData()%>%RunPCA(npcs = 10,reduction.name = "apca")%>%RunUMAP(dims = 1:10,reduction="apca")
## Normalizing across cells
## Centering and scaling data matrix
## PC_ 1
## Positive: CD36, CD49a, CD29, CD206, CD102, CD13, CD47, CD31, CD10, CD146
## CD54, CD59, CD26, CD309, HLA-ABC, CD98, CD40, CD123, CD81, B2M
## CD90, CD4, CD107a, CD38, Folate, CD270, CD27, CD304, CD21, CD141
## Negative: CD1c, CD11a, CD56, CD45R, CD19, CD43, CD45RA, CD18, CD44, CD2
## CD184, CD7, CD252, CD58, CD69, MERTK, CD366, CD161, CD177, CD20
## CD301, CD244, CD15, Siglec8, CD194, CD140a, XCR1, CD30, CD195, CD209
## PC_ 2
## Positive: CD64, CD16, CD11b, CD14, CD141, CD66a, CD140b, CD177, CD27, XCR1
## CD45R, CD137L, CD123, TMEM119, CD194, CD57, CD66b, CD81, CD274, CD146
## CD61, CD277, CD55, CD45RA, CD309, CD59, CD206, CD26, CD80, HLA-DR
## Negative: CD127, CD25, Notch, CD294, Podoplanin, CD314, CD8a, CD48, CD133, CD169
## CD134, CD103, CD71, CD96, CD185, CD93, CD279, CD45RO, CD272, CD276
## CD144, Galectin9, CD3, CD86, CD9, CD370, CD79b, CD22, CD41, Tim4
## PC_ 3
## Positive: CD9, CD103, CD71, CD32, CD19, CD117, CD110, CD52, CD93, CD56
## Podoplanin, CD370, TSLPR, CD48, CD123, Notch, CD105, CD62E, CD274, CD57
## IgG, CD340, CD69, CD269, CD309, CD314, FceRIa, CD49a, CD13, CD178
## Negative: CD33, HLA-DR, CD11c, CD244, CD163, KLRG1, CD39, VSIG4, CD106, CD152
## CD1a, CD267, CD138, CD24, CD135, CD140a, CD28, Folate, CD14, CD86
## CD18, CD62L, CD272, CD38, CD96, CD1d, CD303, CD58, CD20, CD324
## PC_ 4
## Positive: CD55, CD57, CD194, CD137, CD284, CD49d, CD2, CD274, CD34, CD140b
## CD43, CD277, TMEM119, CD45RA, CD7, CD5, KLRG1, CD80, CD70, CD28
## CD32, CD154, CD112, CD85g, CD20, CD177, CD49f, CD95, CD196, CD24
## Negative: CD163, HLA-DR, CD11c, CD39, CD16, CD106, CD14, CD185, Folate, CD33
## Tim4, CD71, CD64, CD45R, CD19, CD41, CD86, CD272, CD103, CD93
## CD45RO, C5L2, CD275, VSIG4, CD314, CD68, CD38, CD161, CD83, CD340
## PC_ 5
## Positive: CD34, CD110, CD80, XCR1, CD204, CD33, CD16, CD14, CD57, HLA-DR
## CD277, CD52, CD273, CD178, CD11c, CD269, IgG-Hamster, CD115, CD64, CD3
## CD275, CD119, CD163, CD195, CD72, CD135, CD161, CD106, C5L2, CD45R
## Negative: CD5, CD7, CD223, CD144, CD226, CD35, CD42b, CD185, CD278, CD45RO
## EGFR, CD2, CD62L, CD90, FceRIa, CD105, CD96, Cadherin, CD79b, CD11a
## CD55, CD69, CD62P, CD196, CD272, CD28, KLRG1, CD40, HLA-ABC, CD127
## Warning: Cannot add objects with duplicate keys (offending key: PC_) setting
## key to original value 'apca_'
## 17:04:21 UMAP embedding parameters a = 0.9922 b = 1.112
## 17:04:21 Read 180 rows and found 10 numeric columns
## 17:04:21 Using Annoy for neighbor search, n_neighbors = 30
## 17:04:21 Building Annoy index with metric = cosine, n_trees = 50
## 0% 10 20 30 40 50 60 70 80 90 100%
## [----|----|----|----|----|----|----|----|----|----|
## **************************************************|
## 17:04:21 Writing NN index file to temp file /tmp/Rtmpnq8ub5/file3fc33c4211af
## 17:04:21 Searching Annoy index using 1 thread, search_k = 3000
## 17:04:21 Annoy recall = 100%
## 17:04:22 Commencing smooth kNN distance calibration using 1 thread with target n_neighbors = 30
## 17:04:22 Initializing from normalized Laplacian + noise (using irlba)
## 17:04:22 Commencing optimization for 500 epochs, with 6482 positive edges
## 17:04:23 Optimization finished
feature_select<-rownames(cci_object)
cci_object$xcoord<-cci_object@images$image@coordinates$x
cci_object$ycoord<-cci_object@images$image@coordinates$y
# Detection of spatial protein modules
module_list<-spatrio_resonance(cci_object,
sigma=230,
assay='ADT',
feature_select=feature_select,
correlation='pearson',
maxK=8,
k=6,
min_avg_con=0.6,
min_avg_cor=0.6,
min_featuer=10,
max_featuer=200,
smooth = "reduction",
reduction = "umap",
smooth_k = 10,
min_pct_cutoff = 0.1)
## Feature filtering...
## Filtering features...
## Data smoothing
## Smoothing with reduction...
## | | | 0%Running in parallel using 5 cores ..
## | | | 1% | |= | 1% | |= | 2% | |== | 2% | |== | 3% | |=== | 4% | |==== | 5% | |==== | 6% | |===== | 7% | |===== | 8% | |====== | 8% | |====== | 9% | |======= | 9% | |======= | 10% | |======= | 11% | |======== | 11% | |======== | 12% | |========= | 12% | |========= | 13% | |========== | 14% | |========== | 15% | |=========== | 16% | |============ | 17% | |============ | 18% | |============= | 18% | |============= | 19% | |============== | 19% | |============== | 20% | |============== | 21% | |=============== | 21% | |=============== | 22% | |================ | 22% | |================ | 23% | |================= | 24% | |================== | 25% | |================== | 26% | |=================== | 27% | |=================== | 28% | |==================== | 28% | |==================== | 29% | |===================== | 29% | |===================== | 30% | |===================== | 31% | |====================== | 31% | |====================== | 32% | |======================= | 32% | |======================= | 33% | |======================== | 34% | |======================== | 35% | |========================= | 36% | |========================== | 37% | |========================== | 38% | |=========================== | 38% | |=========================== | 39% | |============================ | 39% | |============================ | 40% | |============================ | 41% | |============================= | 41% | |============================= | 42% | |============================== | 42% | |============================== | 43% | |=============================== | 44% | |================================ | 45% | |================================ | 46% | |================================= | 47% | |================================= | 48% | |================================== | 48% | |================================== | 49% | |=================================== | 49% | |=================================== | 50% | |=================================== | 51% | |==================================== | 51% | |==================================== | 52% | |===================================== | 52% | |===================================== | 53% | |====================================== | 54% | |====================================== | 55% | |======================================= | 56% | |======================================== | 57% | |======================================== | 58% | |========================================= | 58% | |========================================= | 59% | |========================================== | 59% | |========================================== | 60% | |========================================== | 61% | |=========================================== | 61% | |=========================================== | 62% | |============================================ | 62% | |============================================ | 63% | |============================================= | 64% | |============================================== | 65% | |============================================== | 66% | |=============================================== | 67% | |=============================================== | 68% | |================================================ | 68% | |================================================ | 69% | |================================================= | 69% | |================================================= | 70% | |================================================= | 71% | |================================================== | 71% | |================================================== | 72% | |=================================================== | 72% | |=================================================== | 73% | |==================================================== | 74% | |==================================================== | 75% | |===================================================== | 76% | |====================================================== | 77% | |====================================================== | 78% | |======================================================= | 78% | |======================================================= | 79% | |======================================================== | 79% | |======================================================== | 80% | |======================================================== | 81% | |========================================================= | 81% | |========================================================= | 82% | |========================================================== | 82% | |========================================================== | 83% | |=========================================================== | 84% | |============================================================ | 85% | |============================================================ | 86% | |============================================================= | 87% | |============================================================= | 88% | |============================================================== | 88% | |============================================================== | 89% | |=============================================================== | 89% | |=============================================================== | 90% | |=============================================================== | 91% | |================================================================ | 91% | |================================================================ | 92% | |================================================================= | 92% | |================================================================= | 93% | |================================================================== | 94% | |================================================================== | 95% | |=================================================================== | 96% | |==================================================================== | 97% | |==================================================================== | 98% | |===================================================================== | 98% | |===================================================================== | 99% | |======================================================================| 99% | |======================================================================| 100%
## Merging results ..
##
## Time Elapsed: 16.9846119880676 secs
## Calculating with 179 features...
## Data scaling...
## Centering and scaling data matrix
## Spatially weighted correlation calculating...
## Consensus clustering...
## end fraction
## clustered
## clustered
## clustered
## clustered
## clustered
## clustered
## clustered
## Feature module calculating...
## [1] 10
module_list[["group"]][["k3"]]<-NULL
spatrio_heatmap(module_list,ann_cols = pal_d3()(length(module_list$group)),border_color=NA)
## $Group
## Module1 Module2
## "#1F77B4FF" "#FF7F0EFF"
The spatial interaction of genes is calculated based on the spatial position obtained by spatrio, and the previously developed spatalk package is used here to calculate the interaction score.
load("data/Human_steatosis_liver/lrpairs.rda")
load("data/Human_steatosis_liver/pathways.rda")
obj<-gene_cci_analysis(cci_object,
assay = "RNA",
species = "Human",
xcoord = cci_object@images$image@coordinates$x,
ycoord = cci_object@images$image@coordinates$y,
celltype = cci_object$spot_type,
lrpairs = lrpairs,
pathways=pathways)
## Checking input data
## Begin to filter lrpairs and pathways
## ***Done***
## Note: there are 2 cell types and 2 pair-wise cell pairs
## Begin to find LR pairs
SpaTrop speculates the multi-modal cell interaction (gene-gene interaction & protein-protein interaction) from portal to periportal.
library(data.table)
##
## Attaching package: 'data.table'
## The following objects are masked from 'package:dplyr':
##
## between, first, last
## The following objects are masked from 'package:reshape2':
##
## dcast, melt
#Read in data frame containing protein id and gene id information
id <- read_csv("data/Human_steatosis_liver/id.csv")
## New names:
## • `` -> `...1`
## Rows: 190 Columns: 3
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (2): orig, transfer
## dbl (1): ...1
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#Read in data frame containing information of cell-cell interaction
lr<-fread("data/Human_steatosis_liver/human_lr_pair.txt")
p1<-gene_cci_plot(obj,celltype_sender="Portal",celltype_receiver="Periportal", top_lrpairs = 20, color = "#9a6a9e")
Idents(cci_object)<-cci_object$spot_type
df<-adt_cci_analysis(cci_object,
input_list=module_list,
id=id,
lr=lr,
celltype_sender="Portal",
celltype_receiver="Periportal",
module_sender="k1",
module_receiver="k2",
transfer = T)#In the calculation process, in order to obtain richer interaction information, we converted protein id into gene id
## Normalizing across cells
## Centering and scaling data matrix
p2<-adt_cci_plot(df,color = "#cb6377")
CombinePlots(list(p1,p2))
## Warning: CombinePlots is being deprecated. Plots should now be combined using
## the patchwork system.
head(gene_cci_plot(obj,celltype_sender="Portal",celltype_receiver="Periportal", top_lrpairs = 20, color = "#9a6a9e",return_data = T))
## ligand receptor species celltype_sender celltype_receiver lr_co_exp_num
## 753 GDF5 ACVR2A Human Portal Periportal 5
## 855 GDF2 ACVR1 Human Portal Periportal 8
## 856 BMP2 ACVR1 Human Portal Periportal 22
## 858 GDF5 ACVR1 Human Portal Periportal 7
## 859 TGFB2 ACVR1 Human Portal Periportal 21
## 51 EBI3 IL6ST Human Portal Periportal 17
## lr_co_ratio lr_co_ratio_pvalue score
## 753 0.02314815 0 1.0000000
## 855 0.03703704 0 0.9998780
## 856 0.10185185 0 0.9998780
## 858 0.03240741 0 0.9998780
## 859 0.09722222 0 0.9998780
## 51 0.07870370 0 0.9997315
head(df)
## lr_pair ligand_gene_symbol receptor_gene_symbol ligand_exp receptor_exp
## 1: ICAM1_ITGAL ICAM1 ITGAL 3.904139 37.3519194
## 2: ICAM2_ITGAL ICAM2 ITGAL 1.497519 37.3519194
## 3: CD14_ITGB2 CD14 ITGB2 23.326354 1.9383121
## 4: ICAM1_ITGB2 ICAM1 ITGB2 3.904139 1.9383121
## 5: ICAM2_ITGB2 ICAM2 ITGB2 1.497519 1.9383121
## 6: ICAM1_SPN ICAM1 SPN 3.904139 0.3238685
## score
## 1: 1.00000000
## 2: 0.61933211
## 3: 0.55682178
## 4: 0.22780088
## 5: 0.14108440
## 6: 0.09311677
SpaTrop speculates the multi-modal cell interaction (gene-gene interaction & protein-protein interaction) from periportal to portal.
library(data.table)
#Read in data frame containing protein id and gene id information
id <- read_csv("data/Human_steatosis_liver/id.csv")
## New names:
## Rows: 190 Columns: 3
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (2): orig, transfer dbl (1): ...1
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `` -> `...1`
#Read in data frame containing information of cell-cell interaction
lr<-fread("data/Human_steatosis_liver/human_lr_pair.txt")
p1<-gene_cci_plot(obj,celltype_sender="Periportal",celltype_receiver="Portal", top_lrpairs = 20, color = "#9a6a9e")
df<-adt_cci_analysis(cci_object,
input_list=module_list,
id=id,
lr=lr,
celltype_sender="Periportal",
celltype_receiver="Portal",
module_sender="k2",
module_receiver="k1",
transfer = T)#In the calculation process, in order to obtain richer interaction information, we converted protein id into gene id
## Normalizing across cells
## Centering and scaling data matrix
p2<-adt_cci_plot(df,color = "#cb6377")
CombinePlots(list(p1,p2))
## Warning: CombinePlots is being deprecated. Plots should now be combined using
## the patchwork system.
head(gene_cci_plot(obj,celltype_sender="Periportal",celltype_receiver="Portal", top_lrpairs = 20, color = "#9a6a9e",return_data = T))
## ligand receptor species celltype_sender celltype_receiver lr_co_exp_num
## 1199 GDF9 TGFBR1 Human Periportal Portal 4
## 806 FGG ITGAV Human Periportal Portal 81
## 807 FGA ITGAV Human Periportal Portal 86
## 810 FGB ITGAV Human Periportal Portal 81
## 817 ANGPTL3 ITGAV Human Periportal Portal 28
## 819 FN1 ITGAV Human Periportal Portal 81
## lr_co_ratio lr_co_ratio_pvalue score
## 1199 0.01606426 0 0.9999944
## 806 0.32530120 0 0.9975877
## 807 0.34538153 0 0.9975877
## 810 0.32530120 0 0.9975877
## 817 0.11244980 0 0.9975877
## 819 0.32530120 0 0.9975877
head(df)
## lr_pair ligand_gene_symbol receptor_gene_symbol ligand_exp
## 1: LGALS9_CD47 LGALS9 CD47 0.09370726
## 2: CD70_CD27 CD70 CD27 0.06032591
## 3: CD70_TNFRSF17 CD70 TNFRSF17 0.06032591
## receptor_exp score
## 1: 1.9666947 1.0000000
## 2: 0.8266830 0.5201952
## 3: 0.2386804 0.2795151