Spatial architecture of autism pathogenesis reveals mosaic structural disarray during early development.
The 10 matches
- [1] § Methods › Spatial Signaling Score (S3) ↔ Spatial signaling score/CalculateSpatialSignalingScore.R, lines 87–167 · score 0.88 · edge weight, ligand expression, cell contact, receptor expression, scaled S3, sender cell
- [2] § Methods › Spatial Signaling Score (S3) ↔ Spatial signaling score/CalculateSpatialSignalingScore.R, lines 87–167 · score 0.75 · cell contact graph, edge weights, Scaled S3, receiver cell identity, sum, sender
- [3] § Methods › Spatial Signaling Score (S3) ↔ Spatial signaling score/Spatialsignalingscore_main.R, lines 1–42 · score 0.71 · literature supported, receptor genes, shortlisted ligand, ligand receptor pairs, S3, Score
- [4] § Methods › MERFISH spot assignment ↔ Spot assigment/Assign_spots_EDT.py, lines 231–281 · score 0.67 · segmented cell, RNA spot, cell mask, nucleus, assignment, dilated
- [5] § Results › Cell adhesion between ASD progenitors is dysregulated ↔ Spatial signaling score/CalculateSpatialSignalingScore.R, lines 47–85 · score 0.66 · interacting cell pairs, receptor expression, Spatial Signaling Score, receiver cell identity, ligand receptor, sender
- [6] § Methods › Spatial Signaling Score (S3) ↔ Spatial signaling score/Spatialsignalingscore_main.R, lines 330–392 · score 0.64 · edge weight, cell contact, ligand receptor pair, sender, S3, receiver
- [7] § Methods › Spatial Signaling Score (S3) ↔ Spatial signaling score/Spatialsignalingscore_main.R, lines 330–392 · score 0.60 · cell contact graph, edge weights, cell identity, sender, S3, receiver
- [8] § Methods › MERFISH spot assignment ↔ Spot assigment/Assign_spots_EDT.py, lines 231–281 · score 0.59 · segmented region, RNA spots, nuclei, assignment, DAPI, mask
- [9] § Methods › Spatial Signaling Score (S3) ↔ Spatial signaling score/Spatialsignalingscore_main.R, lines 394–455 · score 0.53 · randomized control, diagnosis, disorganized, signaling, cell identities, S3
- [10] § Methods › MERFISH spot decoding ↔ Spot assigment/Assign_spots_EDT.py, lines 39–130 · score 0.52 · Euclidean distance, closest, spots, pixels, frame, cell
Paper
Loaded from Europe PMC by your browser, not stored by OSCR: doi.org · Europe PMC
The paper is loaded when this pane is shown.
The authors' code
R · 685 lines · 40 KB · no license · 4 matches
- # The main script for quantifying spatial ligand-receptor interactions
- # load libraries
- library(patchwork) #1.1.1
- library(Rmisc) #1.5
- library(reticulate) #1.22
- library(data.table) #1.14.2
- library(readxl) #1.3.1
- library(reshape2) #1.4.4
- library(pheatmap) #1.0.12
- library(Seurat) #4.0.2
- library(ggplot2)
- library(readxl)
- library(quantmod)
- # load our own functions
- source("/home/ubuntu/SpatialSignalingScore/DistToDataframe.R")
- source("/home/ubuntu/SpatialSignalingScore/AnalysisSpatialNetworks.R")
- source("/home/ubuntu/SpatialSignalingScore/CalculateSpatialSignalingScore.R")
- source("/home/ubuntu/SpatialSignalingScore/ScaleSpatialSignalingScore.R")
- source("/home/ubuntu/SpatialSignalingScore/FindDifferentialSpatialSignalingScore.R")
- source("/home/ubuntu/SpatialSignalingScore/VisualizeS3Dotplot.R")
- source("/home/ubuntu/SpatialSignalingScore/LoadAllMetrics.R")
- #======================================== 1. SHORTLIST LIGANDS AND RECEPTORS FOR ANALYSIS ==============================================
- #---------------- Load ligand-receptor pairs from literature: https://static-content.springer.com/esm/art%3A10.1038%2Fs41467-020-18873-z/MediaObjects/41467_2020_18873_MOESM4_ESM.xlsx ---------------
- ligand.receptor = read_excel('/home/ubuntu/41467_2020_18873_MOESM4_ESM.xlsx',sheet='literature_support')
- #---------------- Select ligands and receptors that exist in scRNAseq panel ---------------
- scrnaP <- readRDS("/home/ubuntu/scrnaP.rds")
- scrnaN <- readRDS("/home/ubuntu/scrnaN.rds")
- scrna<-merge(scrnaN,y = scrnaP)
- selected_pairs = data.frame(ligand = character(length=0L),receptor=character(length=0L))
- for (i in 1:nrow(ligand.receptor)){
- if (ligand.receptor[i,"Ligand gene symbol"] %in% rownames(scrna@assays[["SCT"]])){
- if (ligand.receptor[i,"Receptor gene symbol"] %in% rownames(scrna@assays[["SCT"]])){
- temp = cbind(as.character(ligand.receptor[i,"Ligand gene symbol"]),
- as.character(ligand.receptor[i,"Receptor gene symbol"]),
- as.character(ligand.receptor[i,"Ligand location"]))
- colnames(temp) = c('ligand','receptor','ligand.location')
- selected_pairs=rbind(selected_pairs,temp)
- }}}
- write.csv(selected_pairs,file='/home/ubuntu/differentialS3/selected_ligand-receptor_pairs_latest2020_20230714.txt')
- #---------------- Filter out ligands and receptors that are lowly expressed in scRNAseq ---------------
- lig.rec = unique(c(as.character(selected_pairs$ligand),as.character(selected_pairs$receptor)))
- # get highest mean expression per cell identity across all cell identities
- best.avg = data.frame(row.names=lig.rec)
- avg.scRNAseq <- AverageExpression(scrna, features=lig.rec, assays="SCT",slot='counts',group.by = "cell_identity",verbose =F)
- best.avg$scRNAseq <- apply(avg.scRNAseq$SCT,1,max)
- p <- hist(log(best.avg$scRNAseq),breaks=60)
- p$breaks[findValleys(p$density, thresh=0)]
- lig.rec.good = lig.rec[(best.avg$scRNAseq)>exp(-2.4)] # threshold selected is at the valley of the bimodel distribution
- selected_pairs2= data.frame(ligand = character(length=0L),receptor=character(length=0L))
- for (i in 1:nrow(selected_pairs)){
- if (selected_pairs[i,"ligand"] %in% lig.rec.good){
- if (selected_pairs[i,"receptor"] %in% lig.rec.good){
- temp = cbind(as.character(selected_pairs[i,"ligand"]),
- as.character(selected_pairs[i,"receptor"]))
- colnames(temp) = c('ligand','receptor')
- selected_pairs2=rbind(selected_pairs2,temp)
- }}}
- lig.rec.left = unique(c(as.character(selected_pairs2$ligand),as.character(selected_pairs2$receptor)))
- selected_pairs = selected_pairs2
- selected_pairs$LR_comb = paste0(as.character(selected_pairs$ligand),'--',as.character(selected_pairs$receptor))
- write.csv(selected_pairs,file=paste0(root_dir,'selected_ligand-receptor_pairs_threshold_valley_20230714.txt'))
- #---------------- Initialze all paremeters and paths ---------------
- meta.mfish <- read.csv("/home/ubuntu/metadata_mfish.csv", header = T)
- data_name = meta.mfish$data_name
- ctrl_name = meta.mfish$data_name[meta.mfish$diagnosis=="ctrl"]
- case_name = meta.mfish$data_name[meta.mfish$diagnosis=="ASD"]
- ##--- choose assay 'SCT': measured expression,'SCTpred': imputed expression. Both use 'counts' slot ---
- assay = 'SCTpred'
- ##--- choose method of Spatial Signaling Score 1:demoninator being # of interacted receiver cells,
- ## 2:demoninator being # of all receiver cells,
- save.id = 2 # default is 2
- ##--- directory of results for all datasets ---
- root_dir = '/home/ubuntu/differentialS3/'
- data_dir = '/home/ubuntu/differentialS3/panel1/'
- results_folder = '/home/ubuntu/differentialS3/results/'
- data_dir_wilcoxtest = '/home/ubuntu/differentialS3/wilcoxtest/'
- ##--- choose cell identity labels to be processed ---
- # labels from imputed expression: 'imputed.cell_identity'
- # labels from measured expression: 'cell_identity'
- cluster_column = "imputed.cell_identity"
- ##--- choose the spatial network, 'SN_2median':physical distance < 2*median are connected
- ## 'SN_touched':two cells are touched, juxtacrine signalling
- spatial_network_name = 'SN_touched'
- ##--- threshold of proportion of interacting receiver cells ---
- prop_thrd = 0.2
- ##--- load SFARI gene list ---
- sfari.gene = read.csv("/home/ubuntu/SFARI-Gene_genes_01-23-2023release_03-02-2023export.csv")
- ##--- Format of selected ligand-receptor pairs ---
- # "ligand" "receptor" "ligand.location" "LR_comb"
- # 1 ...
- # 2 ...
- # ...
- ##--- load selected ligand-receptor pairs ---
- LRname = "_exp-5_intersect"
- selected_pairs = read.csv(file=paste0(root_dir,'selected_ligand-receptor_pairs_threshold_valley_20230714.txt'))
- selected_pairs = selected_pairs[,-1]
- selected_pairs$LR_comb = paste0(selected_pairs$ligand,'--',selected_pairs$receptor)
- ##--- Subset ligand-receptor pairs for which ligand and/or receptor are SFARI genes ---
- selected_pairs_sfari = NULL
- for (i in 1:nrow(selected_pairs)){
- if ( selected_pairs$ligand[i] %in% sfari.gene$gene.symbol | selected_pairs$receptor[i] %in% sfari.gene$gene.symbol){
- selected_pairs_sfari=rbind(selected_pairs_sfari,selected_pairs[i,])
- }
- }
- write.csv(selected_pairs_sfari,file=paste0(root_dir,'sfari_ligand-receptor_pairs_20230714.txt'))
- ## NOTE: all steps will saved intermediate results. Subsequent steps will directly load the saved results
- #======================================== 2. GENERATE SPATIAL NETWORKS & CALCULATE PROPORTION OF INTERACTING RECEIVER CELLS ==============================================
- for (x in c(1:length(data_name))){
- results_folder = paste0(root_dir,'panel1/',data_name[x],'/')
- if (!dir.exists(results_folder)){
- dir.create(results_folder)
- }
- Mer <- readRDS(paste0("/home/ubuntu/label transfer/dataset/",meta.mfish$data_name[[x]],"_imputed_18k_genes_-SCT-anchor-SCT.rds"))
- gene.list = unique(c(rownames(Mer@assays$SCT), selected_pairs$ligand, selected_pairs$receptor))
- gene.list = gene.list[gene.list %in% rownames(Mer)]
- Mer <- subset(Mer, features = gene.list)
- cell_id = names(Idents(Mer))
- cell_id = substr(cell_id,7+nchar(data_name[x]),16+nchar(data_name[x]))
- Idents(Mer) = as.numeric(cell_id)
- Mer<-RenameCells(Mer, new.names =as.character(Idents(Mer)))
- mer.loc <- data.frame(row.names = Idents(Mer))
- mer.loc$X = Mer$X
- mer.loc$Y = Mer$Y
- actual_height = max(Mer$Y) - min(Mer$Y)
- actual_width = max(Mer$X) - min(Mer$X)
- height = actual_height/1000 # plot height
- width = actual_width/1000
- size = width/100
- #---------------- generate spatial networks ----------------
- if (spatial_network_name == 'SN_touched'){
- # cell-cell contact network/graph generated on python, directly load here
- annot_network = read.csv(paste0('/home/ubuntu/',meta.mfish$data_name[[x]],'/touched_cell_networks.csv'))
- # delete the edge of cells filtered in preprocessing
- annot_network = annot_network[annot_network$from %in% Idents(Mer) &annot_network$to %in% Idents(Mer),]
- annot_network$from = factor(annot_network$from)
- annot_network$to = factor(annot_network$to)
- annot_network$distance = sqrt((annot_network$sdimx_begin-annot_network$sdimx_end)**2+(annot_network$sdimy_begin-annot_network$sdimy_end)**2)
- print(paste0(meta.mfish$data_name[[x]], ":median of cell cell distance is ", median(annot_network$distance)))
- Mer@graphs[[spatial_network_name]] = list(name = spatial_network_name, method = 'touched',networkDT = annot_network)
- } else if ( spatial_network_name == 'SN_2median'){
- # find median of nearest neighbor
- nn_spatial <- dbscan::kNN(loc , k=1)
- median_neighbors = median(nn_spatial[["dist"]])
- print(paste0(data_name[dataset],': median of nearest neighbor is ',median_neighbors))
- # spatial networks, distance < 2* median
- Mer<-GenerateSpatialNetwork(Mer, threshold=median_neighbors*2,
- name = spatial_network_name,full_network = FALSE)
- }
- #---------------- Calculate proportion of interacting receiver cells. results are stored in Mer@graphs[[spatial_network_name]][['proportion']][[cluster_column]] ----------------
- Mer<-AnalysisSpatialNetworks(object=Mer,
- cluster_column = 'imputed.cell_identity',
- selected_clusters = selected_clusters,
- selected_pairs = selected_pairs,
- networks = spatial_network_name)
- Mer<-AnalysisSpatialNetworks(object=Mer,
- cluster_column = 'cell_identity',
- selected_clusters = selected_clusters,
- selected_pairs = selected_pairs,
- networks = spatial_network_name)
- saveRDS(Mer,paste0(results_folder,"Seurat_object_",spatial_network_name,".rds"))
- }
- #---------------- Filter proportion of interacting receiver cells ----------------
- ##--- Load proportion for all datasets ----
- cluster_column = 'imputed.cell_identity'
- proportion_all = NULL
- for(dataset in c(ctrl_name, case_name)){
- data_folders = paste0(data_dir, dataset, '/')
- print(dataset)
- Mer<-readRDS(paste0(data_folders,"Seurat_object_", spatial_network_name, ".rds"))
- print(unique(Mer$imputed.cell_identity))
- spatial_all_scores<-Mer@graphs[[spatial_network_name]][['proportion']][[cluster_column]]
- spatial_all_scores$data = dataset
- proportion_all = rbind(proportion_all,spatial_all_scores)
- }
- write.csv(proportion_all,paste0(root_dir,'proportion/proportion_all_',cluster_column,'_',spatial_network_name,'.csv'))
- ##--- Calculate the mean proportions within each diagnosis ----
- proportion_mean = data.frame(row.names = unique(proportion_all$LR_cell_comb))
- for (cell_identity_pairs in unique(proportion_all$LR_cell_comb)){
- # control
- temp =proportion_all[proportion_all$LR_cell_comb %in%cell_identity_pairs &proportion_all$data %in% ctrl_name,]
- proportion_mean[cell_identity_pairs,'mean_ctrl'] = mean(temp$proportion)
- proportion_mean[cell_identity_pairs,'standard_error_ctrl'] = sd(temp$proportion)/sqrt(nrow(temp)-1)
- # case
- temp =proportion_all[proportion_all$LR_cell_comb %in%cell_identity_pairs &proportion_all$data %in% case_name,]
- proportion_mean[cell_identity_pairs,'mean_case'] = mean(temp$proportion)
- proportion_mean[cell_identity_pairs,'standard_error_case'] = sd(temp$proportion)/sqrt(nrow(temp)-1)
- }
- proportion_mean = proportion_mean[!is.na(proportion_mean$standard_error_ctrl) &!is.na(proportion_mean$standard_error_case),]
- proportion_mean$LR_cell_comb = rownames(proportion_mean)
- write.csv(proportion_mean,paste0(root_dir,'proportion/proportion_mean_',cluster_column,'_',spatial_network_name,'.csv'))
- ##--- give the cell identities we are interested ----
- selected_clusters = unique(Mer$imputed.cell_identity)
- ##--- all the homotypical cell identity pairs A-A and its proportions ---
- same_DT = data.table(V1 = selected_clusters, V2 = selected_clusters)
- same_DT$LR_cell_comb = paste0(same_DT$V1,'--',same_DT$V2)
- proportion_all_homo = proportion_mean[proportion_mean$LR_cell_comb %in% same_DT$LR_cell_comb,]
- write.csv(proportion_all_homo,paste0(root_dir,'proportion/proportion_mean_homo_',cluster_column,'_',spatial_network_name,'.csv'))
- ##--- apply threshold for homotypical cell identity pairs ---
- proportion_homo_filtered = proportion_all_homo[proportion_all_homo$mean_ctrl>prop_thrd,]
- ##--- heterotypic cell identity pairs: A-B, B-A ---
- combn_DT = as.data.table(t(combn(selected_clusters, m = 2)))
- # direction 1: A-B
- combn_DT$LR_cell_comb_1 = paste0(combn_DT$V1,'--',combn_DT$V2)
- # direction 2: B-A
- combn_DT$LR_cell_comb_2 = paste0(combn_DT$V2,'--',combn_DT$V1)
- combn_DT$proportion_1 =NA
- combn_DT$proportion_2=NA
- ##--- for any two cell identities, find the maximum proportion in either direction ---
- for (i in seq(1,nrow(combn_DT))){
- if (length(proportion_mean[proportion_mean$LR_cell_comb %in% combn_DT$LR_cell_comb_1[i],"mean_ctrl"]!=0)){
- combn_DT$proportion_1[i] = proportion_mean[proportion_mean$LR_cell_comb %in% combn_DT$LR_cell_comb_1[i],"mean_ctrl"]
- }
- if (length(proportion_mean[proportion_mean$LR_cell_comb %in% combn_DT$LR_cell_comb_2[i],"mean_ctrl"]!=0)){
- combn_DT$proportion_2[i] = proportion_mean[proportion_mean$LR_cell_comb %in% combn_DT$LR_cell_comb_2[i],"mean_ctrl"]
- }
- combn_DT$proportion[i] = max(combn_DT$proportion_1[i],combn_DT$proportion_2[i])
- }
- proportion_hetero_all = combn_DT[!is.na(combn_DT$proportion_1),]
- write.csv(proportion_hetero_all,paste0(root_dir,'proportion/proportion_mean_hetero_',cluster_column,'_',spatial_network_name,'.csv'))
- ##--- apply threshold for heterotypic cell identity pairs: find the maximum proportion in either direction > threshold ---
- proportion_hetero_filtered = proportion_hetero_all[proportion_hetero_all$proportion>prop_thrd,]
- ##--- all the cell identity pairs after applying filtering ---
- selected_cluster_pairs = c(proportion_hetero_filtered$LR_cell_comb_1,proportion_hetero_filtered$LR_cell_comb_2,rownames(proportion_homo_filtered))
- write.csv(selected_cluster_pairs,paste0(root_dir,'proportion/selected_cluster_pairs_proportion_',prop_thrd,'_',cluster_column,'_',spatial_network_name,'.csv'),col.names = NA, row.names = FALSE)
- #---------------- Visualize selected proportions of interacting receiver cells ----------------
- ##--- load cell identity pairs after applying filtering ---
- selected_cluster_pairs = read.csv(paste0(root_dir,'proportion/selected_cluster_pairs_proportion_0.2_',cluster_column,'_',spatial_network_name,'.csv'))
- selected_cluster_pairs = sort(selected_cluster_pairs$x)
- ##--- load proportion for all cell identity pairs and all datasets ---
- proportion_all = read.csv(paste0(root_dir,'proportion/proportion_all_',cluster_column,'_',spatial_network_name,'.csv'))
- selDT = as.data.table(proportion_all)
- selDT_d = data.table::dcast.data.table(selDT, data~LR_cell_comb, value.var = 'proportion', fill = 0)
- dataname = c(ctrl_name,case_name)
- rownames = selDT_d$data
- selDT_d = selDT_d[,-1]
- selDT_d = as.matrix(selDT_d)
- rownames(selDT_d) = rownames
- selDT_g = selDT_d[dataname,]
- ##--- do wilcoxon test on proportions to identify cell identity pairs with significant difference between case and control, p.value<0.05 ---
- sign_cluster_pairs = NULL
- for (col in 1:ncol(selDT_g)) {
- ttest=t.test(selDT_g[ctrl_name,col],selDT_g[case_name,col],na.action=na.omit)
- print(paste0(colnames(selDT_g)[col]," proportion p.value: ",ttest$p.value))
- if (ttest$p.value<=0.05) sign_cluster_pairs = c(sign_cluster_pairs,colnames(selDT_g)[col])
- }
- sign_cluster_pairs = intersect(sign_cluster_pairs,selected_cluster_pairs)
- ##--- mean case vs mean ctrl ---
- proportion_case = data.frame(row.names = selected_cluster_pairs )
- proportion_sub = proportion_all[proportion_all$data %in% case_name,]
- for (cell_identity_pairs in selected_cluster_pairs ){
- temp =proportion_sub[proportion_sub$LR_cell_comb %in%cell_identity_pairs,]
- proportion_case[cell_identity_pairs,'mean'] = mean(temp$proportion)
- proportion_case[cell_identity_pairs,'standard_error'] = sd(temp$proportion)/sqrt(nrow(temp)-1)
- }
- proportion_case$diagnosis = 'Case'
- proportion_case$cell_identity_pairs = rownames(proportion_case)
- proportion_ctrl = data.frame(row.names = selected_cluster_pairs)
- proportion_sub = proportion_all[proportion_all$data %in% ctrl_name,]
- for (cell_identity_pairs in selected_cluster_pairs ){
- temp =proportion_sub[proportion_sub$LR_cell_comb %in%cell_identity_pairs,]
- proportion_ctrl[cell_identity_pairs,'mean'] = mean(temp$proportion)
- proportion_ctrl[cell_identity_pairs,'standard_error'] = sd(temp$proportion)/sqrt(nrow(temp)-1)
- }
- proportion_ctrl$diagnosis = 'Control'
- proportion_ctrl$cell_identity_pairs = rownames(proportion_ctrl)
- proportion_mean = rbind(proportion_case,proportion_ctrl)
- x.text <- transpose(as.data.frame(strsplit(sort(unique(proportion_mean$cell_identity_pairs)), split = "--")))
- colnames(x.text) = c('sender', 'receiver')
- x.text$sender.receiver = paste0(x.text$sender,'--',x.text$receiver)
- x.text$color = 'black'
- x.text$color[x.text$sender.receiver %in% sign_cluster_pairs] = 'red'
- ggplot(data = proportion_mean,aes(x=mean,y=cell_identity_pairs,color=diagnosis))+geom_point(alpha=0.5)+#position = position_dodge(width = 1)
- geom_errorbar(aes(xmin = mean-standard_error,xmax = mean+standard_error,color=diagnosis),alpha=0.5) +
- theme_bw() + scale_color_manual(values = c('orange','black'))+
- theme(axis.text.x = element_text(angle = 0, vjust = 0.5, hjust=0.5,size=16),
- legend.title = element_text(size=16), #change legend title font size
- legend.text = element_text(size=15))+
- annotate(geom = "text", y=c(nrow(x.text)+1), x = -0.5, label = c('receiver'), size = 7,hjust = 0,fontface="bold")+
- annotate(geom = "text", y=c(nrow(x.text)+1), x = -0.55, label = c('sender'), size = 7, hjust = 1,fontface="bold")+
- annotate(geom = "text", y=c(nrow(x.text)+1), x = -0.525, label = c('-'), size = 7, hjust = 0.5,fontface="bold")+
- annotate(geom = "text", y = seq_len(nrow(x.text)), x = -0.5, label = x.text$receiver, size = 6,colour = x.text$color,hjust = 0)+
- annotate(geom = "text", y = seq_len(nrow(x.text)), x = -0.55, label = x.text$sender, size = 6,colour = x.text$color,hjust = 1)+
- annotate(geom = "text", y = seq_len(nrow(x.text)), x = -0.525, label = '-', size = 6,colour = x.text$color,hjust = 0.5)+
- coord_cartesian(xlim=c(0,1),ylim=c(0.5,nrow(x.text)+0.5),expand = FALSE, clip = "off")+
- theme(plot.margin=unit(c(2,1,1,20),'lines'),axis.text.y = element_blank(),axis.title = element_blank())
- ggsave(paste0(root_dir,'proportion/',cluster_column,'_proportion_',prop_thrd,'_case_vs_ctrl_',spatial_network_name,'_20230714.png'),
- width = 9.3,height=30,units = 'in')
- #======================================== 3. EVALUATE LARB CUTOFF ==============================================
- assay='SCTpred'
- data_folders = paste0(data_dir,data_name[4],'/')
- ##--- load the merfish dataset with the spatial networks ---
- Mer<-readRDS(paste0(data_folders,"Seurat_object_",spatial_network_name,".rds"))
- Mer<-subset(Mer,feature = unique(c(selected_pairs$ligand,selected_pairs$receptor)))
- expr_select = GetAssayData(object = Mer, assay = assay, slot = 'data')
- cell_metadata = [email hidden]
- ##--- the annotation of spatial network ---
- annot_network_directional = Mer@graphs[[spatial_network_name]][["networkDT"]]
- ##--- get the expression ---
- colnames(expr_select) = colnames(Mer)
- ##--- check if ligand or receptor existing in the expression ---
- selected_pairs_sub = selected_pairs[selected_pairs$ligand %in% rownames(expr_select),]
- selected_pairs_sub = selected_pairs_sub[selected_pairs_sub$receptor %in% rownames(expr_select),]
- ##--- only keep the ligand-receptor pairs for ligand and receptor existing in the expression ---
- select_ligands = as.character(selected_pairs_sub$ligand)
- select_receptors = as.character(selected_pairs_sub$receptor)
- sender.expr = as.matrix(expr_select[select_ligands,as.character(annot_network_directional$from)])
- receiver.expr = as.matrix(expr_select[select_receptors,as.character(annot_network_directional$to)])
- ##--- edge weight in cell-cell contact graph ---
- LARB_expr = sender.expr*receiver.expr
- hist(log(LARB_expr),breaks=100)
- LARB_cutoff = exp(-5) # 2x peak of log distribution
- #======================================== 4. CALCULATE SPATIAL SIGNALING SCORE ==============================================
- assay="SCTpred"
- cluster_column = "imputed.cell_identity"
- for (x in c(1:length(data_name))){
- print(data_name[x])
- results_folder = paste0('/home/ubuntu/differentialS3/panel1/',data_name[x],'/')
- if (!dir.exists(results_folder)){
- dir.create(results_folder)
- }
- data_folders = paste0(data_dir,data_name[x],'/')
- Mer<-readRDS(paste0(data_folders,"Seurat_object_",spatial_network_name,".rds"))
- if(!dir.exists(paste0(results_folder,'3_lig-rec_cell-cell_communication'))){
- dir.create(paste0(results_folder,'3_lig-rec_cell-cell_communication'))
- }
- ##--- only run for the cell_identity pairs shortlist ---
- selected_cluster_pairs = read.csv(paste0(root_dir,'proportion/selected_cluster_pairs_proportion_',prop_thrd,'_imputed.cell_identity_',spatial_network_name,'.csv'))
- selected_cluster_pairs = sort(selected_cluster_pairs$x)
- Mer<-CalculateSpatialSignalingScore(object=Mer,
- cluster_column = cluster_column,
- selected_cluster_pairs = selected_cluster_pairs,
- normalization = FALSE,
- LARB_cutoff = LARB_cutoff,
- assay = assay,
- slot = 'data',
- selected_pairs = selected_pairs,
- networks = spatial_network_name,
- save.id = save.id)
- saveRDS(Mer,paste0(results_folder,save.id,"_Seurat_object_SpatialSignalingScore",spatial_network_name, "_assay_",assay,LRname,".rds"))#"_LARB_",LARB_cutoff,"_scale.factor_",scale.factor,
- }
- #======================================== 5. CALCULATE CASE-CONTROL DIFFERENTIAL SPATIAL SIGNALING SCORE ==============================================
- # get shortlist cell_identity pairs
- assay='SCTpred'
- cluster_column = 'imputed.cell_identity'
- selected_cluster_pairs = read.csv(paste0(root_dir,'proportion/selected_cluster_pairs_proportion_0.2_',cluster_column,'_',spatial_network_name,'.csv'))
- selected_cluster_pairs = sort(selected_cluster_pairs$x)
- ctrl_name = meta.mfish$data_name[meta.mfish$diagnosis=="ctrl"]
- case_name = meta.mfish$data_name[meta.mfish$diagnosis=="ASD"]
- phenotypeA = meta.mfish$data_name[meta.mfish$layering=="disorganized" & # bud_mis_layering_no_desease_state_case
- meta.mfish$diagnosis=="ASD" &
- meta.mfish$state=="canonical" &
- meta.mfish$bud=="present"]
- phenotypeA = c(phenotypeA, "20221006_JY_T2_B4_108A")
- phenotypeA = phenotypeA[! phenotypeA %in% "20220916_JY_T2_B4_50"]
- phenotypeB = meta.mfish$data_name[ meta.mfish$diagnosis=="ASD" &
- meta.mfish$state=="diseased"]
- grps = list("case_name" = case_name,
- "phenotypeA" = phenotypeA,
- "phenotypeB" = phenotypeB)
- for (group in names(grps)){
- score_all_dataset = FindDifferentialSpatialSignalingScore(case_name=get(group),
- ctrl_name=ctrl_name, selected_pairs= selected_pairs,
- cluster_column=cluster_column, selected_cluster_pairs = selected_cluster_pairs,
- spatial_network_name=spatial_network_name, data_dir=data_dir,save.id=save.id,
- assay = assay,LRname = LRname)
- saveRDS(score_all_dataset,paste0(root_dir,'wilcoxtest/',save.id,'_dS3_', group, '_vs-all-ctrls_',cluster_column,'_',spatial_network_name,"_assay_",assay,LRname,'.rds'))
- }
- #--- compare random sets of controls: we use mean 99th percentile of NMD distribution in 50 randomized control-to-control comparisons as threshold ----
- df <- data.frame()
- for (itr in 1:50){
- ctrl1 <- union(sample(meta.mfish$data_name[meta.mfish$layering %in% "disorganized"], 3), sample(meta.mfish$data_name[meta.mfish$layering %in% "layered"], 4))
- ctrl2 <- ctrl_name[!ctrl_name %in% ctrl1]
- score_all_dataset = FindDifferentialSpatialSignalingScore(case_name=ctrl2,
- ctrl_name=ctrl1, selected_pairs= selected_pairs,
- cluster_column=cluster_column, selected_cluster_pairs = selected_cluster_pairs,
- spatial_network_name=spatial_network_name, data_dir=data_dir,save.id=save.id,
- assay = assay,LRname = LRname)
- saveRDS(score_all_dataset,paste0(root_dir,'wilcoxtest/',save.id,'_dS3_ctrlvsctrl-itr', itr, '_',cluster_column,'_',spatial_network_name,"_assay_",assay,LRname,'.rds'))
- metric_score = readRDS(paste0(data_dir_wilcoxtest, save.id,'_dS3_ctrlvsctrl-itr', itr, '_',cluster_column,'_',spatial_network_name,"_assay_",assay, LRname, '.rds'))
- metric_score <- metric_score[metric_score$p.adjust < thr.padjust, ]
- print(nrow(metric_score[metric_score$p.adjust < thr.padjust,]))
- df[itr, 1:6] <- summary(metric_score$differential_S3_normalized)
- df[itr, 7] <- mean(abs(metric_score$differential_S3_normalized))
- }
- colnames(df) <- c("min","Q1", "median", "mean", "Q3", "max", "mean abs NMD")
- for (itr in 1:50){
- metric_score = readRDS(paste0(data_dir_wilcoxtest, save.id,'_dS3_ctrlvsctrl-itr', itr, '_',cluster_column,'_',spatial_network_name,"_assay_",assay, LRname, '.rds'))
- print(nrow(metric_score[metric_score$p.adjust < thr.padjust & abs(metric_score$differential_S3_normalized) > mean(df$V9), ]))
- }
- colnames(df[, 8:10]) <- c("95th percentile", "99th percentile", "99.9th percentile")
- saveRDS(df, "/home/ubuntu/differentialS3/wilcoxtest/ctrl-vs-ctrl_iterations.rds")
- #======================================== 6. DOTPLOT VISUALIZATION OF CASE-CONTROL DIFFERENTIAL SPATIAL SIGNALING SCORE ==============================================
- assay='SCTpred'
- cluster_column = 'imputed.cell_identity'
- selected_pairs_sfari = read.csv(file=paste0(root_dir,'sfari_ligand-receptor_pairs_20230714.txt'))
- selected_pairs_nosfari = selected_pairs[!selected_pairs$LR_comb %in% selected_pairs_sfari$LR_comb,]
- # set the parameter
- size = "p.adjust"
- diff = "differential_S3_normalized"
- color = "differential_S3_normalized"
- metrics = "score"
- thr.pvalue = NULL
- filtering = TRUE
- thr.diff = 0.006 # mean 99th percentile of NMD distribution in 50 randomized control-to-control comparisons
- thr.padjust = 0.05
- orderby = color
- top_num_per_pair = NULL
- top_num_all = 200L
- sfari = ""
- highlight = sfari.gene$gene.symbol
- cluster_on = color
- max_diff=NULL
- p.circle = 0.05
- meanlig_thr = NULL
- meanrec_thr = NULL
- control.grp = "all"
- for (option in c("case_name", "phenotypeA", "phenotypeB")){
- metric_score = readRDS(paste0(data_dir_wilcoxtest, save.id, '_dS3_', option, '_vs-', control.grp, '-ctrls_', cluster_column,'_', spatial_network_name, "_assay_", assay, LRname,'.rds'))
- print(paste0(option, " ", nrow(metric_score[metric_score$p.adjust<thr.padjust & abs(metric_score$differential_S3_normalized) > 0.006,]), " significant LRCC"))
- lig.rep_order = VisualizeS3Dotplot(metric_score=metric_score, size=size,color=color,diff=diff,metrics = metrics,
- filtering = filtering, thr.pvalue = thr.pvalue, thr.diff = thr.diff,thr.padjust = thr.padjust,
- orderby = orderby,top_num_per_pair = top_num_per_pair,top_num_all=top_num_all,
- cluster_on =cluster_on, max_diff=max_diff,results_folder=data_dir_wilcoxtest,
- cluster_column=cluster_column,spatial_network_name=spatial_network_name,assay = assay,
- selected_pairs=selected_pairs,#_sfari,sfari = sfari,
- highlight = highlight, selected_clusters_pairs = selected_clusters_pairs,
- clustering='col',cluster_order_row = selected_clusters_pairs$sender.receiver,#cluster_order_col = cluster_order_col,
- p.circle=p.circle,save.id=save.id,w.adjust = 5, h.adjust = 4.5, saving_name = paste0('_pearson_',option,'_', control.grp, 'ctrls', LRname))
- }
- #======================================== 7. HEATMAP VISUALIZATION OF POSITIVE-CONTROL LIGAND-RECEPTOR INTERACTIONS ==============================================
- ##--- ligand-receptor pairs from literature ---
- lig_rep_positive = read.csv(file='/home/ubuntu/positive_ctrl/lig-rec-shortlist_230705_v2.txt')
- ##--- shortlist cell_identity pairs ---
- cell_identity_select_1 = expand.grid(selected_clusters,selected_clusters)
- colnames(cell_identity_select_1) = c('receiver','sender')
- cell_identity_select_1$sender.receiver = paste0(cell_identity_select_1$sender,'--',cell_identity_select_1$receiver)
- cell_identity_select = read.csv(file='/home/ubuntu/differentialS3/positive_ctrl/selected cell_identity pairs sender_v4.csv')[,-1]
- cell_identity_select_1 = cell_identity_select_1[cell_identity_select_1$sender.receiver %in% cell_identity_select,]
- cell_identity_select_1 = transpose(as.data.frame(strsplit(cell_identity_select, split = "--")))
- colnames(cell_identity_select_1) = c('sender','receiver')
- ##--- get scaled S3 for all datasets and all ligand-receptor pairs ---
- ScaledSpatialSignalingScore = readRDS(paste0(data_dir_wilcoxtest,save.id,'_all_ScaledSpatialSignalingScore_',cluster_column,'_',spatial_network_name,"_assay_",assay,LRname,'.rds'))
- cell_identity_select_1 = cell_identity_select_1[cell_identity_select_1$sender.receiver %in% unique(ScaledSpatialSignalingScore$LR_cell_comb),]
- #cell_identity_select_1 = cell_identity_select_1[cell_identity_select_1$sender.receiver %in% sign_cell_identity_pairs,]
- ##--- subset control datasets and their positive-control ligand-receptor interactions
- ScaledSpatialSignalingScore = ScaledSpatialSignalingScore[ScaledSpatialSignalingScore$LR_comb %in% lig_rep_positive_1$LR_comb,]
- #subset selected cell_identity pairs
- ScaledSpatialSignalingScore = ScaledSpatialSignalingScore[ScaledSpatialSignalingScore$LR_cell_comb %in% cell_identity_select_1$sender.receiver,]
- cluster_on = "mean_ctrl"
- ScaledSpatialSignalingScore_temp = expand.grid(cell_identity_select_1$sender.receiver,lig_rep_positive_1$LR_comb)
- colnames(ScaledSpatialSignalingScore_temp) = c("LR_cell_comb","LR_comb" )
- ScaledSpatialSignalingScore_temp$LR_CC = paste0(ScaledSpatialSignalingScore_temp$LR_comb,'---',ScaledSpatialSignalingScore_temp$LR_cell_comb)
- ScaledSpatialSignalingScore_temp$mean_ctrl = 0
- ##--- get the mean scaled S3 across all controls ---
- ScaledSpatialSignalingScore = rbind(ScaledSpatialSignalingScore[,c("LR_cell_comb","LR_comb","LR_CC" ,"mean_ctrl" )],
- ScaledSpatialSignalingScore_temp[!ScaledSpatialSignalingScore_temp$LR_CC%in%ScaledSpatialSignalingScore$LR_CC,])
- selDT = as.data.table(ScaledSpatialSignalingScore)
- selDT_d = data.table::dcast.data.table(selDT, LR_cell_comb ~LR_comb, value.var = cluster_on, fill = 0)
- rownames = as.character(selDT_d[[1]])
- write.csv(selDT_d,file=paste0(root_dir,"wilcoxtest/","pos-ctrl-ScaledSpatialSignalingScore.csv"))
- clus_sort_names_row = cell_identity_select_1$sender.receiver
- y.text <- transpose(as.data.frame(strsplit(clus_sort_names_row, split = "--")))
- colnames(y.text ) = c('sender', 'receiver')
- y.text$sender.receiver = paste0(y.text$sender,"--",y.text$receiver)
- y.text$color = 'black'
- y.text$symble = "-"
- selDT[, `:=`(LR_cell_comb, factor(LR_cell_comb, clus_sort_names_row))]
- ##--- change the col order ---
- clus_sort_names_col = lig_rep_positive_1$LR_comb
- x.text <- transpose(as.data.frame(strsplit(clus_sort_names_col, split = "--")))
- colnames(x.text) = c('ligand', 'receptor')
- selDT[, `:=`(LR_comb, factor(LR_comb, clus_sort_names_col))]
- selDT$mean_ctrl[selDT$mean_ctrl>0.05]=0.05
- max = max(selDT$mean_ctrl)
- median = median(selDT$mean_ctrl)
- mean = mean(selDT$mean_ctrl)
- min= min(selDT$mean_ctrl)
- ggplot()+ geom_tile(data = selDT, aes_string(x = "LR_comb", y = "LR_cell_comb", fill = "mean_ctrl")) +
- theme_classic() +
- labs(fill='mean\ncontrol\nScaledSpatialSignalingScore')+
- annotate(geom = "text", x=c(0), y = -3.5, label = c('receptor'), size = 3.5, angle=90,hjust = 0,fontface="bold")+
- annotate(geom = "text", x=c(0), y = -4, label = c('ligand'), size = 3.5, angle=90,hjust = 1,fontface="bold")+
- annotate(geom = "text", y =c(nrow(y.text)+1), x = -6.5, label = c('sender'), size = 3.5,hjust = 1,fontface="bold")+
- annotate(geom = "text", y = c(nrow(y.text)+1), x = -6, label = c('receiver'), size = 3.5,hjust = 0,fontface="bold")+
- annotate(geom = "text", y = c(nrow(y.text)+1), x = -6.25, label = c('-'), size = 3.5,hjust = 0.5,fontface="bold")+
- annotate(geom = "text", x = seq_len(nrow(x.text)), y = -3.5, label = x.text$receptor, size = 2.7, angle=90,hjust = 0)+
- annotate(geom = "text", x = seq_len(nrow(x.text)), y = -4, label = x.text$ligand, size = 2.7, angle=90,hjust = 1)+
- annotate(geom = "text", y = seq_len(nrow(y.text)), x = -6.5, label = y.text$sender, colour=y.text$color,size = 2.7,hjust = 1)+
- annotate(geom = "text", y = seq_len(nrow(y.text)), x = -6.25, label = y.text$symble, colour=y.text$color,size = 2.7,hjust = 0.5)+
- annotate(geom = "text", y = seq_len(nrow(y.text)), x = -6, label = y.text$receiver, colour=y.text$color,size = 2.7,hjust = 0)+
- coord_cartesian(ylim = c(0.5, nrow(y.text)+0.5),xlim=c(0.5,nrow(x.text)+0.5),expand = FALSE, clip = "off")+
- theme(plot.margin=unit(c(1.5,1,6,11),'lines'),axis.text = element_blank(),axis.title = element_blank())+
- scale_fill_gradient2(low='blue',high='red',mid='yellow',midpoint =(min+max)/2)
- ggsave(paste0(root_dir,"wilcoxtest/",save.id,'_',cluster_column,'_mean_ScaledSpatialSignalingScore_of_positive_lig-rep_on_ctrl_dataset_',spatial_network_name,LRname,'_colclip0.05.png'),
- width = 7.5,height=5.6,units = 'in')
- #======================================== 8. COMPARE SCALED S3 CALCULATED WITH MEASURED AND IMPUTED EXPRESSION ==============================================
- assay = 'SCT'
- cluster_column = 'cell_identity'
- ScaledSpatialSignalingScore_measured = readRDS(paste0(data_dir_wilcoxtest,save.id,'_all_ScaledSpatialSignalingScore_',cluster_column,'_',spatial_network_name,"_assay_",assay,LRname,'.rds'))
- assay = 'SCTpred'
- cluster_column = 'imputed.cell_identity'
- ScaledSpatialSignalingScore_imputed = readRDS(paste0(data_dir_wilcoxtest,save.id,'_all_ScaledSpatialSignalingScore_',cluster_column,'_',spatial_network_name,"_assay_",assay,LRname,'.rds'))
- ##--- get all ligand-receptor pairs present in MERFISH panel ---
- lig_rec = unique(ScaledSpatialSignalingScore_measured$LR_comb)
- ##--- calculate max LR_expr across all cell identity pairs for measured and imputed separately ---
- max_LR_expr_pred = data.frame(row.names = paste(lig_rec))
- assay = 'SCTpred'
- cluster_column = 'imputed.cell_identity'
- for (dataset in data_name){
- results_folder = paste0(data_dir,'/',dataset,'/')
- Mer = readRDS(paste0(results_folder,save.id,"_Seurat_object_SpatialSignalingScore",spatial_network_name, "_assay_",assay,LRname,".rds"))
- spatial_all_scores<-Mer@graphs[[spatial_network_name]]$SpatialSignalingScore[[cluster_column]]
- LR_expr = spatial_all_scores[,c('LR_comb','LR_cell_comb','LR_expr')]
- colnames(LR_expr)[3] = 'Value'
- LR_expr = dcast(LR_expr,LR_comb~LR_cell_comb)
- rownames(LR_expr) = LR_expr$LR_comb
- LR_expr = LR_expr[lig_rec,]
- LR_expr = LR_expr[,-1]
- # max lig_expr across all cell identity pairs for each ligand-receptor pair
- max_LR_expr_pred[[dataset]] = apply(LR_expr,1,max)
- }
- max_LR_expr = data.frame(row.names = paste(lig_rec))
- assay = 'SCT'
- cluster_column = 'cell_identity'
- for (dataset in data_name){
- results_folder = paste0(data_dir,'/',dataset,'/')
- Mer = readRDS(paste0(results_folder,save.id,"_Seurat_object_SpatialSignalingScore",spatial_network_name, "_assay_",assay,LRname,".rds"))
- spatial_all_scores<-Mer@graphs[[spatial_network_name]]$SpatialSignalingScore[[cluster_column]]
- LR_expr = spatial_all_scores[,c('LR_comb','LR_cell_comb','LR_expr')]
- colnames(LR_expr)[3] = 'Value'
- LR_expr = dcast(LR_expr,LR_comb~LR_cell_comb)
- rownames(LR_expr) = LR_expr$LR_comb
- LR_expr = LR_expr[lig_rec,]
- LR_expr = LR_expr[,-1]
- # max lig_expr across all interactions for each ligand-receptor pair
- max_LR_expr[[dataset]] = apply(LR_expr,1,max)
- }
- max_LR_expr$LR = rownames(max_LR_expr)
- max_LR_expr_pred$LR = rownames(max_LR_expr_pred)
- max_LR_expr_1 = melt(max_LR_expr,id.vars =c("LR"))
- colnames(max_LR_expr_1)[3] = 'measured'
- max_LR_expr_pred_1 = melt(max_LR_expr_pred,id.vars =c("LR"))
- colnames(max_LR_expr_pred_1)[3] = 'imputed'
- max_LR_expr_all = max_LR_expr_1
- max_LR_expr_all$imputed = max_LR_expr_pred_1$imputed
- ggplot(max_LR_expr_all,aes(x=measured,y=imputed))+geom_point(color='red',shape=1)+ggtitle('max_LR_expr_all')
- ggsave(paste0(root_dir,'/measured_imputed/imputed-measured.png'),height=10,width=10)
- ##--- filter out the lowly expressed ligand-receptor pairs in both measured and imputed expression ---
- cutoff = 0.05
- max_LR_expr_all_select = max_LR_expr_all[max_LR_expr_all$imputed>cutoff & !is.na(max_LR_expr_all$measured)&max_LR_expr_all$measured>cutoff,]
- ##--- scatter plot ---
- all_scores = NULL
- for (dataset in data_name){
- results_folder = paste0(data_dir,'/',dataset,'/')
- print(dataset)
- if (!dir.exists(results_folder)){
- dir.create(results_folder)}
- LR_comb_select = max_LR_expr_all_select$LR[max_LR_expr_all_select$variable %in% dataset ]
- if (length(LR_comb_select)!=0){
- assay = 'SCTpred'
- cluster_column = "imputed.cell_identity"
- Mer = readRDS(paste0(results_folder,save.id,"_Seurat_object_SpatialSignalingScore",spatial_network_name, "_assay_",assay,LRname,".rds"))
- spatial_all_scores<-Mer@graphs[[spatial_network_name]]$SpatialSignalingScore[[cluster_column]]
- spatial_all_scores_pred = spatial_all_scores[spatial_all_scores$LR_comb %in% LR_comb_select,c('LR_comb',"LR_cell_comb","ScaledSpatialSignalingScore")]
- assay = 'SCT'
- cluster_column = "cell_identity"
- Mer = readRDS(paste0(results_folder,save.id,"_Seurat_object_SpatialSignalingScore",spatial_network_name, "_assay_",assay,LRname,".rds"))
- spatial_all_scores<-Mer@graphs[[spatial_network_name]]$SpatialSignalingScore[[cluster_column]]
- spatial_all_scores = spatial_all_scores[spatial_all_scores$LR_comb %in% LR_comb_select,c('LR_comb',"LR_cell_comb","ScaledSpatialSignalingScore")]
- colnames(spatial_all_scores)[3] = c("ScaledSpatialSignalingScore_measured")
- spatial_all_scores$LRCC = paste0(spatial_all_scores$LR_comb,"---",spatial_all_scores$LR_cell_comb)
- spatial_all_scores_pred$LRCC = paste0(spatial_all_scores_pred$LR_comb,"---",spatial_all_scores_pred$LR_cell_comb)
- lrcc.common = intersect(spatial_all_scores$LRCC,spatial_all_scores_pred$LRCC )
- spatial_all_scores = spatial_all_scores[spatial_all_scores$LRCC %in%lrcc.common,]
- spatial_all_scores_pred = spatial_all_scores_pred[spatial_all_scores_pred$LRCC %in%lrcc.common,]
- spatial_all_scores$ScaledSpatialSignalingScore_imputed = spatial_all_scores_pred$ScaledSpatialSignalingScore[match(spatial_all_scores_pred$LRCC,spatial_all_scores$LRCC)]
- spatial_all_scores$dataset = dataset
- all_scores = rbind(all_scores,spatial_all_scores)
- }
- }
- saveRDS(all_scores,paste0(root_dir,"measured_imputed/ScaledSpatialSignalingScore_measured_vs_imputed_common_LR_0.05.rds"))
- all_scores<-readRDS(paste0(root_dir,"measured_imputed/ScaledSpatialSignalingScore_measured_vs_imputed_common_LR_0.05.rds"))
- hist(all_scores$ScaledSpatialSignalingScore_measured,breaks=100)
- cutoff = 0.0015
- all_scores_subset = all_scores[all_scores$ScaledSpatialSignalingScore_measured>cutoff & all_scores$ScaledSpatialSignalingScore_imputed>cutoff,]
- ggplot(data = all_scores_subset,aes(x=log2(ScaledSpatialSignalingScore_imputed),
- y=log2(ScaledSpatialSignalingScore_measured)))+geom_point(aes(color=dataset))+
- geom_abline(slope=1,intercept = 0)+theme_bw()+
- theme(title=element_text(size=20),axis.title= element_text(size=20),legend.text= element_text(size=20),axis.text = element_text(size=15) )
- ggsave(paste0(root_dir,"measured_imputed/log2_ScaledSpatialSignalingScore_measured_vs_imputed_color_data_cutoff_",cutoff,".png"),width = 15,height=7,units = 'in')
- cor(log2(all_scores_subset$ScaledSpatialSignalingScore_measured),log2(all_scores_subset$ScaledSpatialSignalingScore_imputed))
Spatialsignalingscore_main.R at commit 0008b95, no license · at the source
Overview
14 affiliations
- Bioinformatics Institute (BII), Agency for Science, Technology and Research (A*STAR),Singapore, Republic of Singapore
- Genome Institute of Singapore (GIS), Agency for Science Technology and Research (A*STAR),Singapore, Republic of Singapore
- Terray Therapeutics Inc., Monrovia, CA USA
- Lee Kong Chian School of Medicine, Nanyang Technological University,Singapore, Republic of Singapore
- School of Biological Sciences, Nanyang Technological University,Singapore, Republic of Singapore
- Department of Biochemistry, Yong Loo Lin School of Medicine, National University of Singapore,Singapore, Republic of Singapore
- Department of Biological Sciences, National University of Singapore,Singapore, Republic of Singapore
- School of Medicine, Nazarbayev University,Astana, Republic of Kazakhstan
- Singapore Eye Research Institute (SERI),Singapore, Republic of Singapore
- SingHealth and Duke-NUS Ophthalmology & Visual Sciences Academic Clinical Programme (EYE ACP),Singapore, Republic of Singapore
- School of Computing, National University of Singapore,Singapore, Republic of Singapore
- International Research Laboratory on Artificial Intelligence, Institute for Infocomm Research, Agency for Science, Technology and Research (A*STAR),Singapore, Republic of Singapore
- Centre for Frontier AI Research (CFAR), Agency for Science, Technology and Research (A*STAR),Singapore, Republic of Singapore
- National Cancer Centre Singapore, 30 Hospital Boulevard,Singapore, Republic of Singapore
Abstract
The abstract is not reproduced here: the paper's license (CC BY-NC-ND) does not allow it. Read it in the paper, at the publisher or on Europe PMC.
Repositories
Its files are read in the Code ↔ Paper reader above, with 10 matches between paragraphs and lines of code.
Zenodo 19229995
Availability: 1 check, the latest on 27 September 2026: the link answers (HTTP 200)
- 27 September 2026: the link answers (HTTP 200)
10 files
- Spatial signaling score/
AnalysisSpatialNetworks. , R, 65 linesR - Spatial signaling score/
CalculateSpatialSignalin , R, 167 linesgScore.R - Spatial signaling score/
DistToDataframe.R , R, 14 lines - Spatial signaling score/
FindDifferentialSpatialS , R, 126 linesignalingScore.R - Spatial signaling score/
LoadAllMetrics.R , R, 58 lines - Spatial signaling score/
Spatialsignalingscore_ma , R, 685 linesin.R - Spatial signaling score/
VisualizeS3Dotplot.R , R, 224 lines - Spatial signaling score/
create_spatial_network_f , Python, 79 linesor_touched_cells.py - Spot assigment/
Assign_spots_EDT.py , Python, 388 lines - Readme.md, Text, 8 lines
jinyueliu0/spatial-signaling-score
0008b95ed8775f1a50b48eb3051416de5e190318, 5 September 2023Availability: 1 check, the latest on 27 September 2026: the link answers
- 27 September 2026: the link answers
10 files
- Spatial signaling score/
AnalysisSpatialNetworks. , R, 65 linesR - Spatial signaling score/
CalculateSpatialSignalin , R, 167 lines, 3 matchesgScore.R - Spatial signaling score/
DistToDataframe.R , R, 14 lines - Spatial signaling score/
FindDifferentialSpatialS , R, 126 linesignalingScore.R - Spatial signaling score/
LoadAllMetrics.R , R, 58 lines - Spatial signaling score/
Spatialsignalingscore_ma , R, 685 lines, 4 matchesin.R - Spatial signaling score/
VisualizeS3Dotplot.R , R, 224 lines - Spatial signaling score/
create_spatial_network_f , Python, 79 linesor_touched_cells.py - Spot assigment/
Assign_spots_EDT.py , Python, 388 lines, 3 matches - Readme.md, Text, 8 lines
Code availability statement
The paper has a code availability statement. Its license (CC BY-NC-ND) does not allow reproducing it here; in short, from what the harvester recognized in it:
- it points to the authors' code: Zenodo 19229995
Read it in the paper: doi.org/10.1038/s41467-026-74320-5.
Tracing map
Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.
What the map holds:
- 2 repositories of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
- 18 scripts, each with its path and the digest of its content;
- 10 matches between paragraphs of the paper and lines of the code (method lexical-v1);
- neither the text of the paper nor the code itself.
Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.
Data
Datasets cited
- geo:GSE197150, at NCBI GEO; found in “Data availability”
Code and data availability statement
The paper has a code and data availability statement. Its license (CC BY-NC-ND) does not allow reproducing it here; in short, from what the harvester recognized in it:
- it points to a dataset: NCBI GEO GSE197150
- it points to the authors' code: Zenodo 19229995
Read it in the paper: doi.org/10.1038/s41467-026-74320-5.
Versions
The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.
Version 1, 27 September 2026: the first record
Recorded: type, language, journal, volume, issue, pages, dates, 15 authors, 2 keywords, 12 MeSH terms, 1 funder, 70 references.
Cite
This paper
Lin, L., Saw, T. Y., Chou, N., Goh, J. L. J., Kwa, J. E., Chock, W. K., Singhal, V., Li, Z., Huang, M. J., Ng, H. H., Khor, C. C., Kuan, H. L., Chen, K. H., Prabhakar, S., & Liu, J. (2026). Spatial architecture of autism pathogenesis reveals mosaic structural disarray during early development. Nature communications, 17(1), 7522. https://
BibTeX
@article{lin2026spatial,
author = {Lin, Li and Saw, Tzuen Yih and Chou, Nigel and Goh, Jie Lin Jolene and Kwa, Jing Eugene and Chock, Wan Kee and Singhal, Vipul and Li, Zheng and Huang, Mike J. and Ng, Huck Hui and Khor, Chiea Chuen and Kuan, Hwee Lee and Chen, Kok Hao and Prabhakar, Shyam and Liu, Jinyue},
title = {{Spatial architecture of autism pathogenesis reveals mosaic structural disarray during early development}},
journal = {Nature communications},
year = {2026},
month = jun,
volume = {17},
number = {1},
pages = {7522},
publisher = {Nature Publishing Group},
issn = {2041-1723},
doi = {10.1038/
url = {https://
pmid = {42288509},
pmcid = {PMC13408761}
}
RIS
TY - JOUR
AU - Lin, Li
AU - Saw, Tzuen Yih
AU - Chou, Nigel
AU - Goh, Jie Lin Jolene
AU - Kwa, Jing Eugene
AU - Chock, Wan Kee
AU - Singhal, Vipul
AU - Li, Zheng
AU - Huang, Mike J.
AU - Ng, Huck Hui
AU - Khor, Chiea Chuen
AU - Kuan, Hwee Lee
AU - Chen, Kok Hao
AU - Prabhakar, Shyam
AU - Liu, Jinyue
TI - Spatial architecture of autism pathogenesis reveals mosaic structural disarray during early development
T2 - Nature communications
J2 - Nat Commun
PY - 2026
DA - 2026/
VL - 17
IS - 1
SP - 7522
SN - 2041-1723
PB - Nature Publishing Group
DO - 10.1038/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.1038/
"type": "article-journal",
"title": "Spatial architecture of autism pathogenesis reveals mosaic structural disarray during early development",
"container-title": "Nature communications",
"author": [
{
"family": "Lin",
"given": "Li"
},
{
"family": "Saw",
"given": "Tzuen Yih"
},
{
"family": "Chou",
"given": "Nigel"
},
{
"family": "Goh",
"given": "Jie Lin Jolene"
},
{
"family": "Kwa",
"given": "Jing Eugene"
},
{
"family": "Chock",
"given": "Wan Kee"
},
{
"family": "Singhal",
"given": "Vipul"
},
{
"family": "Li",
"given": "Zheng"
},
{
"family": "Huang",
"given": "Mike J."
},
{
"family": "Ng",
"given": "Huck Hui"
},
{
"family": "Khor",
"given": "Chiea Chuen"
},
{
"family": "Kuan",
"given": "Hwee Lee"
},
{
"family": "Chen",
"given": "Kok Hao"
},
{
"family": "Prabhakar",
"given": "Shyam"
},
{
"family": "Liu",
"given": "Jinyue"
}
],
"container-title-short":
"volume": "17",
"issue": "1",
"page": "7522",
"DOI": "10.1038/
"PMID": "42288509",
"PMCID": "PMC13408761",
"ISSN": "2041-1723",
"publisher": "Nature Publishing Group",
"URL": "https://
"language": "en",
"issued": {
"date-parts": [
[
2026,
6,
13
]
]
}
}
The tracing map gets a citation of its own once an author has validated it and it has a DOI.
Similar papers
The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.
- [1] doi:10.1016/j.xcrm.2026.102766 [code]
- A longitudinal single-cell and spatial multiomic atlas of pediatric high-grade glioma.Journal: Cell reports. MedicineIn common: tifffile, pheatmap, Seurat, 12 other tools, genetics / omics, 6 references
- [2] doi:10.1038/s41467-026-76675-1 [code]
- Long-read proteogenomic atlas of human neuronal differentiation reveals isoform diversity informing neurodevelopmental risk mechanisms.Journal: Nature communicationsIn common: reticulate, pheatmap, Seurat, 9 other tools, autism, developmental, genetics / omics, 3 references
- [3] doi:10.21203/rs.3.rs-9676637/v1 [code]
- A Comprehensive Benchmarking of Spatial Deconvolution and Domain Detection Methods across Diverse Tissues and Spatial Transcriptomic TechnologiesJournal: Research Square (preprint)In common: reticulate, Seurat, OpenCV, 9 other tools, genetics / omics, 3 references
- [4] doi:10.1038/s42003-026-10957-8 [code]
- Brain defence by the extracellular matrix protein Cochlin.Journal: Communications biologyIn common: reticulate, pheatmap, Seurat, 11 other tools
- [5] doi:10.1186/s13059-026-04177-w [code]
- Genomic sequence evolution underlying human neocortical interareal diversification.Journal: Genome biologyIn common: reticulate, pheatmap, Seurat, 9 other tools, genetics / omics, 2 references
- [6] doi:10.1038/s41586-026-10679-1 [code]
- Cortical development dynamics across autism spectrum disorder mouse models.Journal: NatureIn common: tifffile, OpenCV, scikit-image, 5 other tools, autism, genetics / omics, 5 references
- [7] doi:10.1038/s41467-026-73416-2 [code]
- Defective ventral neurogenesis due to midfetal Chd8 mutation drives autistic-like behavior in mice.Journal: Nature communicationsIn common: OpenCV, Pillow, pandas, 3 other tools, autism, developmental, 6 references
- [8] doi:10.1002/imt2.70163 [code]
- Spatial multi-omics unveils sphingolipid metabolic reprogramming within the retinal pathological niche.Journal: iMetaIn common: pheatmap, Seurat, OpenCV, 10 other tools, genetics / omics
- [9] doi:10.1038/s41380-026-03585-5 [code]
- Multiomics analysis identifies VPA-induced changes in neural progenitor cells, ventricular-like regions, and cellular microenvironment in dorsal forebrain organoids.Journal: Molecular psychiatryIn common: reticulate, Seurat, reshape2, 3 other tools, autism, genetics / omics, 4 references
- [10] doi:10.1093/neuonc/noag128 [code]
- Spatially-resolved single-cell imaging of melanoma brain metastases identifies localized immune patterns predictive of immune checkpoint blockade response.Journal: Neuro-oncologyIn common: tifffile, pheatmap, OpenCV, 9 other tools, genetics / omics
Contribute
The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.
Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.
Claim this paper
Correct its record
Say what each link of this record is, remove the ones that are not the paper's, add the ones that are missing. The correction becomes a new version of the record, in its Versions section.
Validate its tracing map
You validate the map as this page shows it: 2 repositories of the authors' code, each at its verified commit and with its license, 18 scripts, and 10 matches between paragraphs and code (see the Code and Map sections). It then receives a DOI on Zenodo, with you (your ORCID iD) and OSCR as its creators; the code itself is not deposited.
The map's fingerprint: sha256:c2cf92f4f3f4f095…
Add the badge to its README
The badge links the code to this page. Copy one of these into the README of the paper's code: only you decide where it goes, and nothing is changed for you.
Markdown
[, paste the snippet at the top, then “Commit changes…” and, to review it first, “Create a new branch and start a pull request”. You open the pull request; OSCR asks for no permission.
Request its removal
To ask OSCR to remove this record, the copies of its authors' scripts or its tracing map, use the removal request page: signed in, you say who you are, what to remove and why, then review and confirm the request. Published rules decide every request (how).
Discussion, reproductions, activity
Discussion: questions and error reports about this paper and its code, from signed-in readers and its authors. It opens with sign-in.
Reproductions: reports from readers who ran the authors' code: what they reproduced, with which environment, commit and data. It opens with sign-in.
Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.
