Spatiotemporal brain transcriptomics reveal risk gene hot-spots in major neuropsychiatric disorders.
The 15 matches
- [1] § Results › Spatial enrichment patterns of neuropsychiatric risk gene sets implicate disease-relevant brain regions and circuits ↔ R code for data analysis.R, lines 113–194 · score 0.92 · parietal cortex, ganglionic eminence, occipital cortex, frontal cortex, brain stem, temporal cortex
- [2] § Methods › Function analysis of WGCNA module genes ↔ R code for data analysis.R, lines 458–545 · score 0.83 · enriched GO terms, clusterProfiler, compareCluster, KEGG pathway, cutoff, Module genes
- [3] § Methods › Weighted gene co-expression network (WGCNA) analysis ↔ R code for data analysis.R, lines 188–248 · score 0.81 · soft threshold power, blockwiseModules, cut height, Pearson, TOM, network
- [4] § Methods › Weighted gene co-expression network (WGCNA) analysis ↔ R code for data analysis.R, lines 741–801 · score 0.81 · soft threshold power, blockwiseModules, cut height, Pearson, TOM, network
- [5] § Methods › Statistics and reproducibility ↔ R code for data analysis.R, lines 2–62 · score 0.80 · Mann Whitney, ComplexHeatmap, remaining genes, selected gene, expression matrix, Rank Biserial
- [6] § Methods › Statistics and reproducibility ↔ R code for data analysis.R, lines 2–62 · score 0.80 · Mann Whitney, ComplexHeatmap, remaining genes, selected gene, expression matrix, Rank Biserial
- [7] § Results › Spatial enrichment patterns of neuropsychiatric risk gene sets implicate disease-relevant brain regions and circuits ↔ R code for data analysis.R, lines 64–111 · score 0.80 · parietal cortex, ganglionic eminence, occipital cortex, frontal cortex, brain stem, temporal cortex
- [8] § Methods › Function analysis of WGCNA module genes ↔ R code for data analysis.R, lines 1044–1105 · score 0.75 · clusterProfiler, compareCluster, KEGG pathway, cutoff, Module genes, enriched
- [9] § Results › Developmental expression enrichment patterns of risk gene sets align with the peak age of onset across major neuropsychiatric disorders ↔ R code for data analysis.R, lines 64–111 · score 0.70 · peak ages, early infancy, middle adulthood, early prenatal, enrichment patterns, onset
- [10] § Results › Developmental expression enrichment patterns of risk gene sets align with the peak age of onset across major neuropsychiatric disorders ↔ R code for data analysis.R, lines 64–111 · score 0.70 · peak ages, early infancy, middle adulthood, early prenatal, enrichment patterns, onset
- [11] § Methods › Risk gene sets expression enrichment analysis in the brain spatiotemporal transcriptome › Curation of genome-wide risk genes for the 15 traits ↔ R code for data analysis.R, lines 113–186 · score 0.68 · SZes, panic disorder, SZgw, date, ANO, TS
- [12] § Methods › Risk gene sets expression enrichment analysis in the brain spatiotemporal transcriptome › Curation of genome-wide risk genes for the 15 traits ↔ R code for data analysis.R, lines 113–194 · score 0.66 · SZes, panic disorder, SZgw, ANO, TS, neuroticism
- [13] § Results › Assessing the biological relevance of risk gene expression patterns using ENIGMA brain morphometry ↔ R code for data analysis.R, lines 683–739 · score 0.57 · d_icv, amyg, caud, hippo, pal, thal
- [14] § Results › Spatiotemporal enrichment patterns of risk gene sets differentiate neuropsychiatric disorder subgroups ↔ R code for data analysis.R, lines 197–235 · score 0.57 · variance explained, Principal component, Scree, rank biserial, Bar, PC
- [15] § Results › Spatiotemporal enrichment patterns of risk gene sets differentiate neuropsychiatric disorder subgroups ↔ R code for data analysis.R, lines 237–262 · score 0.51 · panic disorder, SZgw, PC4, PC1, epilepsy, PD
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 · 1,145 lines · 41 KB · CC-BY-4.0 · 9 matches
- ##Mann-Whitney U test
- # install.packages("ggcorrplot")
- # BiocManager::install("ComplexHeatmap")
- library(gmodels)
- library("data.table")
- library("dplyr")
- library(ggplot2)
- library(ggpubr)
- library(effectsize)
- library("ComplexHeatmap")
- # Mann-Whitney U test based on RPKM values ------------------------------------
- riskgene<-read.table("riskgenes.CSV",header=TRUE,sep=",",row.names=1)
- str(riskgene)
- braingene<-read.table("expression_matrix-ave.CSV",header=TRUE,sep=",",row.names=1)
- str(braingene)
- dim(braingene)
- gene <- rownames(braingene)
- length(gene)
- P_values <- data.frame()
- W<-data.frame()
- r_rank_biserial<-data.frame()
- for (i in 1:length(riskgene))
- {
- interesting_genes <- c(riskgene[, i])
- interesting_genes <- interesting_genes[interesting_genes[] != ""]
- selected_genes <- braingene[interesting_genes,]
- dim(selected_genes)
- selected_genes <- na.omit(selected_genes)
- dim(selected_genes)
- remaining_genes <-
- braingene[!rownames(braingene) %in% interesting_genes,]
- dim(remaining_genes)
- remaining_genes
- for (j in 1:524) {
- mwu_test_result <-
- wilcox.test(selected_genes[, j],
- remaining_genes[, j],
- alternative = "greater",
- verbose = FALSE)
- EFS_result <-
- cliffs_delta(
- selected_genes[, j],
- remaining_genes[, j],
- mu = 0,
- alternative = "greater",
- verbose = F
- )
- P_values[j, i] <- mwu_test_result$p.value
- r_rank_biserial[j, i] <- EFS_result$r_rank_biserial
- }
- }
- rownames(P_values)<-c(colnames(braingene))
- rownames(P_values)
- colnames(P_values)<-c(colnames(riskgene))
- colnames(P_values)
- rownames(r_rank_biserial)<-c(colnames(braingene))
- colnames(r_rank_biserial)<-c(colnames(riskgene))
- write.csv(P_values, file="P_Value.CSV", quote = F,row.names = T)
- write.csv(r_rank_biserial,file="r_rank_biserial.CSV",
- quote=F,row.names = T)
- ##complexheatmap of risk gene enrichment patterns
- brain<-read.table("brian regions.CSV",header=TRUE,sep=",")
- head(brain)
- brain_order<-brain[order(brain$column_num),]
- head(brain_order)
- data1<-read.table("r_rank_biserial.CSV",header=TRUE,sep=",",row.names=1)
- data1<-data1[brain_order$sample,]
- head(data1)
- data2<- t(data1)
- dim(data2)
- data2 <- as.matrix(data2)
- str(data2)
- row_anno <-read.table("disease_Annotation_peak age onset.CSV",header=TRUE,sep=",",row.names=1,encoding = "UTF-8")
- dim(row_anno)
- str(row_anno)
- row_anno$peak_age_onset<-factor(row_anno$peak_age_onset,
- levels = c("Y4.5","Y5.5","Y8","Y9.5","Y15.5","Y19.5","Y12.8_Y24.9","Y20.5","Childhood_Y60","Y85","Y87"))
- col_anno <-read.table("brain_region_Annotation.CSV",header=TRUE,sep=",",row.names=1)
- str(col_anno)
- col_anno<-col_anno[,-c(2:3)]
- col_anno<-col_anno[brain_order$sample,]
- head(col_anno)
- col_anno$structure<-factor(col_anno$structure,
- levels = c("frontal_cortex","parietal_cortex","temporal_cortex","occipital_cortex","ganglionic_eminence","striatum","thalamus","limbic_system","brain_stem","cerebellum"))
- col_anno$dev_stage<-factor(col_anno$dev_stage,
- levels = c("Early_prenatal","Early_mid_prenatal","Late_mid_prenatal","Late_prenatal","Early_infancy","Late_infancy","Early_childhood","Late_childhood","Adolescence","Young_adulthood","Middle_adulthood" ))
- ann_colors = list(peak_age_onset = c(Y4.5 = "#CCFFCC",Y5.5="#CCFF00", Y8="#00CC99", Y9.5="#00CC00", Y15.5="#FF99FF", Y19.5="#FF33FF",
- Y12.8_Y24.9="#00FFFF" , Y20.5="#33CCCC", Childhood_Y60="#3366CC", Y85="#333399", Y87="#111111"),
- dev_stage=c(Early_prenatal="#000000",Early_mid_prenatal="#333333",Late_mid_prenatal="#666666",Late_prenatal="#888888",Early_infancy="#DDDDDD", Late_infancy="#EEEEEE", Early_childhood="#00FFCC",Late_childhood="#00CC99",Adolescence="#FFCCFF",Young_adulthood="#33CCCC",Middle_adulthood="#333399"),
- structure= c(frontal_cortex="#FFFF00",parietal_cortex="pink",temporal_cortex="#CCFF00",occipital_cortex="orange" , limbic_system = "#CC0000", striatum = "#00CC66", thalamus = "#00FF00",brain_stem="#CC00FF", ganglionic_eminence="blue", cerebellum = "#330066")
- )
- pdf(file = "complexheatmap-r_rank_biserial.pdf", width = 12, height = 8)
- pheatmap(data2, scale = "row",show_rownames = T,
- clustering_method="ward.D2",
- show_colnames = F,
- cluster_cols=F,cluster_rows=F,drop_levels=T,
- col = colorRampPalette(c("blue","white","red"))(100),
- annotation_col = col_anno,
- annotation_row = row_anno,
- annotation_colors = ann_colors,
- heatmap_legend_param = list(title = "normalized r") ,
- annotation_names_row = T,
- annotation_names_col = T ,
- column_title = NULL
- )
- dev.off()
- # # FC-other structures(without BS),pairwise t-test -----------------------------
- library(dplyr)
- library(ggplot2)
- library(rstatix)
- library(ggpubr)
- setwd("Major 15 disorder merged gene-RPKM-ave")
- data1<-read.csv("combine_r_rank_biserial-11structure-scaled-line.CSV",header=TRUE,sep=",")
- str(data1)
- data1$structure <- factor(data1$structure,
- levels = c("frontal_cortex", "parietal_cortex", "temporal_cortex", "occipital_cortex",
- "ganglionic_eminence","striatum","thalamus","amygdala","brain_stem","hippocampus","cerebellum"))
- data1$disorder <- factor(data1$disorder,
- levels = c("Neuroticism","BIP","TS", "SZes","IQ", "ASD","ADHD","ANO","PanicDisorder", "OCD","AD", "Epilepsy", "PD","MDD", "SZgw"))
- data1 <- data1[data1$structure != "brain_stem", ]
- df_summary <- data1 %>%
- group_by(disorder, structure) %>%
- summarise(
- mean_value = mean(r, na.rm = TRUE),
- sd_value = sd(r, na.rm = TRUE),
- se_value = sd(r, na.rm = TRUE) / sqrt(n()),
- n = n(),
- .groups =NULL
- )
- df_summary
- stat_res <- data1 %>%
- group_by(disorder) %>%
- pairwise_t_test(
- r ~ structure,
- ref.group = "frontal_cortex",
- p.adjust.method = "fdr"
- )
- stat_res
- stat_frontal <- stat_res %>%
- filter(group1 == "frontal_cortex")
- stat_frontal <- stat_frontal %>%
- mutate(stars = case_when(
- p.adj < 0.001 ~ "***",
- p.adj < 0.01 ~ "**",
- p.adj < 0.05 ~ "*",
- TRUE ~ ""
- ))
- write.csv(stat_frontal,file="stat_frontal_noBS.CSV", quote = F,row.names = F)
- plot_data <- df_summary %>%
- left_join(stat_frontal,
- by = c("structure" = "group2", "disorder")) %>%
- mutate(y_pos = mean_value + se_value + 0.02)
- ggplot() +
- # dot
- geom_jitter(data = data1,
- aes(x = structure, y = r),
- width = 0.15, height = 0.3,
- size = 0.1, alpha = 0.3, color = "black") +
- # bar
- geom_col(data = df_summary,
- aes(x = structure, y = mean_value, fill = structure),
- width = 0.7, alpha = 0.9) +
- # SE
- geom_errorbar(data = df_summary,
- aes(x = structure,
- ymin = mean_value - se_value,
- ymax = mean_value + se_value),
- width = 0.25, linewidth = 0.2) +
- # sig
- geom_text(data = plot_data,
- aes(x = structure, y = y_pos, label = stars),
- size = 3, color = "red", vjust = 0.3) +
- facet_grid(rows = vars(disorder), scales = "free_y") +
- scale_y_continuous(n.breaks =3) +
- theme_bw() +
- theme(
- strip.text.y = element_text(angle = 0, size =7),
- axis.text.x = element_text(angle = 30, size = 8,hjust = 0.9),
- axis.text.y = element_text(size = 5),
- ) +
- labs(y = "Mean ± SE")
- # ##PCA analysis -----------------------------------------------------------------
- library(ggplot2)
- library(ggrepel)
- data1<-read.table("r_rank_biserial_rpkm-ave.CSV",header=TRUE,sep=",",row.names=1)
- head(data1)
- data2<- scale(data1)
- data2<- t(data2)
- disor<-rownames(data2)
- disor
- mean(data2[,3])
- pca_result <- prcomp(data2,center=T,scale=T)
- pca_result
- summary(pca_result)
- pca_result$x
- screeplot(pca_result)
- plot(pca_result, type = "barplot")
- pca_result$x
- rownames(pca_result$x)
- var_explained <- pca_result$sdev^2 / sum(pca_result$sdev^2)
- df_var <- data.frame(
- PC = paste0("PC", 1:length(var_explained)),
- Variance = var_explained
- )
- var_explained
- df_var$PC <- factor(df_var$PC, levels = df_var$PC[order(df_var$Variance, decreasing = TRUE)])
- # Scree plot
- ggplot(df_var, aes(x = PC, y = Variance)) +
- geom_bar(stat = "identity") +
- geom_line(aes(group = 1)) +
- geom_point(size = 2) +
- ylab("Proportion of Variance Explained") +
- xlab("Principal Components") +
- theme_bw(base_size = 14) +
- theme(
- axis.text.x = element_text(angle = 45, hjust = 1)
- )
- ##disorder order
- disor<-rownames(pca_result$x)
- disor
- ##PCA-15 disorder dot plot
- pca_df <- data.frame(
- PC1 = pca_result$x[,1],
- PC4 = pca_result$x[,4]
- )
- pca_df
- pca_result$x
- write.csv(pca_result$x,file="PCA result.csv")
- ggplot(pca_df, aes(PC1, PC4, color =disor)) +
- geom_point(size = 3) +
- geom_text_repel(
- aes(label = disor),
- size = 3,
- max.overlaps = 20,
- box.padding = 0.5,
- point.padding = 0.3,
- min.segment.length = 0.2,
- segment.color = "grey50"
- )+
- scale_color_manual(values = c("IQ"="darkgrey", "ASD"="red","TS" ="firebrick", "Neuroticism"="darkgreen", "ADHD"="#FFdd22", "OCD" ="#0099FF", "ANO" = "#00CC00","PanicDisorder" ="#FF99FF", "BIP"="#FF33FF","MDD"= "orange", "SZes"="#33CCCC", "SZgw"="blue",
- "Epilepsy"= "#3366CC", "AD"="purple", "PD"="#111111"))+
- theme_bw()
- # ##corr::PCA component and spatiotemporal variables --------------------------------------------------
- library(dplyr)
- library(ggplot2)
- scaled<-read.csv("combine_r_rank_biserial-11structure-scaled.CSV",header=TRUE,sep=",")
- str(scaled)
- head(scaled)
- ##disorder order
- disor<-rownames(pca_result$x)
- disor
- scaled$structure <- factor(scaled$structure,
- levels = c("frontal_cortex", "parietal_cortex", "temporal_cortex", "occipital_cortex",
- "ganglionic_eminence","striatum","thalamus","amygdala","hippocampus","brain_stem","cerebellum"))
- scaled_summary <- scaled %>%
- group_by(structure) %>%
- summarise(across(disor, mean, na.rm = TRUE))
- scaled_summary_t<-t(scaled_summary)
- scaled_summary_t
- colnames(scaled_summary_t)
- colnames(scaled_summary_t) <- as.character(scaled_summary_t[1, ])
- scaled_summary_t
- scaled_summary_t <- scaled_summary_t[-1, ] # 删除第一行
- scaled_summary_t
- write.csv(scaled_summary_t,file="scaled_15disorder_structure summary.CSV",quote=F,row.names = T)
- scaled_summary<-read.csv("scaled_15disorder_structure summary.CSV",header=T,sep=",",row.names = 1)
- rownames(scaled_summary)
- colnames(scaled_summary)
- p2 <- pca_result$x[, c(1:4), drop = FALSE]
- df_pca_asso<-cbind(p2,scaled_summary)
- df_pca_asso
- help(rcorr)
- library(Hmisc)
- res<-rcorr(as.matrix(df_pca_asso),type="spearman")
- res
- R <- res$r
- P <- res$P
- vars <- colnames(df_pca_asso)
- vars
- library(tidyverse)
- n <- length(vars)
- upper_idx <- upper.tri(P, diag = FALSE)
- p_unique <- P[upper_idx]
- p_unique
- p_unique <- p_unique[!is.na(p_unique)]
- p_unique
- # FDR
- p_unique_fdr <- p.adjust(p_unique, method = "fdr")
- P_fdr <- matrix(NA, nrow = n, ncol = n)
- colnames(P_fdr) <- rownames(P_fdr) <- vars
- P_fdr[upper_idx] <- p_unique_fdr
- P_fdr[lower.tri(P_fdr)] <- t(P_fdr)[lower.tri(P_fdr)]
- diag(P_fdr) <- NA
- R
- P_fdr
- df_plot <- R %>%
- as.data.frame() %>%
- rownames_to_column("Var1") %>%
- pivot_longer(-Var1, names_to = "Var2", values_to = "cor") %>%
- left_join(
- P_fdr %>%
- as.data.frame() %>%
- rownames_to_column("Var1") %>%
- pivot_longer(-Var1, names_to = "Var2", values_to = "p"),
- by = c("Var1", "Var2")
- )
- df_plot$Var1 <- factor(df_plot$Var1, levels = vars)
- df_plot$Var2 <- factor(df_plot$Var2, levels = vars)
- df_plot
- ##dot plot
- df_plot <- df_plot %>%
- mutate(
- abs_cor = abs(cor),
- logp = -log10(p + 1e-10)
- )
- df_plot
- df_plot <- df_plot %>%
- mutate(
- p_fdr = as.vector(P_fdr[cbind(
- match(Var1, vars),
- match(Var2, vars)
- )]),
- sig = case_when(
- p_fdr < 0.001 ~ "***",
- p_fdr < 0.01 ~ "**",
- p_fdr < 0.05 ~ "*",
- TRUE ~ ""
- )
- )
- df_plot
- library(ggplot2)
- # bubble plot
- ggplot(df_plot, aes(Var1, Var2)) +
- geom_point(aes(size = logp,
- color = cor)) +
- geom_text(aes(label = sig), size = 4, vjust = 0.7) + # 星号标注
- scale_color_gradient2(low = "blue", mid = "white", high = "red", midpoint = 0,
- limits = range(df_plot$cor, na.rm = TRUE)) +
- scale_size(range = c(0, 10)) +
- scale_alpha(range = c(0.2, 1)) +
- theme_minimal()+
- theme(
- axis.text.x = element_text(angle = 45, hjust = 1),
- panel.grid = element_blank()
- ) +
- labs(
- size = "-log10(p)",
- color = "r",
- x = NULL, y = NULL,
- title = "Cor: PC1-4/ structures"
- )
- ## PC1 and variables
- library(dplyr)
- library(ggplot2)
- # ## PC and developmental stages----------------------------------------------------
- scaled<-read.csv("combine_r_rank_biserial-10structure-scaled.CSV",header=TRUE,sep=",")
- str(scaled)
- head(scaled)
- scaled$dev_stage <- factor(scaled$dev_stage,
- levels = c("Early_prenatal" ,"Early_mid_prenatal","Late_mid_prenatal","Late_prenatal", "Early_infancy","Late_infancy", "Early_childhood", "Late_childhood", "Adolescence",
- "Young_adulthood","Middle_adulthood"))
- ##disorder
- disor<-rownames(pca_result$x)
- disor
- scaled_summary <- scaled %>%
- group_by(dev_stage) %>%
- summarise(across(disor, mean, na.rm = TRUE))
- scaled_summary_t<-t(scaled_summary)
- scaled_summary_t
- colnames(scaled_summary_t)
- colnames(scaled_summary_t) <- as.character(scaled_summary_t[1, ])
- scaled_summary_t
- scaled_summary_t <- scaled_summary_t[-1, ]
- scaled_summary_t
- write.csv(scaled_summary_t,file="scaled_15disorder_dev_stage summary.CSV",quote=F,row.names = T)
- scaled_summary<-read.csv("scaled_15disorder_dev_stage summary.CSV",header=T,sep=",",row.names = 1)
- rownames(scaled_summary)
- colnames(scaled_summary)
- p2 <- pca_result$x[, c(1:4), drop = FALSE]
- df_pca_asso<-cbind(p2,scaled_summary)
- df_pca_asso
- library(Hmisc)
- res<-rcorr(as.matrix(df_pca_asso),type = "spearman")
- res
- R <- res$r
- P <- res$P
- vars <- colnames(df_pca_asso)
- vars
- library(tidyverse)
- n <- length(vars)
- upper_idx <- upper.tri(P, diag = FALSE)
- p_unique <- P[upper_idx]
- p_unique
- p_unique <- p_unique[!is.na(p_unique)]
- p_unique
- # FDR
- p_unique_fdr <- p.adjust(p_unique, method = "fdr")
- P_fdr <- matrix(NA, nrow = n, ncol = n)
- colnames(P_fdr) <- rownames(P_fdr) <- vars
- P_fdr[upper_idx] <- p_unique_fdr
- P_fdr[lower.tri(P_fdr)] <- t(P_fdr)[lower.tri(P_fdr)]
- diag(P_fdr) <- NA
- R
- P_fdr
- df_plot <- R %>%
- as.data.frame() %>%
- rownames_to_column("Var1") %>%
- pivot_longer(-Var1, names_to = "Var2", values_to = "cor") %>%
- left_join(
- P_fdr %>%
- as.data.frame() %>%
- rownames_to_column("Var1") %>%
- pivot_longer(-Var1, names_to = "Var2", values_to = "p"),
- by = c("Var1", "Var2")
- )
- df_plot$Var1 <- factor(df_plot$Var1, levels = vars)
- df_plot$Var2 <- factor(df_plot$Var2, levels = vars)
- df_plot
- df_plot <- df_plot %>%
- mutate(
- abs_cor = abs(cor),
- logp = -log10(p + 1e-10) # 避免 log(0)
- )
- df_plot
- df_plot <- df_plot %>%
- mutate(
- p_fdr = as.vector(P_fdr[cbind(
- match(Var1, vars),
- match(Var2, vars)
- )]),
- sig = case_when(
- p_fdr < 0.001 ~ "***",
- p_fdr < 0.01 ~ "**",
- p_fdr < 0.05 ~ "*",
- TRUE ~ ""
- )
- )
- ggplot(df_plot, aes(Var1, Var2)) +
- geom_point(aes(size = logp,
- color = cor)) +
- geom_text(aes(label = sig), size = 4, vjust = 0.7) + # 星号标注
- scale_color_gradient2(low = "blue", mid = "white", high = "red", midpoint = 0,
- limits = range(df_plot$cor, na.rm = TRUE)) +
- scale_size(range = c(0, 10)) +
- scale_alpha(range = c(0.2, 1)) +
- theme_minimal()+
- theme(
- axis.text.x = element_text(angle = 45, hjust = 1),
- panel.grid = element_blank()
- ) +
- labs(
- size = "-log10(p)",
- color = "r",
- x = NULL, y = NULL,
- title = "Cor: PC1-4/ dev_stage"
- )
- # ### PC and single variable ----------------------------------------------------
- ## PC2 and late infancy
- library(dplyr)
- library(ggplot2)
- scaled<-read.csv("combine_r_rank_biserial-10structure-scaled.CSV",header=TRUE,sep=",")
- str(scaled)
- head(scaled)
- scaled$dev_stage2 <- ifelse(scaled$dev_stage == "Late_infancy",
- "Late_infancy",
- "other")
- scaled$dev_stage2 <- factor(scaled$dev_stage2,
- levels = c("Late_infancy", "other"))
- summary(scaled$dev_stage2)
- disor<-rownames(pca_result$x)
- disor
- scaled_summary <- scaled %>%
- group_by(dev_stage2) %>%
- summarise(across(disor, mean, na.rm = TRUE))
- scaled_summary_t<-t(scaled_summary)
- scaled_summary_t
- colnames(scaled_summary_t)
- colnames(scaled_summary_t) <- as.character(scaled_summary_t[1, ])
- scaled_summary_t
- scaled_summary_t <- scaled_summary_t[-1, ]
- scaled_summary_t
- write.csv(scaled_summary_t,file="scaled_15disorder_late infancy summary.CSV",quote=F,row.names = T)
- scaled_summary<-read.csv("scaled_15disorder_late infancy summary.CSV",header=T,sep=",",row.names = 1)
- rownames(scaled_summary)
- colnames(scaled_summary)
- as.data.frame(pca_result$x[,1])
- df_pca_asso<-cbind(pca_result$x[,1:4],scaled_summary)
- df_pca_asso$PC1
- library(Hmisc)
- res<-rcorr(as.matrix(df_pca_asso))
- res
- disor
- ##"Cor: PC2/ Late_infancy enrichment"
- library(ggpubr)
- ggplot(data = df_pca_asso, aes(x = PC2, y =Late_infancy )) +
- geom_point() +
- geom_smooth(method = "lm", se = TRUE, color = "red") +
- stat_cor(method = "spearman",label.x.npc = 0.1, label.y.npc = 1.0,) +
- labs(title = "Cor: PC2/ Late_infancy",
- x = "PC2",
- y = "Late_infancy enrichment") +
- theme_minimal()+
- geom_text_repel(
- aes(label = disor),
- size = 3,
- max.overlaps = 20,
- box.padding = 0.5,
- point.padding = 0.3,
- min.segment.length = 0.2,
- segment.color = "grey50"
- )
- ## PC4 and cerebellum
- library(dplyr)
- library(ggplot2)
- scaled<-read.csv("combine_r_rank_biserial-11structure-scaled.CSV",header=TRUE,sep=",")
- str(scaled)
- head(scaled)
- scaled$structure2 <- ifelse(scaled$structure == "cerebellum",
- "cerebellum",
- "other")
- scaled$structure2 <- factor(scaled$structure2,
- levels = c("cerebellum", "other"))
- summary(scaled$structure2)
- disor<-rownames(pca_result$x)
- disor
- scaled_summary <- scaled %>%
- group_by(structure2) %>%
- summarise(across(disor, mean, na.rm = TRUE))
- scaled_summary_t<-t(scaled_summary)
- scaled_summary_t
- colnames(scaled_summary_t)
- colnames(scaled_summary_t) <- as.character(scaled_summary_t[1, ])
- scaled_summary_t
- scaled_summary_t <- scaled_summary_t[-1, ]
- scaled_summary_t
- write.csv(scaled_summary_t,file="scaled_15disorder_cerebellum summary.CSV",quote=F,row.names = T)
- scaled_summary<-read.csv("scaled_15disorder_cerebellum summary.CSV",header=T,sep=",",row.names = 1)
- rownames(scaled_summary)
- colnames(scaled_summary)
- as.data.frame(pca_result$x[,1])
- df_pca_asso<-cbind(pca_result$x[,1:4],scaled_summary)
- df_pca_asso$PC1
- library(Hmisc)
- res<-rcorr(as.matrix(df_pca_asso))
- res
- disor
- ##"Cor: PC4/ 和cerebellum enrichment"
- library(ggpubr)
- ggplot(data = df_pca_asso, aes(x = PC4, y =cerebellum )) +
- geom_point() +
- geom_smooth(method = "lm", se = TRUE, color = "red") +
- stat_cor(method = "spearman",label.x.npc = 0.2, label.y.npc = 1.0,) +
- labs(title = "Cor: PC4/ cerebellum enrichment",
- x = "PC4",
- y = "cerebellum enrichment") +
- theme_minimal()+
- geom_text_repel(
- aes(label = disor),
- size = 3,
- max.overlaps = 20,
- box.padding = 0.5,
- point.padding = 0.3,
- min.segment.length = 0.2,
- segment.color = "grey50"
- )
- # ##ENIGMA-AHBA enrichment correlations ------------------------
- library("data.table")
- library("dplyr")
- library(ggplot2)
- library(ggpubr)
- brainregion <-read.csv("brain_region_Annotation-6-fine.CSV",header=TRUE,sep=",")
- colnames(brainregion)
- head(brainregion)
- disord <-read.csv("combine_r_rank_biserial_rpkm-ave.CSV",header=TRUE,sep=",")
- head(disord)
- Disor_region_anno<-dplyr::left_join(disord,brainregion,by="X")
- head(Disor_region_anno)
- Disor_region_anno_enig <- Disor_region_anno %>%
- filter(!is.na(Structure_comn)) %>%
- group_by(Structure_comn) %>%
- summarise(across(all_of(colnames(Disor_region_anno)[-c(1,17:21)]), ave))
- Disor_region_anno_enig<- unique(Disor_region_anno_enig, fromLast = TRUE)
- Disor_region_anno_enig
- write.csv(Disor_region_anno_enig, file="Disor_region_anno.CSV", quote = F,row.names = T)
- # ##ASD ------------------------------------------------------------------
- enig_sub <-read.csv("asd_meta-analysis_case-controls_CortThick.CSV",header=TRUE,sep=",")
- enig_tck <-read.csv("asd_meta-analysis_case-controls_SubVol.CSV",header=TRUE,sep=",")
- enig<-rbind(enig_sub[,c(2:3,9)],enig_tck[,c(2:3,9)])
- enig$Structure<-sub('L_','',enig$Structure,ignore.case = F)
- enig$Structure<-sub('R_','',enig$Structure,ignore.case = F)
- enig$Structure<-sub('LL','Ll',enig$Structure,ignore.case = F)
- enig$Structure<-sub('RL','Rl',enig$Structure,ignore.case = F)
- enig$Structure<-sub('L','',enig$Structure,ignore.case = F)
- enig$Structure<-sub('R','',enig$Structure,ignore.case = F)
- enig
- enig2 <- enig %>%
- group_by(Structure) %>%
- summarise( d_icv_ave = mean(d_icv, na.rm = TRUE))
- print(enig2,n=40)
- region_enig <-read.csv("brain region-enigma.CSV",header=TRUE,sep=",")
- region_enig
- enig_comn<-dplyr::left_join(region_enig,enig2,by="Structure")
- enig_comn
- enig_merge<-dplyr::left_join(enig_comn,Disor_region_anno_enig,by="Structure_comn")
- str(enig_merge)
- enig_merge2 <- enig_merge %>%
- filter(!is.na(Structure_comn)) %>%
- group_by(Structure_comn) %>%
- summarise(across(all_of(colnames(enig_merge)[c(4:19)]), ave))
- enig_merge2<- unique(enig_merge2, fromLast = TRUE)
- enig_merge3<-enig_merge2 %>%
- filter(!is.na(d_icv_ave))
- ##dotplot
- ggplot(data = enig_merge3, aes(x = d_icv_ave, y =ASD )) +
- geom_point() +
- geom_smooth(method = "lm", se = TRUE, color = "red") +
- stat_cor(method = "spearman",label.x.npc = 'left', label.y.npc = "top",) +
- labs(title = "Correlation: brain MRI changes/ risk gene overexpression",
- x = "ASD_case-controls-d_icv",
- y = "ASD gene overexpression (rank-biserial)") +
- theme_minimal()+
- geom_text(
- data = subset(enig_merge3, Structure_comn %in% c("pal", "thal", "precuneus","lingual","caud", "hippo",
- "amyg","cuneus","put")),
- aes(label = Structure_comn),
- vjust = -0.5, # 标签垂直偏移
- hjust = 0.1 # 标签水平偏移
- )
- # WGCNA -----------------------------------------------------------------
- # BiocManager::install("WGCNA")
- # BiocManager::install("preprocessCore")
- library("WGCNA")
- library("glue")
- ## export dir
- outdir <- "C:/WGCNA"
- dir.create(file.path(outdir), showWarnings = FALSE)
- data1<-read.table("expression matrix_RPKM.CSV",header=TRUE,sep=",",row.names=1)
- dim(data1)
- row_sums <- rowSums(data1)
- sort(row_sums)[1:10]
- # delete very low expression genes
- row_sums
- data2 <- data1[row_sums >10, ]
- dim(data2)
- data2<-t(data2)
- head(data2)
- ## Plot a sample dendrogram
- setwd("C:/WGCNA")
- sampleTree <- hclust(dist(data2), method = "average")
- pdf(file = "Sample_dendrogram_rm_outlier.pdf", width = 12, height = 9)
- par(cex = 0.6)
- par(mar = c(2,5,5,1))
- plot(sampleTree, main = "Sample clustering to detect outliers",
- sub="", xlab="", cex.lab = 1.5, cex.axis = 1.5, cex.main = 2)
- abline(h = 100000, col = "red")
- dev.off()
- ## clust 1 contains the samples we want to keep
- clust <- cutreeStatic(sampleTree, cutHeight = 100000, minSize = 5)
- clust
- keepSamples <- (clust != 0)
- notkeepSamples <- clust[clust == 0]
- length(notkeepSamples)
- datExpr <- data2[keepSamples, ]
- str(datExpr)
- keepSamples
- write.csv(datExpr, file = "datExpr.csv")
- ## Determination of the soft-thresholding power====================================================================================
- powers <- c(1:20) # often 20 in practice
- sft <- pickSoftThreshold(datExpr, powerVector = powers, RsquaredCut = 0.85)
- sft
- pdf("Soft_Threshold.pdf")
- par(mfrow = c(1, 2))
- plot(sft$fitIndices[, 1], -sign(sft$fitIndices[, 3]) * sft$fitIndices[, 2],
- xlab = "Soft Threshold (power)", ylab = "SFT, signed R^2",
- type = "n", main = paste("Scale independence"))
- text(sft$fitIndices[, 1], -sign(sft$fitIndices[, 3]) * sft$fitIndices[, 2],
- labels = powers, col = "red")
- abline(h = 0.85, col = "red") ## 阈值线
- plot(sft$fitIndices[, 1], sft$fitIndices[, 5], type = "n",
- xlab = "Soft Threshold (power)", ylab = "Mean Connectivity",
- main = paste("Mean connectivity"))
- text(sft$fitIndices[, 1], sft$fitIndices[, 5],
- labels = powers, col = "red")
- dev.off()
- ## Obtain an appropriate soft-threshold
- power <- sft$powerEstimate
- if (is.na(power))
- {
- nSamples <- ncol(datExpr)
- power <- ifelse(nSamples < 20, 9, ifelse(nSamples < 30, 8, ifelse(nSamples < 40, 7, 6)))
- }
- power
- #Module identification====================================================================================
- module_detect_dir <- "C:/WGCNA"
- dir.create(file.path(module_detect_dir), showWarnings = FALSE)
- enableWGCNAThreads(nThreads = 2)
- str(datExpr)
- nGenes <- ncol(datExpr)
- block_thred <- 40000
- if(nGenes <= block_thred){
- net <- blockwiseModules(datExpr, corType = "pearson", maxBlockSize = 1.1 * nGenes,
- networkType = "unsigned", power = power, minModuleSize = 40,
- mergeCutHeight = 0.25, numericLabels = TRUE, saveTOMs = TRUE,
- pamRespectsDendro = FALSE, saveTOMFileBase = glue("{module_detect_dir}/TOM"))
- } else {
- net <- blockwiseModules(datExpr, corType = "pearson", maxBlockSize = block_thred,
- networkType = "unsigned", power = power, minModuleSize = 40,
- mergeCutHeight = 0.25, numericLabels = TRUE, saveTOMs = TRUE,
- pamRespectsDendro = FALSE, saveTOMFileBase = glue("{module_detect_dir}/TOM"))
- }
- moduleLables <- net$colors
- moduleColors <- labels2colors(moduleLables)
- moduleLables
- # #Extract the whole-genome module color table--------------------------------------
- str(moduleLables)
- head(moduleLables)
- genome_module<-cbind(moduleLables,moduleColors)
- genome_module<-as.data.frame(genome_module)
- factor_modules<-factor(genome_module$moduleColors)
- dummy_modules<-model.matrix(~factor(factor_modules)-1)
- str(dummy_modules)
- genome_module_dummy<-cbind(genome_module,dummy_modules)
- colnames(genome_module_dummy) <- gsub("factor\\(factor_modules\\)", "", colnames(genome_module_dummy))
- write.csv(genome_module_dummy, file = glue("{module_detect_dir}/genome_module_dummy.csv"), row.names = TRUE)
- ## save the results
- MEs <- net$MEs
- geneTree <- net$dendrograms[[1]]
- save(MEs, moduleLables, moduleColors, geneTree, net,
- file = glue("{module_detect_dir}/networkConstruction_and_modules.RData"))
- ## Plot the clustering tree and co-expression modules
- blocks <- length(unique(net$blocks))
- if(blocks == 1){
- pdf(glue("{module_detect_dir}/Gene_Cluster_Dendrogram.pdf"))
- plotDendroAndColors(net$dendrogram[[1]], moduleColors[net$blockGenes[[1]]],
- groupLabels = "Module colors", dendroLabels = FALSE,
- hang = 0.03, addGuide = TRUE, guideHang = 0.05)
- dev.off()
- } else {
- pdf(glue("{module_detect_dir}/Gene_Cluster_Dendrogram.pdf"))
- for (i in 1:blocks){
- plotDendroAndColors(net$dendrogram[[i]], moduleColors[net$blockGenes[[i]]],
- groupLabels = "Module colors",
- main = glue("Gene dendrogram and module colors in block {i}"),
- dendroLabels = FALSE,
- hang = 0.03, addGuide = TRUE, guideHang = 0.05)
- }
- dev.off()
- }
- # Co-expression network visualization
- dissTOM <- 1 - TOMsimilarityFromExpr(datExpr, power = power)
- set.seed(123)
- select <- sample(nGenes, size = as.numeric(400))
- selectTOM <- dissTOM[select, select]
- selectColors <- moduleColors[select]
- selectTree <- hclust(as.dist(selectTOM), method = "average")
- plotDiss = selectTOM^7
- diag(plotDiss) = NA
- pdf(glue("{outdir}/Network_heatmap_plot_selectGenes.pdf"))
- TOMplot(plotDiss, selectTree, selectColors, main = "Network heatmap plot, selected genes", col = heat.colors(12))
- dev.off()
- # compute module eigengenes
- MEs0 <- moduleEigengenes(datExpr, moduleColors)$eigengenes
- MEs0
- MEsCol <- orderMEs(MEs0)
- str(MEsCol)
- write.csv(MEsCol,file=glue("{module_detect_dir}/mescol.csv"), row.names = T, quote = FALSE)
- MEsCol <- read.csv(glue("{module_detect_dir}/mescol.csv"), sep=",", row.names = 1)
- MEsCol
- #=## Phenotypic data association analysis - ====================================================================================
- ## Read phenotypic data
- data1 <- read.csv("brian regions-wgcna.csv", sep=",", row.names = 1)
- allTraits<-data1[,1:3]
- str(allTraits)
- Sample <- rownames(datExpr)
- str(Sample)
- traitRows <- match(Sample, rownames(allTraits))
- traitRows
- datTraits <- data.frame(allTraits[traitRows, ])
- table(rownames(datTraits) == rownames(datExpr))
- dev_stage<-factor(datTraits$dev_stage)
- coarse_structure<-factor(datTraits$coarse_structure)
- dummy_dev<-model.matrix(~factor(dev_stage)-1)
- dummy_structure<-model.matrix(~factor(coarse_structure)-1)
- str(dummy_dev)
- str(dummy_structure)
- # regression analysis for 41 MEs -----------------------------------------------------
- library(dplyr)
- str(MEsCol)
- head(dummy_structure)
- MEsColall<-cbind(MEsCol,dummy_structure,dummy_dev)
- write.csv(MEsColall,file=glue("{module_detect_dir}/MEsColall-21Var.csv"), row.names = T, quote = FALSE)
- PValues<-data.frame(matrix(nrow = 18, ncol = length(MEsCol)))
- BS<-data.frame(matrix(nrow = 18, ncol = length(MEsCol)))
- str(BS)
- colnames(MEsCol)
- for (i in 1:length(MEsCol))
- {
- formula <- as.formula(paste(colnames(MEsCol)[i], "~ dummy_structure+ dummy_dev"))
- model <- lm(formula, data = MEsColall)
- summary(model)
- # 进行其他处理,如汇总结果等
- PValue<-summary(model)$ coefficients[, "Pr(>|t|)"]
- B<-summary(model)$coefficients[,"Estimate"]
- PValues[,i]<-unname(PValue)
- BS[,i]<-unname(B)
- }
- str(PValues)
- head(PValues)
- colnames(PValues)<-colnames(MEsCol)
- colnames(BS)<-colnames(MEsCol)
- rownames(PValues)<-names(PValue)
- rownames(BS)<-names(PValue)
- names(PValue)
- head(BS)
- tBS<-t(BS)
- tPValues<-t(PValues)
- colnames(tPValues) <- gsub("dummy_devfactor\\(dev_stage\\)", "", colnames(tPValues))
- colnames(tPValues) <- gsub("dummy_structurefactor\\(coarse_structure\\)", "", colnames(tPValues))
- colnames(tBS) <- gsub("dummy_devfactor\\(dev_stage\\)", "", colnames(tBS))
- colnames(tBS) <- gsub("dummy_structurefactor\\(coarse_structure\\)", "", colnames(tBS))
- write.csv(tBS, file = glue("{module_detect_dir}/structure—dev-covariate-regression_B-18var.CSV"),row.names = T)
- write.csv(tPValues, file = glue("{module_detect_dir}/structure—dev-covariate-regression_PV-18var.csv"), row.names = T, quote = FALSE)
- ## Select the modules with most significant spatiotemporal enrichment (at least one regression coefficient greater than 0.05).
- library("WGCNA")
- library("glue")
- tBS<-read.csv(glue("{module_detect_dir}/structure—dev-covariate-regression_B-18var.CSV"), check.names = FALSE, sep=",", row.names = 1)
- tPValues<-read.csv(glue("{module_detect_dir}/structure—dev-covariate-regression_PV-18var.CSV"), check.names = FALSE,sep=",", row.names = 1)
- tBS<- as.matrix(tBS)
- tPValues<- as.matrix(tPValues)
- colnames(tBS)
- rownames(tBS)
- #(Intercept)
- tBS2<-tBS[,c("(Intercept)","Neocortex","Striatum","Ganglionic_eminence","Amygdala",
- "Hippocampus","Brain_stem","Cerebellum","Early prenatal", "Early mid-prenatal", "Late mid-prenatal","Late prenatal","Early infancy","Late infancy","Early childhood","Late childhood","Adolescence","Middle adulthood")]
- tPValues2<-tPValues[,c("(Intercept)","Neocortex","Striatum","Ganglionic_eminence","Amygdala",
- "Hippocampus","Brain_stem","Cerebellum","Early prenatal", "Early mid-prenatal", "Late mid-prenatal","Late prenatal","Early infancy","Late infancy","Early childhood","Late childhood","Adolescence","Middle adulthood")]
- colnames(tBS2)[1] <- "Tha | Young Adult"
- colnames(tPValues2)[1] <- "Tha | Young Adult"
- head(tPValues2)
- ##FDR ------------------------------------------------
- p_adj_by_disease <- apply(tPValues2, 2, p.adjust, method = "BH")
- p_adj_by_disease
- write.csv(p_adj_by_disease, file="structure—dev-covariate-regression_PV-18var-P-41M-FDR.CSV", quote = F,row.names = T)
- ##module with MAX B>0.05 --------------------------------------------------
- threshold<-0.05
- threshold
- tBS2_sig <- tBS2[apply(tBS2, 1, max) > threshold, ]
- str(tBS2_sig)
- rownames(tBS2_sig)
- p_adj_fdr<-p_adj_by_disease[ rownames(tBS2_sig),]
- write.csv(tBS2_sig, file = glue("{module_detect_dir}/structure—dev-covariate-regression_B-18var_B大于0.05ME.CSV"),row.names = T)
- write.csv(p_adj_fdr, file = glue("{module_detect_dir}/structure—dev-covariate-regression_PV-18var_B大于0.05ME-fdr.csv"), row.names = T, quote = FALSE)
- ### textMatrix
- textMatrix <-signif(tBS2_sig, 1)
- textMatrix[abs(tBS2_sig) <= 0.05] <- ""
- textMatrix[p_adj_fdr >= 0.05] <- ""
- textMatrix
- dim(textMatrix) <- dim(tBS2_sig)
- # heatmap
- pdf(glue("{outdir}/Module-trait_relationship_dev_str_covari-18var-B0.05-fdr0.05.pdf"), width = 8, height =10)
- par(mar = c(9, 9, 3, 3),cex.main = 2)
- labeledHeatmap(Matrix = tBS2_sig, xLabels = colnames(tBS2_sig), yLabels = rownames(tBS2_sig),
- ySymbols = rownames(tBS2_sig), colorLabels = FALSE, colors = blueWhiteRed(50),
- cex.lab=1.0,
- textMatrix = textMatrix, setStdMargins = FALSE, cex.text = 0.6, zlim = c(-0.25, 0.25),
- main = paste("Module-trait relationships"),
- clustRow = TRUE,
- rowDendro = TRUE,
- verticalSeparator.x=8)
- dev.off()
- # Chi-square test between module genes and the 15 merged risk gene sets -----------------------------------------
- #Create a loop to batch integrate risk gene data into genome module data
- library("data.table")
- riskgene<-read.table("15 disorder_merged gene.CSV",header=TRUE,sep=",",row.names=1)
- str(riskgene)
- braingene<-fread("genome_module_dummy.CSV",header=TRUE,sep=",")
- braingene<-braingene[,-c(2,3)]
- colnames(braingene)[1]<-"gene"
- colnames(braingene)[2:42]<-paste("ME",colnames(braingene)[2:42],sep="")
- colnames(braingene)
- str(braingene)
- colname=c(colnames(riskgene))
- str(riskgene)
- dim(riskgene)
- dim(braingene)
- braingeneXrisk<-braingene
- for(i in 1:15){
- v2<-colname[i]
- riskgenei<-data.table(c(riskgene[,i]),"1")
- names(riskgenei) <- c("gene", v2)
- str(riskgenei)
- braingeneXrisk<-dplyr::left_join(braingeneXrisk,riskgenei,by="gene")
- }
- braingeneXrisk[is.na(braingeneXrisk)]<-0
- str(braingeneXrisk)
- braingeneXrisk<-braingeneXrisk[!duplicated(braingeneXrisk,by="gene"),]
- str(braingeneXrisk)
- ##Chi-square test
- library(gmodels)
- library("data.table")
- library("dplyr")
- str(braingeneXrisk)
- colnames(braingeneXrisk)
- setDT(braingeneXrisk, keep.rownames=FALSE, key=NULL, check.names=FALSE)
- variables<-c(colnames(braingeneXrisk))
- variables
- ncol(braingene)
- ncol(braingeneXrisk)
- p_values<-data.frame()
- OR<-data.frame()
- Risk_Positive_prop<-data.frame()
- imax<-ncol(braingene)
- imax
- jmax<-ncol(braingeneXrisk)-ncol(braingene)
- jmax
- c(imax+1:jmax)
- variables[2:ncol(braingene)]
- variables[ncol(braingene)+1:jmax]
- braingeneXrisk[[1]]
- for (i in 2:imax)
- {for (j in c(imax+1:jmax))
- {result<-CrossTable(braingeneXrisk[[i]], braingeneXrisk[[j]],expected = F, format = "SAS",fisher = T, prop.c = F,prop.t = F,prop.chisq = F)
- p_values[i-1,j-ncol(braingene)]<-result$fisher.gt$p.value
- OR[i-1,j-ncol(braingene)]<-result$fisher.gt$estimate[[1]]
- Risk_Positive_prop[i-1,j-ncol(braingene)]<-result$prop.col[2,2]
- }
- }
- rownames(p_values)<-c(variables[2:imax])
- colnames(p_values)<-c(variables[imax+1:jmax])
- rownames(OR)<-c(variables[2:imax])
- colnames(OR)<-c(variables[imax+1:jmax])
- rownames(Risk_Positive_prop)<-c(variables[2:imax])
- colnames(Risk_Positive_prop)<-c(variables[imax+1:jmax])
- rownames(Risk_Positive_prop)
- write.csv(p_values, file="P_Values-41ME.CSV", quote = F,row.names = T)
- write.csv(OR,file="OR-41ME.CSV", quote=F,row.names = T)
- ##Conduct enrichment analysis with the enrich function in the clusterProfiler package
- library(dplyr)
- library(stringr)
- library(rlang)
- library(ggplot2)
- require(clusterProfiler)
- library(clusterProfiler)
- library(biomaRt)
- library(AnnotationHub)
- library(AnnotationDbi)
- library(ggstar)
- library("org.Hs.eg.db")
- library("ggtext")
- # enriChKEGG---------------
- # KEGG analysis of significantly enriched modules---------------------------------------------------------------
- sig_module<-read.table("sig modules-16.CSV",header=TRUE,sep=",",row.names=1)
- colnames(sig_module)
- posi_gene_Entrez<-vector("list", ncol(sig_module))
- names(posi_gene_Entrez)<-colnames(sig_module)
- colnames(sig_module)
- for (j in 1:16)
- {
- posi_sig_module<-sig_module[,j]
- length(posi_sig_module)
- posi_sig_module <- posi_sig_module[!posi_sig_module==""]
- length(posi_sig_module)
- posi_sig_module
- entrezid_all = mapIds(x = org.Hs.eg.db,
- keys = posi_sig_module,
- keytype = "SYMBOL",
- column = "ENTREZID")
- entrezid_all
- entrezid_all = na.omit(entrezid_all)
- entrezid_all = data.frame(entrezid_all)
- posi_gene_Entrez[[j]]<- entrezid_all[,1]
- }
- summary(posi_gene_Entrez)
- save(posi_gene_Entrez, file ='KEGG_sig module gene.RData')
- load('KEGG_sig module gene.RData')
- summary(posi_gene_Entrez)
- ###qvalueCutoff=0.05###
- ###Compare multiple enrichment results using the compareCluster function in clusterProfiler
- KEGG_result<-compareCluster(posi_gene_Entrez, fun="enrichKEGG", organism="hsa",qvalueCutoff=0.05)
- table(KEGG_result@compareClusterResult$Cluster)
- str(KEGG_result)
- KEGG_result@compareClusterResult$Description<-str_replace_all(KEGG_result@compareClusterResult$Description, " - Homo sapiens \\(.*?\\)", "")
- str(KEGG_result@compareClusterResult$Description)
- KEGG_result@compareClusterResult$Log_qvalue<- -log(KEGG_result@compareClusterResult$qvalue,10)
- write.csv(KEGG_result,"KEGG_sig module gene-q0.05.csv")
- dotpl<- dotplot(KEGG_result, x="Cluster",color= "Log_qvalue",
- showCategory =3,
- by="Log_qvalue",
- size ="GeneRatio",
- font.size = 10,
- label_format = 30)+
- theme(axis.text.x = element_text(angle = 45, hjust = 1,size=8),axis.text.y = element_text(hjust = 1,size=8),plot.title = element_text(size = 10, hjust = 0.5))+
- labs(title="Enrichment analysis of module genes for KEGG pathways",x = '', y = '')
- ggsave(dotpl,filename="KEGG_sig module gene-q0.05.png", width =6, height =7,units = "in", dpi = 300, bg = "transparent")
- ##enrichGO--export go terms top 3significant
- for (j in 1:16)
- {
- summary(posi_gene_Entrez)
- enrichGO_result<-enrichGO(posi_gene_Entrez[[j]], OrgDb=org.Hs.eg.db, keyType = "ENTREZID", ont = "ALL",
- pvalueCutoff = 0.05, pAdjustMethod = "BH", qvalueCutoff = 0.05,
- minGSSize =3, maxGSSize = 500,
- readable = FALSE,
- pool = FALSE
- )
- str(enrichGO_result)
- go <- enrichGO_result
- str(go)
- go <- go[order(go$ONTOLOGY, go$qvalue, decreasing = F),]
- go_top5 <- go %>%
- group_by(ONTOLOGY) %>%
- slice_head(n = 3) %>%
- ungroup()
- go_top5 <- go_top5[order(go_top5$ONTOLOGY, go_top5$qvalue, decreasing = T),]
- go_top5
- go_top5$Description <- sapply(go_top5$Description, function(x) paste(strwrap(x, width = 30), collapse = "\n"))
- str(go_top5)
- go_top5$ShortDesc <- ifelse(nchar(go_top5$Description) > 40,
- paste0(substr(go_top5$Description, 1, 37), "..."),
- go_top5$Description)
- go_top5$ShortDesc
- go_top5$ShortDesc <- sub("acetylcholine", "Ach", go_top5$ShortDesc) # 提取首个词
- barpl<-ggplot(go_top5, aes(x = reorder(ShortDesc, -qvalue),y= -log10(qvalue))) +
- geom_col(aes(fill = ONTOLOGY), width = 0.5, show.legend =F) +
- facet_grid(ONTOLOGY~., scale = 'free_y', space = 'free_y') +
- theme(axis.text = element_text(size = 12), panel.grid = element_blank(), panel.background = element_rect(color = 'black', fill = 'transparent')) +
- scale_y_continuous(expand = expansion(mult = c(0, 0.1))) +
- coord_flip() +
- labs(title=colnames(sig_module)[j],x = '', y = '-Log10(q)' )
- ggsave(barpl,filename=paste0('enrich.go_sig module gene',colnames(sig_module)[j],'-q0.05.png'), width = 4,height=4,dpi=300, units="in", bg = "transparent")
- }
R code for data analysis.R, under CC-BY-4.0 · at the source
Overview
- Clinical Research Center for Mental Disorders, Shanghai Pudong New Area Mental Health Center, School of Medicine, Tongji University,Shanghai, China
- Laboratory for Molecular Mechanisms of Brain Development, RIKEN Center for Brain Science,Wako, Japan
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 15 matches between paragraphs and lines of code.
liuwq2010/Neuropsychiatric-risk-gene-spatiotemporal-expression
aaec55250e394a7553d4aad991fa7f86cc0f0653, 21 September 2025Availability: 1 check, the latest on 28 September 2026: the link answers
- 28 September 2026: the link answers
2 files
- R code for data analysis.R, R, 546 lines, 6 matches
- LICENSE, License, 21 lines
Zenodo 19097352
Availability: 1 check, the latest on 28 September 2026: the link answers (HTTP 200)
- 28 September 2026: the link answers (HTTP 200)
1 file
- R code for data analysis.R, R, 1,145 lines, 9 matches
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: liuwq2010/
Neuropsychiatric-risk-ge , Zenodo 19097352ne-spatiotemporal-expres sion
Read it in the paper: doi.org/10.1038/s42003-026-10045-x.
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;
- 2 scripts, each with its path and the digest of its content;
- 15 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
No dataset and no data link were found in the paper.
Data availability statement
The paper has a data availability statement. Its license (CC BY-NC-ND) does not allow reproducing it here; in short, from what the harvester recognized in it:
- no repository, dataset or request procedure was recognized in it
Read it in the paper: doi.org/10.1038/s42003-026-10045-x.
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, 28 September 2026: the first record
Recorded: type, language, journal, volume, issue, pages, dates, 2 authors, 2 keywords, 8 MeSH terms, 2 funders, 67 references.
Cite
This paper
Liu, W., & Shimogori, T. (2026). Spatiotemporal brain transcriptomics reveal risk gene hot-spots in major neuropsychiatric disorders. Communications biology, 9(1), 634. https://
BibTeX
@article{liu2026spatiote
author = {Liu, Weiqing and Shimogori, Tomomi},
title = {{Spatiotemporal brain transcriptomics reveal risk gene hot-spots in major neuropsychiatric disorders}},
journal = {Communications biology},
year = {2026},
month = may,
volume = {9},
number = {1},
pages = {634},
publisher = {Nature Publishing Group},
issn = {2399-3642},
doi = {10.1038/
url = {https://
pmid = {42129508},
pmcid = {PMC13172025}
}
RIS
TY - JOUR
AU - Liu, Weiqing
AU - Shimogori, Tomomi
TI - Spatiotemporal brain transcriptomics reveal risk gene hot-spots in major neuropsychiatric disorders
T2 - Communications biology
J2 - Commun Biol
PY - 2026
DA - 2026/
VL - 9
IS - 1
SP - 634
SN - 2399-3642
PB - Nature Publishing Group
DO - 10.1038/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.1038/
"type": "article-journal",
"title": "Spatiotemporal brain transcriptomics reveal risk gene hot-spots in major neuropsychiatric disorders",
"container-title": "Communications biology",
"author": [
{
"family": "Liu",
"given": "Weiqing"
},
{
"family": "Shimogori",
"given": "Tomomi"
}
],
"container-title-short":
"volume": "9",
"issue": "1",
"page": "634",
"DOI": "10.1038/
"PMID": "42129508",
"PMCID": "PMC13172025",
"ISSN": "2399-3642",
"publisher": "Nature Publishing Group",
"URL": "https://
"language": "en",
"issued": {
"date-parts": [
[
2026,
5,
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.1371/journal.pcbi.1014422 [code]
- Deciphering cell type-specific causal genetic effects on brain imaging-derived phenotypes and disorders with single-cell Mendelian randomization.Journal: PLoS computational biologyIn common: clusterProfiler, data.table, ggplot2, 1 other tool, genetics / omics, cellular / molecular, 10 references
- [2] doi:10.1038/s41593-026-02247-7 [code]
- Transcriptomic and phenotypic convergence of neurodevelopmental disorder risk genes in vitro and in vivo.Journal: Nature neuroscienceIn common: genetics / omics, cellular / molecular, 13 references
- [3] doi:10.1038/s41380-026-03497-4 [code]
- Transcriptome-informed brain cartography of polygenic risk and association with brain structure in major psychiatric disorders.Journal: Molecular psychiatryIn common: clusterProfiler, ComplexHeatmap, ggplot2, 1 other tool, genetics / omics, cellular / molecular, 8 references
- [4] doi:10.1016/j.celrep.2026.117500 [code]
- Spatio-molecular gene expression reflects dorsal anterior cingulate cortex structure and function in the human brain.Journal: Cell reportsIn common: easystats, ComplexHeatmap, ggpubr, 2 other tools, genetics / omics, cellular / molecular, 7 references
- [5] doi:10.1111/adb.70179 [code]
- Transcriptional Response to Chronic Long-Access Fentanyl Self-Administration in Rat Habenula and Amygdala.Journal: Addiction biologyIn common: rstatix, clusterProfiler, ComplexHeatmap, 3 other tools, genetics / omics, cellular / molecular, 3 references
- [6] doi:10.1038/s41467-026-71542-5 [code]
- Astrocyte fatty acid metabolism as a driver of risk for major depressive disorder.Journal: Nature communicationsIn common: WGCNA, data.table, ggplot2, 1 other tool, genetics / omics, cellular / molecular, 5 references
- [7] doi:10.1038/s41467-026-72598-z [code]
- Functional impact of genetic background on variable expressivity in neurodevelopmental disorders.Journal: Nature communicationsIn common: WGCNA, clusterProfiler, ComplexHeatmap, 4 other tools, 2 references
- [8] doi:10.1038/s41467-026-75193-4 [code]
- Multi-ancestry gene expression models amplify transcriptome-wide association study discovery and validation.Journal: Nature communicationsIn common: ComplexHeatmap, ggpubr, data.table, 2 other tools, genetics / omics, cellular / molecular, 4 references
- [9] doi:10.1093/bioinformatics/btag592 [code]
- Network-based stratification of allele-specific expression reveals patient subgroups in Huntington's disease.Journal: Bioinformatics (Oxford, England)In common: WGCNA, rstatix, clusterProfiler, 5 other tools, genetics / omics
- [10] doi:10.1016/j.xhgg.2026.100652 [code]
- CRISPR-engineered deletion of POGZ alters transcription factor binding at promoters of genes involved in synaptic signaling.Journal: HGG advancesIn common: WGCNA, ggpubr, data.table, 2 other tools, cellular / molecular, 4 references
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, 2 scripts, and 15 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:f4dd8e6a1693d9e0…
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.
