OSCR

Transcriptome profiling of human hypothalamic agouti-related protein and proopiomelanocortin neurons regulating energy homeostasis.

Code ↔ Paper

6 matches between paragraphs of the paper and lines of its authors' code, computed by the harvester (lexical-v1). Click a colored paragraph or line to see its counterpart.

The 6 matches · 1 of them tie a paragraph to a whole file, not to given lines: a weak match, whose lines are not tinted
  1. [1] § Results › Transcription factor profiles differ among neuronal phenotypes ↔ Human_AgRP_POMC_KP_ILCMSeq_codes.R, lines 303–347 · score 0.95 · STAT5A, NR3C1, transcription factor, BCL6, CREM, ETV5
  2. [2] § Methods › IHC/LCM-Seq studies of hypothalamic neurons › Bioinformatics ↔ Bash scripts for reanalysis of PRJNA281954.sh, the whole file · a weak match · score 0.72 · featureCounts, Cutadapt, MINLEN, SLIDINGWINDOW, TRAILING, Trimmomatic
  3. [3] § Methods › Quantification and statistical analysis ↔ Human_AgRP_POMC_KP_ILCMSeq_codes.R, lines 1–78 · score 0.65 · TukeyHSD, way ANOVA, aov
  4. [4] § Methods › IHC/LCM-Seq studies of hypothalamic neurons › Functional classification ↔ Human_AgRP_POMC_KP_ILCMSeq_codes.R, lines 220–260 · score 0.58 · KEGG BRITE, ACVR1C, INSR, Neuropeptides, Receptor, KP
  5. [5] § Methods › IHC/LCM-Seq studies of hypothalamic neurons › Functional classification ↔ R scripts for reanalysis of PRJNA281954.R, lines 230–276 · score 0.56 · protein coupled, nuclear receptors, Ensembl, AgRP, TPM
  6. [6] § Methods › GWAS associations ↔ Human_AgRP_POMC_KP_ILCMSeq_codes.R, lines 793–852 · score 0.52 · Body weight, disease, Trait, GWAS, enrichment

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,554 lines · 71 KB · no license · 4 matches

  1. #Libraries####
  2. #1.
  3. library(readxl)
  4. library(DESeq2)
  5. library(openxlsx)
  6. library(tidyverse)
  7. #2.
  8. library('ggplot2')
  9. library('ggfortify')
  10. library (cluster)
  11. #3.
  12. library('pheatmap')
  13. library('RColorBrewer')
  14. #5.
  15. library(ggrepel)
  16. library("EnhancedVolcano")
  17. #10.
  18. library(gridExtra)
  19. library(ggpubr)
  20. #14.
  21. library(eulerr)
  22. #16.
  23. library("scales")
  24. library(fmsb)
  25. #One-way ANOVA -Fig 1d, Supplementary table 2####
  26. Ano <- data.frame(read_excel("forANOVAH.xlsx"))
  27. Ano <- Ano %>%
  28. pivot_longer(cols = colnames(Ano),
  29. names_to = "Stage",
  30. values_to = "RIN")
  31. Anos <- aov(Ano$RIN~factor(Ano$Stage))
  32. summary(Anos)
  33. TukeyHSD(Anos)
  34. #1.DESeq2 -Fig 2, Supplementary table 4, 5####
  35. data <- data.frame(read_excel("Human_iLCM_POMC_AgRP_KP_no_multi.xlsx")) #raw reads
  36. row.names(data) <- data$Geneid
  37. countS <- data %>% dplyr::select(1,2,3)
  38. data <- data %>% dplyr::select(4:11)
  39. colnames(data) = paste0('raw_',colnames(data))
  40. data$Geneid <- row.names(data)
  41. countS <- right_join(countS, data)
  42. row.names(countS) <- countS$Geneid
  43. data <-data %>% dplyr::select(-"Geneid")
  44. colnames(data) <- c("AgRP_1","AgRP_2","AgRP_3","POMC_1","POMC_2","KP_1","KP_2","KP_3")
  45. info = data.frame(smpl=colnames(data))
  46. rownames(info) = info$smpl
  47. info$type = gsub('s', '', matrix(unlist(strsplit(info$smpl, '_')), nc=2, byrow=TRUE)[,1])
  48. info$type = factor(info$type)
  49. vresTC = tibble(Geneid=rownames(data))
  50. uni <- unique(info$type)
  51. dds<- DESeqDataSetFromMatrix(countData =data, colData = info, design = ~type)
  52. keep <- rowSums(counts(dds) > 5) >= 2
  53. dds <- dds[keep, ]
  54. rld <- rlog(dds, blind = FALSE)#->PCA
  55. for (x in 1:(length(uni)-1)) {
  56. y = length(uni)-x
  57. for (z in 1:y){
  58. a=uni[x]
  59. b=uni[x+z]
  60. infoh <-info
  61. infoh$type = factor(info$type, levels = c(a,b))
  62. infoh <- infoh %>% filter(is.na(type) != TRUE)
  63. datah <- data[,infoh$smpl]
  64. dds<- DESeqDataSetFromMatrix(countData =datah, colData = infoh, design = ~type)
  65. keep <- rowSums(counts(dds) > 5) >= 2
  66. dds <- dds[keep, ]
  67. ddsDE <- DESeq(dds)
  68. res <- results(ddsDE, alpha=0.05)
  69. resTC <- as.data.frame(res)
  70. colnames(resTC) = paste0('Wald_',a,"_vs_",b,"_",colnames(resTC))
  71. resTC = resTC %>% mutate(Geneid=rownames(.)) %>% as_tibble() %>% dplyr::select(7,2,5,6)
  72. vresTC = left_join(vresTC, resTC)
  73. }
  74. }
  75. all = left_join(countS, vresTC)
  76. write.xlsx(all, "1_pairwise_Wald_AgRP_POMC_KP_noFCshrinkage.xlsx")
  77. #2.PCA -Fig 2e####
  78. rm <- as.data.frame(assay(rld))#deseq
  79. pca <-prcomp(t(rm), scale. =FALSE)
  80. plot(pca$x[,1], pca$x[,2])
  81. pca.var <- pca$sdev^2
  82. pca.var.per <- round(pca.var/sum(pca.var)*100, 1)
  83. barplot(pca.var.per, main="Scree Plot", xlab="Principal Component", ylab="Percent Variation")
  84. pca.data <- data.frame(Sample=rownames(pca$x),
  85. X=pca$x[,1],
  86. Y=pca$x[,2])
  87. ggplot(data=pca.data, aes(x=X, y=Y, label=Sample))+
  88. geom_point()+
  89. ggrepel::geom_label_repel(aes(label = Sample), data = pca.data)+
  90. xlab(paste("PC1 - ", pca.var.per[1], "%", sep=""))+
  91. ylab(paste("PC2 - ", pca.var.per[2], "%", sep=""))+
  92. theme_bw()+
  93. ggtitle("PCA Graph")
  94. ttest <- data.frame(t(rm))
  95. cls <- kmeans(ttest, 3)
  96. ttest$cluster <- as.character(cls$cluster)
  97. pca.data <- data.frame(Sample=rownames(pca$x),
  98. X=pca$x[,1],
  99. Y=pca$x[,2],
  100. Cluster=ttest$cluster)
  101. pcaplot <- ggplot(data=pca.data, aes(x=X, y=Y, label=Sample, color = Cluster))+
  102. geom_point()+
  103. ggrepel::geom_label_repel(aes(label = Sample), data = pca.data)+
  104. xlab(paste("PC1 - ", pca.var.per[1], "%", sep=""))+
  105. ylab(paste("PC2 - ", pca.var.per[2], "%", sep=""))+
  106. theme_bw()+
  107. ggtitle("PCA Graph")
  108. pdf("2_PCA_plot.pdf")
  109. print(pcaplot)
  110. dev.off()
  111. #3.Heatmap -Fig 3a####
  112. test <- as.data.frame(assay(rld))
  113. sign_genes <- all |> filter(Wald_AgRP_vs_POMC_padj < 0.05 | Wald_AgRP_vs_KP_padj < 0.05 | Wald_POMC_vs_KP_padj < 0.05)
  114. test <- test |> mutate(Geneid = row.names(test))
  115. test <-left_join(sign_genes[1],test) |> dplyr::select(2:9)
  116. test <- as.matrix(test)
  117. pheatmap(test,
  118. scale = "row",
  119. color = colorRampPalette(rev(brewer.pal(n =11, name = "RdBu")))(200),
  120. kmeans_k = 500,
  121. cellwidth = 20,
  122. cellheight = 1,
  123. fontsize = 8,
  124. border_color = NA,
  125. clustering_distance_rows = "euclidean",
  126. clustering_distance_cols = "euclidean",
  127. clustering_method = "average",
  128. cutree_cols = 3,
  129. show_rownames = FALSE,
  130. fontsize_row = 6,
  131. fontsize_col = 6,
  132. filename = "3_pheatmap.pdf")
  133. #4.TPM calculation -Fig 2f, etc.####
  134. data <- all %>% dplyr::select(1,4:11)#DEseq
  135. data <- data |> arrange(Geneid)
  136. data <- data.frame(data, row.names = 1)
  137. m = as.matrix(data)
  138. h_length <- data.frame(read_excel("Human_iLCM_length.xlsx"))#gene lengths obtained via FeatureCounts
  139. h_length <- h_length |> arrange(Geneid)
  140. l = h_length$Length / 1000
  141. RPK = m / l
  142. counts_tpm = as.data.frame(t(t(RPK) * 1e6 / colSums(RPK)))
  143. colnames(counts_tpm) = paste0('TPM_', colnames(counts_tpm))
  144. counts_tpm$ens = rownames(counts_tpm)
  145. counts_tpm = as_tibble(counts_tpm)
  146. counts_tpm_ <- counts_tpm %>%
  147. dplyr::select(ens, )
  148. nrow(counts_tpm)
  149. nrow(unique(counts_tpm))
  150. data <- left_join(all, counts_tpm, by=join_by(Geneid==ens))
  151. data4 <- data %>% dplyr::select(1:11,21:28,12:20)
  152. write.xlsx(data4, "4_AgRP_POMC_KP_TPM.xlsx")
  153. #5.Volcano plots -Fig 3b-e####
  154. asd <- data.frame(all, row.names = 1)
  155. asd$external_gene_name <- ifelse(is.na(asd$external_gene_name), row.names(asd), asd$external_gene_name)
  156. asd <- asd[c(1,11,13,14,16,17,19)]
  157. colnames(asd) <- c("Gene","Log2FC_AP","padj_AP","Log2FC_AK","padj_AK","Log2FC_PK","padj_PK")
  158. plotlist <- list()
  159. for (x in 1:3){
  160. asdx <- asd %>% filter(asd[2*x+1] < 1.1)
  161. asdx <- asdx %>% filter(asdx[2*x] < 1000)
  162. asd5 <- asdx %>% filter(asdx[2*x+1] < 0.05 )
  163. asd1 <- asd5 %>% arrange(asd5[2*x+1])
  164. asd1 <- asd1 %>% filter(asd1[2*x]>0)
  165. asd2 <- asd5 %>% arrange(asd5[2*x])
  166. asd4 <- asd5 %>% arrange(asd5[2*x+1])
  167. asd4 <- asd4 %>% filter(asd4[2*x]<0)
  168. asd3 <- asd5 %>% arrange(desc(asd5[2*x]))
  169. asd1 <- head(asd1,10)
  170. asd4 <- head(asd4,10)
  171. asd2 <- head(asd2,10)
  172. asd3 <- head(asd3,10)
  173. asd1 <- full_join(full_join(full_join(asd1, asd2),asd3),asd4)
  174. Gene <- asd1$Gene
  175. xx <- colnames(asdx)[2*x]
  176. yy <- colnames(asdx)[2*x+1]
  177. plotlist[[x]] <- EnhancedVolcano(asdx,
  178. lab = asdx$Gene,
  179. x = xx,
  180. y = yy,
  181. # xlim = c(-12, 12),
  182. # ylim = c(0, 10),
  183. # ylim = c(0, 35),
  184. selectLab = Gene,
  185. labSize = 3.0,
  186. shape= c(16),
  187. labCol = 'black',
  188. labFace = 'bold',
  189. colAlpha = 1,
  190. title='', subtitle='',
  191. pCutoff = 0.05,
  192. FCcutoff = 1,
  193. col = c('grey30', 'grey30', 'royalblue', 'red2'),
  194. pointSize = 1,
  195. drawConnectors = TRUE,
  196. widthConnectors = 0.5,
  197. lengthConnectors = unit(0.01, "npc"),
  198. arrowheads = TRUE,
  199. boxedLabels = FALSE,
  200. max.overlaps = 20,
  201. legendLabels = c('NS', expression(Log[2]~FC), 'p-value', expression(p-adj.~and~log[2]~FC)),
  202. legendPosition = 'top',
  203. directionConnectors = "both",
  204. legendLabSize = 10,
  205. legendIconSize = 2.0,
  206. caption = bquote(~Log[2]~"fold change cutoff: 1; adjusted p-value cutoff: 0.05")
  207. )
  208. }
  209. pdf(paste0("5_Volcano_plots.pdf"))
  210. for (x in 1:3) {
  211. print(plotlist[[x]])
  212. }
  213. dev.off()
  214. #6.Categories (multiple from KEGG BRITE or Neuropeptides) -Fig 3f,g, etc.####
  215. a <- data.frame(read_excel("CAM_human.xlsx"))
  216. colnames(a) = "external_gene_name"
  217. b <- data.frame(read_excel("ion_channel_human_kegg_brite.xlsx"))
  218. colnames(b) = "external_gene_name"
  219. c <- data.frame(read_excel("Neuropeptides - Homo sapiens (human).xlsx"))#Supplementary table 7
  220. colnames(c) = "external_gene_name"
  221. d <- data.frame(read_excel("Human_non_coding.xlsx")) #Supplementary table 9
  222. d <- d[1]
  223. colnames(d)[1] = "Geneid"
  224. e <- data.frame(read_excel("All_receptor_brite+ACVR1C+INSR.xlsx"))#Supplementary table 12
  225. colnames(e) = "external_gene_name"
  226. f <- data.frame(read_excel("Tfs_human.xlsx"))# Supplementary table 6
  227. colnames(f) = "external_gene_name"
  228. g <- data.frame(read_excel("transporter.xlsx"))
  229. colnames(g) = "external_gene_name"
  230. i5 <- data4
  231. j <- dplyr::select(i5,c(1,2))
  232. categories <- list()
  233. categories <- list(a,b,c,d,e,f,g)
  234. for (x in 1:length(categories)){
  235. categories[[x]] <- left_join(categories[[x]], j, relationship = "many-to-many")
  236. }
  237. k <- i5
  238. for (x in 1:length(categories)){
  239. categories[[x]] <- left_join(categories[[x]], k, relationship = "many-to-many")
  240. }
  241. for (x in 1:length(categories)){
  242. categories[[x]]$means_AgRP <- rowMeans(categories[[x]][,c(12:14)],na.rm = TRUE)
  243. categories[[x]]$means_POMC <- rowMeans(categories[[x]][,c(15:16)],na.rm = TRUE)
  244. categories[[x]]$means_KP <- rowMeans(categories[[x]][,c(17:19)],na.rm = TRUE)
  245. categories[[x]]$means_ALL <- rowMeans(categories[[x]][,c(12:19)],na.rm = TRUE)
  246. categories[[x]] <- categories[[x]][rowSums(categories[[x]][,c(12:19)]) > 0,]
  247. }
  248. categorynames <- c("CAMs","Ionch","Neuropep","NoncRNAs","Recept","TransFac","Transp")
  249. Category_lists <- list()
  250. for (x in 1:length(categories)){
  251. Category_lists[[x]] <- assign(categorynames[x],categories[[x]])
  252. }
  253. names(Category_lists) <- categorynames
  254. write.xlsx(Category_lists, file = "6_AgRP_POMC_KP_TPM_categorized.xlsx")
  255. #7.Top transcription factors -Fig 3f, Supplementary table 6####
  256. data <- data.frame(Category_lists[[6]])
  257. data <- data %>%
  258. unique() %>%
  259. dplyr::select(1,2,20,22,23,25,26,28, 12:19)
  260. data$external_gene_name <- ifelse(is.na(data$external_gene_name), data$Geneid, data$external_gene_name)
  261. data <-data %>% filter(is.na(data$Geneid) == FALSE)
  262. colnames(data)[9:16] <- c("AgRP_1","AgRP_2","AgRP_3","POMC_1","POMC_2","KP_1","KP_2","KP_3")
  263. data <- data %>%
  264. mutate(mnAgRP = rowMeans(data[,9:11], na.rm=TRUE)) %>%
  265. mutate(mnPOMC = rowMeans(data[,12:13], na.rm=TRUE)) %>%
  266. mutate(mnKP = rowMeans(data[,14:16], na.rm=TRUE))
  267. data <- data[rowSums((data[9:11]) > 0) >= 3 | rowSums((data[12:13]) > 0) >= 2 | rowSums((data[14:16]) > 0) >= 3, ]
  268. data <- data %>% mutate(max_mean = apply(data[17:19], 1, max, na.rm=TRUE))
  269. dataA <- data %>% arrange(desc(mnAgRP)) %>% head(40)
  270. dataB <- data %>% arrange(desc(mnPOMC)) %>% head(40)
  271. dataC <- data %>% arrange(desc(mnKP)) %>% head(40)
  272. dataG <- full_join(full_join(dataA,dataB),dataC)
  273. for (x in 1:8) {
  274. dataG[x+8] = 2* sqrt(dataG[x+8] /pi)
  275. }
  276. dataG <- dataG %>% arrange(desc(max_mean))
  277. dataG <- dataG %>% mutate(Position = row_number())
  278. dataG <- dataG %>%
  279. mutate(mnAgRP = rowMeans(dataG[,9:11], na.rm=TRUE)) %>%
  280. mutate(mnPOMC = rowMeans(dataG[,12:13], na.rm=TRUE)) %>%
  281. mutate(mnKP = rowMeans(dataG[,14:16], na.rm=TRUE))# %>%
  282. dataG <- dataG %>% mutate(max_mean = apply(dataG[17:19], 1, max, na.rm=TRUE))
  283. dataH <- dataG %>%
  284. pivot_longer(cols = c(mnAgRP,mnPOMC, mnKP),
  285. names_to = "Cell_type",
  286. values_to = "TPM")
  287. dataH$Cell_type <- factor(dataH$Cell_type, levels = c("mnAgRP","mnPOMC", "mnKP"))
  288. ggplot(data = dataH, aes(reorder(external_gene_name,Position), Cell_type))+
  289. geom_point(aes(size = TPM, colour = TPM),)+
  290. scale_color_gradient2(low = '#0000FF', mid = '#FFCCFF', high = '#FF0000', midpoint = median(dataH$max_mean), transform = "log2")+
  291. scale_size_area(max_size = 12)+
  292. theme_bw()+
  293. theme(axis.text.x=element_text(angle=45,hjust=1))
  294. ggsave("7_dotplot_transfact.pdf", width = 500 , height = 120 , units = "mm")
  295. #8.Significant Transcription factors heatmap & columns -Fig 3g, Supplementary table 6####
  296. test <- data.frame(inner_join(data,sign_genes), row.names = 1) %>% dplyr::select(8:15)
  297. colnames(test) <- c("AgRP_1","AgRP_2","AgRP_3","POMC_1","POMC_2","KP_1","KP_2","KP_3")
  298. pheatmap(test,
  299. scale = "row",
  300. color = colorRampPalette(rev(brewer.pal(n =11, name = "RdBu")))(200),
  301. cellwidth = 10,
  302. cellheight = 10,
  303. fontsize = 8,
  304. cluster_cols = FALSE,
  305. clustering_distance_cols = "euclidean",
  306. clustering_method = "average",
  307. fontsize_row = 6,
  308. fontsize_col = 6,
  309. angle_col = 90,
  310. gaps_col = c(3,5),
  311. filename = "8_Pheatmap_TFsign.pdf")
  312. #'testhead' list from heatmap clustering
  313. testhead <-c("TSHZ2","ISL1","PROX1","ARID5B","CREB5","CREM","NR3C1","ST18","XBP1","FOXO1","CREB3L2","TFCP2L1","ZBTB16","ETV5","KLF9","OTP","BMAL2","BCL6",
  314. "ZSCAN30","FOXN2","PBX3","MKX","ETV1","BCL11A","ONECUT1","THRB","ZNF462","LEF1","ZFPM2","ZFHX4","ZNF267","GABPB2","CREBZF","PEG3","L3MBTL4",
  315. "MITF","SOX1","NHLH2","PGR","AR","ZFHX3","ESR1","PLAGL1","SOX14","ZFP30","MYT1L","STAT5A","PKNOX2","FOXD2","NFKBIE") #FDR < 0.05
  316. testhead2 <- data.frame(testhead)
  317. testd <- test |> mutate(
  318. mnAgRP = rowMeans(test[,1:3], na.rm=TRUE),
  319. mnPOMC = rowMeans(test[,4:5], na.rm=TRUE),
  320. mnKP = rowMeans(test[,6:8], na.rm=TRUE)
  321. )
  322. testd <- testd |> mutate(
  323. testhead = row.names(testd))
  324. testd2 <- left_join(testhead2,testd)
  325. testh2 <- testd2 %>%
  326. pivot_longer(cols = c(mnAgRP,mnPOMC, mnKP),
  327. names_to = "Cell_type",
  328. values_to = "TPM")
  329. for (x in c("mnAgRP","mnPOMC","mnKP")) {
  330. testh <- testh2 |> filter(Cell_type == x)
  331. testh$testhead <- as.character(testh$testhead)
  332. testh$testhead <- factor(testh$testhead, levels=unique(testh$testhead))
  333. ggplot(data = testh)+
  334. geom_col(aes(x= testhead, y = TPM, fill = 'black'))+
  335. scale_y_continuous(expand = c(0,0))+
  336. theme_bw()+
  337. theme(axis.text.x=element_text(angle=45,hjust=1))
  338. ggsave(paste0("8_mean_TPMs_",x,"_columns.pdf"), width = 500 , height = 100 , units = "mm")
  339. }
  340. #9.Neuropeptides dotplots -Fig 4a, Supplementary table 7####
  341. data <- data.frame(Category_lists[[3]])
  342. filter = 40
  343. data <- data %>%
  344. unique() %>%
  345. dplyr::select(1,2,20,22,23,25,26,28,12:19)
  346. data$external_gene_name <- ifelse(is.na(data$external_gene_name), data$Geneid, data$external_gene_name)
  347. data <-data %>% filter(is.na(data$Geneid) == FALSE)
  348. colnames(data)[9:16] <- c("AgRP_1","AgRP_2","AgRP_3","POMC_1","POMC_2","KP_1","KP_2","KP_3")
  349. data <- data %>%
  350. mutate(mnAgRP = rowMeans(data[,9:11], na.rm=TRUE)) %>%
  351. mutate(mnPOMC = rowMeans(data[,12:13], na.rm=TRUE)) %>%
  352. mutate(mnKP = rowMeans(data[,14:16], na.rm=TRUE))
  353. data <- data[rowMeans(data[9:11]) >= filter | rowMeans(data[12:13]) >= filter | rowMeans(data[14:16]) >= filter, ]
  354. data <- data[rowSums((data[9:11]) > 0) >= 3 | rowSums((data[12:13]) > 0) >= 2 | rowSums((data[14:16]) > 0) >= 3, ]
  355. data <- data %>% mutate(max_mean = apply(data[17:19], 1, max, na.rm=TRUE))
  356. dataG <- data
  357. for (x in 1:8) {
  358. dataG[x+8] = 2* sqrt(dataG[x+8] /pi)
  359. }
  360. dataG <- dataG %>% arrange(desc(max_mean))
  361. dataG <- dataG %>% mutate(Position = row_number())
  362. dataG <- dataG %>%
  363. mutate(mnAgRP = rowMeans(dataG[,9:11], na.rm=TRUE)) %>%
  364. mutate(mnPOMC = rowMeans(dataG[,12:13], na.rm=TRUE)) %>%
  365. mutate(mnKP = rowMeans(dataG[,14:16], na.rm=TRUE))# %>%
  366. dataG <- dataG %>% mutate(max_mean = apply(dataG[17:19], 1, max, na.rm=TRUE))
  367. datah <- dataG[c(1:10),]
  368. dataH <- datah %>%
  369. pivot_longer(cols = c(mnAgRP,mnPOMC, mnKP),
  370. names_to = "Cell_type",
  371. #values_to = "Diam")
  372. values_to = "TPM")
  373. dataH$Cell_type <- factor(dataH$Cell_type, levels = c("mnAgRP","mnPOMC", "mnKP"))
  374. ggplot(data = dataH, aes(reorder(external_gene_name,Position), Cell_type))+
  375. geom_point(aes(size = ifelse(TPM==0,NA,TPM), colour = TPM),)+
  376. scale_color_gradient2(low = '#0000FF', mid = '#FFCCFF', high = '#FF0000', midpoint = mean(dataH$max_mean))+#, transform = "log2")+
  377. scale_size_area(max_size = 12, transform = "identity" )+
  378. theme_bw()+
  379. theme(axis.text.x=element_text(angle=45,hjust=1))
  380. ggsave("9_dotplot_neuropeptides_1.pdf", width = 500 , height = 120 , units = "mm")
  381. datah <- dataG[-c(1:10),]
  382. dataH <- datah %>%
  383. pivot_longer(cols = c(mnAgRP,mnPOMC, mnKP),
  384. names_to = "Cell_type",
  385. #values_to = "Diam")
  386. values_to = "TPM")
  387. dataH$Cell_type <- factor(dataH$Cell_type, levels = c("mnAgRP","mnPOMC", "mnKP"))
  388. ggplot(data = dataH, aes(reorder(external_gene_name,Position), Cell_type))+
  389. geom_point(aes(size = ifelse(TPM==0,NA,TPM), colour = TPM),)+
  390. scale_color_gradient2(low = '#0000FF', mid = '#FFCCFF', high = '#FF0000', midpoint = mean(dataH$max_mean))+#, transform = "log2")+
  391. scale_size_area(max_size = 12, transform = "identity" )+
  392. theme_bw()+
  393. theme(axis.text.x=element_text(angle=45,hjust=1))
  394. ggsave("9_dotplot_neuropeptides_2.pdf", width = 500 , height = 120 , units = "mm")
  395. #10.Neuropeptides columns -Fig 4b, Supplementary table 7####
  396. data <- data %>% filter(Wald_AgRP_vs_POMC_padj < 0.05 | Wald_AgRP_vs_KP_padj < 0.05 | Wald_POMC_vs_KP_padj < 0.05)
  397. plotra <- data %>% dplyr::select(1,17:19,9:16)
  398. means <- plotra %>% dplyr::select(1:4) %>%
  399. data.frame(row.names = 1)
  400. points <- plotra %>% dplyr::select(1,5:12) %>%
  401. data.frame(row.names = 1)
  402. means_list <- split(means, rownames(means))
  403. points_list <- split(points, rownames(points))
  404. genelist <- list()
  405. for (i in 1:length(rownames(points))) {
  406. genelist[[i]] <- assign(rownames(points)[i], as.data.frame(t(points_list[[i]])) %>%
  407. mutate(names = paste0("mn",as.vector(matrix(unlist(strsplit(colnames(points), '_')), nc=2, byrow=TRUE)[,1]))))
  408. (colnames(genelist[[i]])[1] = "points")
  409. }
  410. names(genelist) <- names(points_list)
  411. meanlist <- list()
  412. for (i in 1:length(rownames(means))) {
  413. meanlist[[i]] <- assign(rownames(means)[i], as.data.frame(t(means_list[[i]])) %>%
  414. mutate(names = colnames(means)))
  415. (colnames(meanlist[[i]])[1] = "points")
  416. }
  417. names(meanlist) <- names(means_list)
  418. ly <- c(150,11000,5000,300,
  419. 300,300,1760,1760,
  420. 1000,80,33000,400,
  421. 100,300,1760,6000,
  422. 800,1500,5000,5000,
  423. 300,600,100)
  424. noby <- c(6,6,6,6,
  425. 6,6,6,6,
  426. 5,6,6,5,
  427. 5,6,6,6,
  428. 4,6,6,6,
  429. 6,6,5)
  430. plist <- list()
  431. for (i in 1:length(rownames(plotra))) {
  432. meanlist[[i]]$names <- factor(meanlist[[i]]$names,
  433. levels = colnames(means))
  434. genelist[[i]]$names <- factor(genelist[[i]]$names,
  435. levels = colnames(means))
  436. plist[[i]] <- ggplot()+
  437. geom_bar(data = meanlist[[i]],
  438. aes(x=names, y=points ,fill=names),
  439. stat = "identity",
  440. show.legend = FALSE#,
  441. )+
  442. geom_jitter(data = genelist[[i]],
  443. aes(x=names, y=points ,fill=names),
  444. position = position_dodge2(width = 0.3),
  445. show.legend = FALSE,
  446. shape = 21,
  447. size = 1,
  448. stroke = 0.25)+
  449. theme_classic()+
  450. labs(title = names(meanlist)[i], x = NULL, y = NULL) +
  451. theme(axis.text = element_text(colour = "black"),
  452. axis.text.x = element_text(colour = "black"),
  453. axis.text.y = element_text(colour = "black"),
  454. plot.margin = margin(t = 3, r = 1, b = 5, l = 1) ) +
  455. theme(panel.grid.major = element_line(colour = NA)) +
  456. theme(plot.title = element_text(size = 10, hjust = 0.5)) +
  457. scale_fill_manual(values = c("#B1624E","#5CC8D7","#8CC63F")) +
  458. theme(axis.ticks = element_line(colour = "black"), plot.background = element_rect(colour = NA)) +
  459. theme(axis.line = element_line(linewidth = 5), axis.title = element_text(size = 7.5), axis.text = element_text(size = 7.5)) +
  460. theme(axis.line = element_line(linewidth = 0.1), panel.grid.minor = element_line(colour = NA)) +
  461. theme(axis.ticks = element_line(linewidth = 0.1),
  462. axis.text.x = element_blank())+
  463. scale_y_continuous(n.breaks = 6, expand = c(0,0),limits = c(0, ly[i]))
  464. }
  465. ggexport(plotlist = plist, filename = "10_Barplots_sign_neuropeptides.pdf",
  466. nrow = 4, ncol = 6)
  467. #11.Receptor ENRICHMENT SORTER with FUNCTION -Fig 7, Supplementary table 12####
  468. data <- data.frame(Category_lists[[5]])
  469. rawfilter = 5
  470. TPMfilter = 10
  471. lFCfilter = 1
  472. sorter <- function(data,rawfilter,TPMfilter,lFCfilter){
  473. datasorter <- data |> filter(
  474. (means_AgRP > TPMfilter &
  475. rowSums((data[4:6]) >= rawfilter) >= 3) |
  476. (means_POMC > TPMfilter &
  477. rowSums((data[7:8]) >= rawfilter) >= 2) |
  478. (means_KP > TPMfilter &
  479. rowSums((data[9:11]) >= rawfilter) >= 3)
  480. )
  481. datasorter = unique(datasorter)
  482. AgRPnull <- datasorter |> filter(
  483. means_AgRP < TPMfilter |
  484. rowSums((datasorter[4:6]) >= rawfilter) < 3
  485. )
  486. POMCnull <- datasorter |> filter(
  487. means_POMC < TPMfilter |
  488. rowSums((datasorter[7:8]) >= rawfilter) < 2
  489. )
  490. KPnull <- datasorter |> filter(
  491. (means_KP < TPMfilter |
  492. rowSums((datasorter[9:11]) >= rawfilter) < 3)
  493. )
  494. AgRPsorted <- inner_join(POMCnull,KPnull) |> filter(
  495. Wald_AgRP_vs_KP_log2FoldChange < -lFCfilter &
  496. Wald_AgRP_vs_POMC_log2FoldChange < -lFCfilter
  497. )
  498. POMCsorted <- inner_join(AgRPnull,KPnull) |> filter(
  499. Wald_POMC_vs_KP_log2FoldChange < -lFCfilter &
  500. Wald_AgRP_vs_POMC_log2FoldChange > lFCfilter
  501. )
  502. KPsorted <- inner_join(POMCnull,AgRPnull) |> filter(
  503. Wald_AgRP_vs_KP_log2FoldChange > lFCfilter &
  504. Wald_POMC_vs_KP_log2FoldChange > lFCfilter
  505. )
  506. AgRPnull <- anti_join(anti_join(AgRPnull,POMCsorted),KPsorted)
  507. POMCnull <- anti_join(anti_join(POMCnull,AgRPsorted),KPsorted)
  508. KPnull <- anti_join(anti_join(KPnull,POMCsorted),AgRPsorted)
  509. AgRPPOMCsorted <- inner_join(POMCnull,KPnull) |> filter(
  510. (Wald_AgRP_vs_KP_log2FoldChange < -lFCfilter &
  511. Wald_POMC_vs_KP_log2FoldChange < -lFCfilter) &
  512. (abs(Wald_AgRP_vs_POMC_log2FoldChange) < abs(Wald_AgRP_vs_KP_log2FoldChange) &
  513. abs(Wald_AgRP_vs_POMC_log2FoldChange) < abs(Wald_POMC_vs_KP_log2FoldChange))
  514. )
  515. AgRPPOMCsorter <- inner_join(AgRPnull,KPnull) |> filter(
  516. (Wald_AgRP_vs_KP_log2FoldChange < -lFCfilter &
  517. Wald_POMC_vs_KP_log2FoldChange < -lFCfilter) &
  518. (abs(Wald_AgRP_vs_POMC_log2FoldChange) < abs(Wald_AgRP_vs_KP_log2FoldChange) &
  519. abs(Wald_AgRP_vs_POMC_log2FoldChange) < abs(Wald_POMC_vs_KP_log2FoldChange))
  520. )
  521. AgRPPOMCsorted <- full_join(AgRPPOMCsorted,AgRPPOMCsorter)
  522. AgRPKPsorted <- inner_join(POMCnull,KPnull) |> filter(
  523. (Wald_AgRP_vs_POMC_log2FoldChange < -lFCfilter &
  524. Wald_POMC_vs_KP_log2FoldChange > lFCfilter) &
  525. (abs(Wald_AgRP_vs_KP_log2FoldChange) < abs(Wald_AgRP_vs_POMC_log2FoldChange) &
  526. abs(Wald_AgRP_vs_KP_log2FoldChange) < abs(Wald_POMC_vs_KP_log2FoldChange))
  527. )
  528. AgRPKPsorter <- inner_join(AgRPnull,POMCnull) |> filter(
  529. (Wald_AgRP_vs_POMC_log2FoldChange < -lFCfilter &
  530. Wald_POMC_vs_KP_log2FoldChange > lFCfilter) &
  531. (abs(Wald_AgRP_vs_KP_log2FoldChange) < abs(Wald_AgRP_vs_POMC_log2FoldChange) &
  532. abs(Wald_AgRP_vs_KP_log2FoldChange) < abs(Wald_POMC_vs_KP_log2FoldChange))
  533. )
  534. AgRPKPsorted <- full_join(AgRPKPsorted,AgRPKPsorter)
  535. POMCKPsorted <- inner_join(AgRPnull,KPnull) |> filter(
  536. (Wald_AgRP_vs_POMC_log2FoldChange > lFCfilter &
  537. Wald_AgRP_vs_KP_log2FoldChange > lFCfilter) &
  538. (abs(Wald_POMC_vs_KP_log2FoldChange) < abs(Wald_AgRP_vs_KP_log2FoldChange) &
  539. abs(Wald_POMC_vs_KP_log2FoldChange) < abs(Wald_AgRP_vs_POMC_log2FoldChange))
  540. )
  541. POMCKPsorter <- inner_join(AgRPnull,POMCnull) |> filter(
  542. (Wald_AgRP_vs_POMC_log2FoldChange > lFCfilter &
  543. Wald_AgRP_vs_KP_log2FoldChange > lFCfilter) &
  544. (abs(Wald_POMC_vs_KP_log2FoldChange) < abs(Wald_AgRP_vs_KP_log2FoldChange) &
  545. abs(Wald_POMC_vs_KP_log2FoldChange) < abs(Wald_AgRP_vs_POMC_log2FoldChange))
  546. )
  547. POMCKPsorted <- full_join(POMCKPsorted,POMCKPsorter)
  548. AgRPnull <- anti_join(anti_join(anti_join(AgRPnull,AgRPPOMCsorted),AgRPKPsorted),POMCKPsorted)
  549. POMCnull <- anti_join(anti_join(anti_join(POMCnull,AgRPPOMCsorted),AgRPKPsorted),POMCKPsorted)
  550. KPnull <- anti_join(anti_join(anti_join(KPnull,AgRPPOMCsorted),AgRPKPsorted),POMCKPsorted)
  551. AgRPsorter <- POMCnull |> filter(
  552. Wald_AgRP_vs_KP_log2FoldChange < -lFCfilter &
  553. (means_AgRP > TPMfilter &
  554. rowSums((POMCnull[4:6]) >= rawfilter) >= 3) &
  555. (means_KP > TPMfilter &
  556. rowSums((POMCnull[9:11]) >= rawfilter) >= 3)
  557. )
  558. AgRPsorted <- full_join(AgRPsorted,AgRPsorter)
  559. AgRPsorter <- KPnull |> filter(
  560. Wald_AgRP_vs_POMC_log2FoldChange < -lFCfilter &
  561. (means_AgRP > TPMfilter &
  562. rowSums((KPnull[4:6]) >= rawfilter) >= 3) &
  563. (means_POMC > TPMfilter &
  564. rowSums((KPnull[7:8]) >= rawfilter) >= 2)
  565. )
  566. AgRPsorted <- full_join(AgRPsorted,AgRPsorter)
  567. POMCsorter <- AgRPnull |> filter(
  568. Wald_POMC_vs_KP_log2FoldChange < -lFCfilter &
  569. (means_POMC > TPMfilter &
  570. rowSums((AgRPnull[7:8]) >= rawfilter) >= 2) &
  571. (means_KP > TPMfilter &
  572. rowSums((AgRPnull[9:11]) >= rawfilter) >= 3)
  573. )
  574. POMCsorted <- full_join(POMCsorted,POMCsorter)
  575. POMCsorter <- KPnull |> filter(
  576. Wald_AgRP_vs_POMC_log2FoldChange > lFCfilter &
  577. (means_POMC > TPMfilter &
  578. rowSums((KPnull[7:8]) >= rawfilter) >= 2) &
  579. (means_AgRP > TPMfilter &
  580. rowSums((KPnull[4:6]) >= rawfilter) >= 3)
  581. )
  582. POMCsorted <- full_join(POMCsorted,POMCsorter)
  583. KPsorter <- POMCnull |> filter(
  584. Wald_AgRP_vs_KP_log2FoldChange > lFCfilter &
  585. (means_KP > TPMfilter &
  586. rowSums((POMCnull[9:11]) >= rawfilter) >= 3) &
  587. (means_AgRP > TPMfilter &
  588. rowSums((POMCnull[4:6]) >= rawfilter) >= 3)
  589. )
  590. KPsorted <- full_join(KPsorted,KPsorter)
  591. KPsorter <- AgRPnull |> filter(
  592. Wald_POMC_vs_KP_log2FoldChange > lFCfilter &
  593. (means_KP > TPMfilter &
  594. rowSums((AgRPnull[9:11]) >= rawfilter) >= 3) &
  595. (means_POMC > TPMfilter &
  596. rowSums((AgRPnull[7:8]) >= rawfilter) >= 2)
  597. )
  598. KPsorted <- full_join(KPsorted,KPsorter)
  599. AgRPnull <- anti_join(anti_join(AgRPnull,POMCsorted),KPsorted)
  600. POMCnull <- anti_join(anti_join(POMCnull,AgRPsorted),KPsorted)
  601. KPnull <- anti_join(anti_join(KPnull,POMCsorted),AgRPsorted)
  602. AgRPPOMCsorter <- KPnull |> filter(
  603. Wald_AgRP_vs_KP_log2FoldChange < -lFCfilter &
  604. Wald_POMC_vs_KP_log2FoldChange < -lFCfilter &
  605. (means_AgRP > TPMfilter &
  606. rowSums((KPnull[4:6]) >= rawfilter) >= 3)&
  607. (means_POMC > TPMfilter &
  608. rowSums((KPnull[7:8]) >= rawfilter) >= 2)
  609. )
  610. AgRPPOMCsorted <- full_join(AgRPPOMCsorted,AgRPPOMCsorter)
  611. AgRPKPsorter <- POMCnull |> filter(
  612. Wald_AgRP_vs_POMC_log2FoldChange < -lFCfilter &
  613. Wald_POMC_vs_KP_log2FoldChange > lFCfilter &
  614. (means_AgRP > TPMfilter &
  615. rowSums((POMCnull[4:6]) >= rawfilter) >= 3)&
  616. (means_KP > TPMfilter &
  617. rowSums((POMCnull[9:11]) >= rawfilter) >= 3)
  618. )
  619. AgRPKPsorted <- full_join(AgRPKPsorted,AgRPKPsorter)
  620. POMCKPsorter <- AgRPnull |> filter(
  621. Wald_AgRP_vs_KP_log2FoldChange > lFCfilter &
  622. Wald_AgRP_vs_POMC_log2FoldChange > lFCfilter &
  623. (means_KP > TPMfilter &
  624. rowSums((AgRPnull[9:11]) >= rawfilter) >= 3)&
  625. (means_POMC > TPMfilter &
  626. rowSums((AgRPnull[7:8]) >= rawfilter) >= 2)
  627. )
  628. POMCKPsorted <- full_join(POMCKPsorted,POMCKPsorter)
  629. Null <- full_join(AgRPnull,full_join(POMCnull,KPnull))
  630. Sorted <- full_join(full_join(full_join(full_join(full_join(AgRPsorted,AgRPPOMCsorted),AgRPKPsorted),POMCsorted),POMCKPsorted),KPsorted)
  631. AgRPPOMCKPsorted <- anti_join(Null,Sorted)
  632. datasorted <- anti_join(anti_join(anti_join(anti_join(anti_join(anti_join(anti_join(anti_join(anti_join(
  633. datasorter,AgRPsorted),POMCsorted),KPsorted),
  634. AgRPPOMCsorted),AgRPKPsorted),POMCKPsorted),
  635. AgRPnull),POMCnull),KPnull)
  636. AgRPenriched <- datasorted |> filter(
  637. (Wald_AgRP_vs_POMC_log2FoldChange < -lFCfilter |
  638. Wald_AgRP_vs_KP_log2FoldChange < -lFCfilter) &
  639. means_AgRP > TPMfilter &
  640. rowSums((datasorted[4:6]) > rawfilter) >= 3
  641. )
  642. POMCenriched <- datasorted |> filter(
  643. (Wald_AgRP_vs_POMC_log2FoldChange > lFCfilter |
  644. Wald_POMC_vs_KP_log2FoldChange < -lFCfilter) &
  645. means_POMC > TPMfilter &
  646. rowSums((datasorted[7:8]) > rawfilter) >= 2
  647. )
  648. KPenriched <- datasorted |> filter(
  649. (Wald_AgRP_vs_KP_log2FoldChange > lFCfilter |
  650. Wald_POMC_vs_KP_log2FoldChange > lFCfilter) &
  651. means_KP > TPMfilter &
  652. rowSums((datasorted[9:11]) > rawfilter) >= 3
  653. )
  654. AgRPPOMCsorter <- inner_join(AgRPenriched,POMCenriched)
  655. AgRPPOMCsorter <- AgRPPOMCsorter |> filter(
  656. abs(Wald_AgRP_vs_POMC_log2FoldChange) < abs(Wald_AgRP_vs_KP_log2FoldChange) &
  657. abs(Wald_AgRP_vs_POMC_log2FoldChange) < abs(Wald_POMC_vs_KP_log2FoldChange)
  658. )
  659. AgRPPOMCsorted <- full_join(AgRPPOMCsorted,AgRPPOMCsorter)
  660. AgRPKPsorter <- inner_join(AgRPenriched,KPenriched)
  661. AgRPKPsorter <- AgRPKPsorter |> filter(
  662. abs(Wald_AgRP_vs_KP_log2FoldChange) < abs(Wald_AgRP_vs_POMC_log2FoldChange) &
  663. abs(Wald_AgRP_vs_KP_log2FoldChange) < abs(Wald_POMC_vs_KP_log2FoldChange)
  664. )
  665. AgRPKPsorted <- full_join(AgRPKPsorted,AgRPKPsorter)
  666. POMCKPsorter <- inner_join(POMCenriched,KPenriched)
  667. POMCKPsorter <- POMCKPsorter |> filter(
  668. abs(Wald_POMC_vs_KP_log2FoldChange) < abs(Wald_AgRP_vs_POMC_log2FoldChange) &
  669. abs(Wald_POMC_vs_KP_log2FoldChange) < abs(Wald_AgRP_vs_KP_log2FoldChange)
  670. )
  671. POMCKPsorted <- full_join(POMCKPsorted,POMCKPsorter)
  672. AgRPsorter <- datasorted |> filter(
  673. (Wald_AgRP_vs_POMC_log2FoldChange < -lFCfilter &
  674. Wald_AgRP_vs_KP_log2FoldChange < -lFCfilter) &
  675. means_AgRP > TPMfilter &
  676. rowSums((datasorted[4:6]) > rawfilter) >= 3
  677. )
  678. POMCsorter <- datasorted |> filter(
  679. (Wald_AgRP_vs_POMC_log2FoldChange > lFCfilter &
  680. Wald_POMC_vs_KP_log2FoldChange < -lFCfilter) &
  681. means_POMC > TPMfilter &
  682. rowSums((datasorted[7:8]) > rawfilter) >= 2
  683. )
  684. KPsorter <- datasorted |> filter(
  685. (Wald_AgRP_vs_KP_log2FoldChange > lFCfilter &
  686. Wald_POMC_vs_KP_log2FoldChange > lFCfilter) &
  687. means_KP > TPMfilter &
  688. rowSums((datasorted[9:11]) > rawfilter) >= 3
  689. )
  690. AgRPsorter <- AgRPsorter |> filter(
  691. abs(Wald_AgRP_vs_POMC_log2FoldChange) > abs(Wald_POMC_vs_KP_log2FoldChange) &
  692. abs(Wald_AgRP_vs_KP_log2FoldChange) > abs(Wald_POMC_vs_KP_log2FoldChange)
  693. )
  694. POMCsorter <- POMCsorter |> filter(
  695. abs(Wald_AgRP_vs_POMC_log2FoldChange) > abs(Wald_AgRP_vs_KP_log2FoldChange) &
  696. abs(Wald_POMC_vs_KP_log2FoldChange) > abs(Wald_AgRP_vs_KP_log2FoldChange)
  697. )
  698. KPsorter <- KPsorter |> filter(
  699. abs(Wald_AgRP_vs_KP_log2FoldChange) > abs(Wald_AgRP_vs_POMC_log2FoldChange) &
  700. abs(Wald_POMC_vs_KP_log2FoldChange) > abs(Wald_AgRP_vs_POMC_log2FoldChange)
  701. )
  702. AgRPsorter <- anti_join(anti_join(AgRPsorter,AgRPPOMCsorter),AgRPKPsorter)
  703. POMCsorter <- anti_join(anti_join(POMCsorter,AgRPPOMCsorter),POMCKPsorter)
  704. KPsorter <- anti_join(anti_join(KPsorter,POMCKPsorter),AgRPKPsorter)
  705. AgRPsorted <- full_join(AgRPsorted,AgRPsorter)
  706. POMCsorted <- full_join(POMCsorted,POMCsorter)
  707. KPsorted <- full_join(KPsorted,KPsorter)
  708. AgRPPOMCKPsorter <- anti_join(datasorted, unique(full_join(full_join(full_join(full_join(full_join(
  709. AgRPsorted,POMCsorted),KPsorted),
  710. AgRPPOMCsorted),AgRPKPsorted),POMCKPsorted
  711. )))
  712. AgRPPOMCKPsorted <- full_join(AgRPPOMCKPsorted,AgRPPOMCKPsorter)
  713. sorted <- list(AgRPsorted,POMCsorted,KPsorted,AgRPPOMCsorted,AgRPKPsorted,POMCKPsorted,AgRPPOMCKPsorted)
  714. sortednames <- c("AgRPsorted","POMCsorted","KPsorted","AgRPPOMCsorted","AgRPKPsorted","POMCKPsorted","AGRPPOMCKPsorted")
  715. sorted_list <- list()
  716. for (x in 1:length(sorted)){
  717. sorted_list[[x]] <- assign(sortednames[x],sorted[[x]])
  718. }
  719. names(sorted_list) <- sortednames
  720. return(sorted_list)
  721. }
  722. sorted_list_rec <- sorter(data,rawfilter,TPMfilter,lFCfilter)
  723. write.xlsx(sorted_list_rec, file = paste0("11_Receptors_sorted_rawreadfilter",rawfilter,"_meanTPMfilter",TPMfilter,"_lFCfilter",lFCfilter,"_0523.xlsx"))
  724. #12.Receptors dotplots -Fig 7, Supplementary table 12####
  725. datasorter <- data.frame(Category_lists[[5]])
  726. datasorter <- datasorter |> filter(
  727. (means_AgRP > TPMfilter &
  728. rowSums((datasorter[4:6]) >= rawfilter) >= 3) |
  729. (means_POMC > TPMfilter &
  730. rowSums((datasorter[7:8]) >= rawfilter) >= 2) |
  731. (means_KP > TPMfilter &
  732. rowSums((datasorter[9:11]) >= rawfilter) >= 3)
  733. )
  734. datasorter = unique(datasorter)
  735. #write.xlsx(datasorter, file = paste0("12_Receptors_sorted_rawreadfilter",rawfilter,"_meanTPMfilter",TPMfilter,"_lFCfilter",lFCfilter,".xlsx"))
  736. colnames(datasorter)[29:31] <- c("mnAgRP","mnPOMC","mnKP")
  737. datasorter <- datasorter %>% mutate(max_mean = apply(datasorter[29:31], 1, max, na.rm=TRUE))
  738. dataG <- datasorter
  739. dataG <- dataG %>% arrange(desc(max_mean))
  740. dataG <- dataG %>% mutate(Position = row_number())
  741. dataH <- dataG %>%
  742. pivot_longer(cols = c(mnAgRP,mnPOMC, mnKP),
  743. names_to = "Cell_type",
  744. values_to = "TPM")
  745. dataH$Cell_type <- factor(dataH$Cell_type, levels = c("mnAgRP","mnPOMC", "mnKP"))
  746. dataM <- dataH
  747. list_of_plots = list()
  748. list_of_plots[[1]] <- ggplot(data = dataH[dataH$external_gene_name == "ACVR1C",], aes(reorder(external_gene_name,Position), Cell_type))+
  749. geom_point(aes(size = ifelse(TPM==0,NA,TPM), colour = TPM),)+
  750. scale_color_gradient2(low = '#0000FF', mid = '#FFCCFF', high = '#FF0000', midpoint = median(dataM$max_mean))+#, transform = "log2")+
  751. scale_size_area(max_size = 12, transform = "identity" )+
  752. theme_bw()+
  753. theme(axis.text.x=element_text(hjust=1))#, angle=45))
  754. dataH = dataH[dataH$external_gene_name != "ACVR1C",]
  755. list_of_plots[[2]] <- ggplot(data = dataH[1:45,], aes(reorder(external_gene_name,Position), Cell_type))+
  756. geom_point(aes(size = ifelse(TPM==0,NA,TPM), colour = TPM),)+
  757. scale_color_gradient2(low = '#0000FF', mid = '#FFCCFF', high = '#FF0000', midpoint = median(dataM$max_mean))+#, transform = "log2")+
  758. scale_size_area(max_size = 12, transform = "identity" )+
  759. theme_bw()+
  760. theme(axis.text.x=element_text(hjust=1))#, angle=45))
  761. dataH = dataH[-c(1:45),]
  762. for (x in 1:9) {
  763. a = x*63-62 #x*y-(y-1)
  764. b = x*63 #x*y
  765. dataI = dataH[a:b,]
  766. plot <- ggplot(data = dataI, aes(reorder(external_gene_name,Position), Cell_type))+
  767. geom_point(aes(size = ifelse(TPM==0,NA,TPM), colour = TPM),)+
  768. scale_color_gradient2(low = '#0000FF', mid = '#FFCCFF', high = '#FF0000', midpoint = median(dataM$max_mean))+#, transform = "log2")+
  769. scale_size_area(max_size = 12, transform = "identity" )+
  770. theme_bw()+
  771. theme(axis.text.x=element_text(hjust=1))#, angle=45))
  772. list_of_plots[[x+2]] <- assign(paste0(x+2, ". receptors"),plot)
  773. }
  774. ggsave(
  775. filename = "12_Receptors_0523.pdf",
  776. plot = marrangeGrob(list_of_plots, nrow=1, ncol=1),
  777. width = 11.5, height = 2.5
  778. )
  779. #13.GWAS sorted enrichment -Fig 6, Table 1, Supplementary table 10, 11####
  780. APfilter1 = rawfilter
  781. APfilter2 = TPMfilter
  782. A <- data.frame(read_excel("Visceral_Adipose_Tissue_Quantity.xlsx"))
  783. B <- data.frame(read_excel("Waist_Circumference.xlsx"))
  784. C <- data.frame(read_excel("Hip_Circumference.xlsx"))
  785. D <- data.frame(read_excel("Fat_Pad_Mass.xlsx"))
  786. E <- data.frame(read_excel("Overnutrition.xlsx"))
  787. F <- data.frame(read_excel("Abdominal_Adipose_Tissue_Measurement.xlsx"))
  788. G <- data.frame(read_excel("Body_Fat_Percentage.xlsx"))
  789. H <- data.frame(read_excel("Eating_Disorder.xlsx"))
  790. I <- data.frame(read_excel("Waist-Hip_Ratio.xlsx"))
  791. J <- data.frame(read_excel("Body_Mass_Index.xlsx"))
  792. K <- data.frame(read_excel("Metabolic_Syndrome.xlsx"))
  793. S <- data.frame(read_excel("BMI-adjusted_hip_circumference.tsv.xlsx"))
  794. T <- data.frame(read_excel("BMI-adjusted_waist_circumference.tsv.xlsx"))
  795. U <- data.frame(read_excel("Body_weight_without child traits.tsv.xlsx"))
  796. M <- data4
  797. M <- M |> filter(Wald_AgRP_vs_POMC_log2FoldChange < 1000 | Wald_AgRP_vs_KP_log2FoldChange < 1000 | Wald_POMC_vs_KP_log2FoldChange < 1000)
  798. a <- A$DISEASE.TRAIT %>% unique()
  799. b <- B$DISEASE.TRAIT %>% unique()
  800. c <- C$DISEASE.TRAIT %>% unique()
  801. d <- D$DISEASE.TRAIT %>% unique()
  802. e <- E$DISEASE.TRAIT %>% unique()
  803. f <- F$DISEASE.TRAIT %>% unique()
  804. g <- G$DISEASE.TRAIT %>% unique()
  805. h <- H$DISEASE.TRAIT %>% unique()
  806. i <- I$DISEASE.TRAIT %>% unique()
  807. j <- J$DISEASE.TRAIT %>% unique()
  808. k <- K$DISEASE.TRAIT %>% unique()
  809. s <- S$DISEASE.TRAIT %>% unique()
  810. t <- T$DISEASE.TRAIT %>% unique()
  811. u <- U$DISEASE.TRAIT %>% unique()
  812. A$CHR_ID <- as.character(A$CHR_ID)
  813. B$CHR_ID <- as.character(B$CHR_ID)
  814. C$CHR_ID <- as.character(C$CHR_ID)
  815. D$CHR_ID <- as.character(D$CHR_ID)
  816. E$CHR_ID <- as.character(E$CHR_ID)
  817. F$CHR_ID <- as.character(F$CHR_ID)
  818. G$CHR_ID <- as.character(G$CHR_ID)
  819. H$CHR_ID <- as.character(H$CHR_ID)
  820. I$CHR_ID <- as.character(I$CHR_ID)
  821. J$CHR_ID <- as.character(J$CHR_ID)
  822. K$CHR_ID <- as.character(K$CHR_ID)
  823. S$CHR_ID <- as.character(S$CHR_ID)
  824. T$CHR_ID <- as.character(T$CHR_ID)
  825. U$CHR_ID <- as.character(U$CHR_ID)
  826. A$CHR_POS <- as.character(A$CHR_POS)
  827. B$CHR_POS <- as.character(B$CHR_POS)
  828. C$CHR_POS <- as.character(C$CHR_POS)
  829. D$CHR_POS <- as.character(D$CHR_POS)
  830. E$CHR_POS <- as.character(E$CHR_POS)
  831. F$CHR_POS <- as.character(F$CHR_POS)
  832. G$CHR_POS <- as.character(G$CHR_POS)
  833. H$CHR_POS <- as.character(H$CHR_POS)
  834. I$CHR_POS <- as.character(I$CHR_POS)
  835. J$CHR_POS <- as.character(J$CHR_POS)
  836. K$CHR_POS <- as.character(K$CHR_POS)
  837. S$CHR_POS <- as.character(S$CHR_POS)
  838. T$CHR_POS <- as.character(T$CHR_POS)
  839. U$CHR_POS <- as.character(U$CHR_POS)
  840. A$RISK.ALLELE.FREQUENCY <- as.character(A$RISK.ALLELE.FREQUENCY)
  841. B$RISK.ALLELE.FREQUENCY <- as.character(B$RISK.ALLELE.FREQUENCY)
  842. C$RISK.ALLELE.FREQUENCY <- as.character(C$RISK.ALLELE.FREQUENCY)
  843. D$RISK.ALLELE.FREQUENCY <- as.character(D$RISK.ALLELE.FREQUENCY)
  844. E$RISK.ALLELE.FREQUENCY <- as.character(E$RISK.ALLELE.FREQUENCY)
  845. F$RISK.ALLELE.FREQUENCY <- as.character(F$RISK.ALLELE.FREQUENCY)
  846. G$RISK.ALLELE.FREQUENCY <- as.character(G$RISK.ALLELE.FREQUENCY)
  847. H$RISK.ALLELE.FREQUENCY <- as.character(H$RISK.ALLELE.FREQUENCY)
  848. I$RISK.ALLELE.FREQUENCY <- as.character(I$RISK.ALLELE.FREQUENCY)
  849. J$RISK.ALLELE.FREQUENCY <- as.character(J$RISK.ALLELE.FREQUENCY)
  850. K$RISK.ALLELE.FREQUENCY <- as.character(K$RISK.ALLELE.FREQUENCY)
  851. S$RISK.ALLELE.FREQUENCY <- as.character(S$RISK.ALLELE.FREQUENCY)
  852. T$RISK.ALLELE.FREQUENCY <- as.character(T$RISK.ALLELE.FREQUENCY)
  853. U$RISK.ALLELE.FREQUENCY <- as.character(U$RISK.ALLELE.FREQUENCY)
  854. L <- full_join(A,full_join(B,full_join(C,full_join(D,full_join(E,full_join(F,full_join(G,full_join(H,full_join(I,full_join(J,full_join(K,full_join(S,full_join(T,U)))))))))))))
  855. L <- unique(L)
  856. l <- L$MAPPED_TRAIT %>% unique()
  857. N <- L %>% filter(L$P.VALUE < 5*10^-8)#GWAS filter
  858. n <- N$SNP_GENE_IDS %>% unique()
  859. n <- n[is.na(n) == FALSE]
  860. n1 <- n[grepl(" - ",n) == FALSE]
  861. n11 <- n1[grepl(",",n1)]
  862. n12 <- n1[grepl(";",n1)]
  863. n1 <- n1[grepl(",",n1) == FALSE]
  864. n1 <- n1[grepl(";",n1) == FALSE]
  865. n1 <- n1[grepl(" x ",n1) == FALSE]
  866. n1 <- as.data.frame(n1)
  867. n12 <- as.data.frame(n12)
  868. n12 <- separate_longer_delim(cols = "n12", delim = "; ", n12) %>% unique()
  869. n1 <- full_join(n1, n12, by = join_by(n1 == n12))
  870. n11 <- as.data.frame(n11)
  871. n11 <- separate_longer_delim(cols = "n11", delim = ", ", n11) %>% unique()
  872. n1 <- full_join(n1, n11, by = join_by(n1 == n11))
  873. n1 <- unique(n1)
  874. M$means_AgRP <- rowMeans(M[,c(12:14)],na.rm = TRUE)
  875. M$means_POMC <- rowMeans(M[,c(15:16)],na.rm = TRUE)
  876. M$means_KP <- rowMeans(M[,c(17:19)],na.rm = TRUE)
  877. M$means_ALL <- rowMeans(M[,c(12:19)],na.rm = TRUE)
  878. sorted_list <- sorter(M,APfilter1,APfilter2,lFCfilter)
  879. AgRPgenelist <- sorted_list$AgRPsorted
  880. POMCgenelist <- sorted_list$POMCsorted
  881. KPgenelist <- sorted_list$KPsorted
  882. AgRPPOMCgenelist <- sorted_list$AgRPPOMCsorted
  883. AgRPKPgenelist <- sorted_list$AgRPKPsorted
  884. POMCKPgenelist <- sorted_list$POMCKPsorted
  885. AgRPPOMCKPgenelist <-sorted_list$AGRPPOMCKPsorted
  886. AgRPGWAS <- inner_join(AgRPgenelist, n1, by = join_by(Geneid == n1)) %>% dplyr::select(1,2,3) %>% mutate(popul = "AgRP")
  887. POMCGWAS <- inner_join(POMCgenelist, n1, by = join_by(Geneid == n1)) %>% dplyr::select(1,2,3) %>% mutate(popul = "POMC")
  888. KPGWAS <- inner_join(KPgenelist, n1, by = join_by(Geneid == n1)) %>% dplyr::select(1,2,3) %>% mutate(popul = "KP")
  889. AgRPPOMCGWAS <- inner_join(AgRPPOMCgenelist, n1, by = join_by(Geneid == n1)) %>% dplyr::select(1,2,3) %>% mutate(popul = "AgRP-POMC")
  890. AgRPKPGWAS <- inner_join(AgRPKPgenelist, n1, by = join_by(Geneid == n1)) %>% dplyr::select(1,2,3) %>% mutate(popul = "AgRP-KP")
  891. POMCKPGWAS <- inner_join(POMCKPgenelist, n1, by = join_by(Geneid == n1)) %>% dplyr::select(1,2,3) %>% mutate(popul = "POMC-KP")
  892. AgRPPOMCKPGWAS <-inner_join(AgRPPOMCKPgenelist, n1, by = join_by(Geneid == n1)) %>% dplyr::select(1,2,3) %>% mutate(popul = "AgRP-POMC-KP")
  893. GWAScelltype <- full_join(full_join(full_join(full_join(full_join(full_join(AgRPGWAS,POMCGWAS),KPGWAS),AgRPPOMCGWAS),AgRPKPGWAS),POMCKPGWAS),AgRPPOMCKPGWAS)
  894. N <- N %>% mutate(exact_gene = NA, searched_genes = NA, neuron_type = NA)
  895. for (x in 1:length(N$SNP_GENE_IDS)) {
  896. for (y in 1:length(GWAScelltype$Geneid)) {
  897. if(grepl(paste0("^", GWAScelltype[y,1], "$"), N$SNP_GENE_IDS[x]) > 0){
  898. N$exact_gene[x] = GWAScelltype[y,1]
  899. #N$searched_genes = #add gene string to dataframe cell, de itt nem kell
  900. N$neuron_type[x] = GWAScelltype[y,4]
  901. } else if(grepl(GWAScelltype[y,1], N$SNP_GENE_IDS[x]) > 0){
  902. N$searched_genes[x] = paste0(N$searched_genes[x], " _ ", GWAScelltype[y,1])
  903. if(is.na(N$neuron_type[x]) == TRUE){
  904. N$neuron_type[x] = GWAScelltype[y,4]
  905. }
  906. } else {}
  907. }
  908. }
  909. Q = list(A,B,C,D,E,F,G,H,I,J,K,S,T,U)
  910. for (x in 1:length(Q)) {
  911. Q[[x]] = left_join(Q[[x]],N)
  912. }
  913. q = c("VATQ","WC","HC","FPM","On","AATM","BFP","ED","WHR","BMI","MS","BaHC","BaWC","BWwoct")
  914. Trait_lists <- list()
  915. for (x in 1:length(q)){
  916. Trait_lists[[x]] <- assign(q[x],Q[[x]])
  917. }
  918. names(Trait_lists) <- q
  919. write.xlsx(Trait_lists, file = paste0("13_GWAS_trait_lists_rawreadfilter",APfilter1,"_meanTPMfilter",APfilter2,"_lFCfilter",lFCfilter,"_0523.xlsx"))#
  920. for (x in 1:length(Trait_lists)) {
  921. Trait_lists[[x]] <- Trait_lists[[x]] %>% arrange(P.VALUE) %>% arrange(SNP_GENE_IDS)
  922. for (y in 2:length(Trait_lists[[x]]$SNP_GENE_IDS)) {
  923. if (is.na(Trait_lists[[x]]$SNP_GENE_IDS[y]) ==FALSE & Trait_lists[[x]]$SNP_GENE_IDS[y] == Trait_lists[[x]]$SNP_GENE_IDS[y-1]){
  924. Trait_lists[[x]]$PUBMEDID[y] <- "XXXXXXXXXXXXXXX"
  925. }
  926. }
  927. Trait_lists[[x]] <- Trait_lists[[x]] %>% filter(PUBMEDID != "XXXXXXXXXXXXXXX") %>% filter(is.na(SNP_GENE_IDS) == FALSE)
  928. }
  929. write.xlsx(Trait_lists, file = paste0("13_GWAS_trait_lists_rawreadfilter",APfilter1,"_meanTPMfilter",APfilter2,"_lFCfilter",lFCfilter,"_UNIQUE_0523.xlsx"))#
  930. R = list(AgRPGWAS,POMCGWAS,KPGWAS,AgRPPOMCGWAS,AgRPKPGWAS,POMCKPGWAS,AgRPPOMCKPGWAS)
  931. for (x in 1:length(R)) {
  932. R[[x]] = left_join(R[[x]], M)
  933. }
  934. r = c("AgRPGWAS","POMCGWAS","KPGWAS","AgRPPOMCGWAS","AgRPKPGWAS","POMCKPGWAS","AgRPPOMCKPGWAS")
  935. AgRPPOMC_GWAS_lists <- list()
  936. for (x in 1:length(r)){
  937. AgRPPOMC_GWAS_lists[[x]] <- assign(r[x],R[[x]])
  938. }
  939. names(AgRPPOMC_GWAS_lists) <- r
  940. V = list(AgRPgenelist,POMCgenelist,KPgenelist,AgRPPOMCgenelist,AgRPKPgenelist,POMCKPgenelist,AgRPPOMCKPgenelist)
  941. for (x in 1:length(R)) {
  942. V[[x]] = left_join(V[[x]], R[[x]])
  943. }
  944. v = c("AgRPgenelist","POMCgenelist","KPgenelist","AgRPPOMCgenelist","AgRPKPgenelist","POMCKPgenelist","AgRPPOMCKPgenelist")
  945. AgRPPOMC_genelist_lists <- list()
  946. for (x in 1:length(v)){
  947. AgRPPOMC_genelist_lists[[x]] <- assign(v[x],V[[x]])
  948. }
  949. names(AgRPPOMC_genelist_lists) <- v
  950. Numbers <- data.frame(matrix(ncol=14,nrow=17, dimnames=list(NULL, q)))
  951. row.names(Numbers) <- c("Sign_SNP_GENE_IDS","Exact_gene_match","Exact_gene_match_AgRP","Exact_gene_match_POMC","Exact_gene_match_KP"
  952. ,"Exact_gene_match_AgRP_POMC","Exact_gene_match_AgRP_KP","Exact_gene_match_POMC_KP","Exact_gene_match_AgRP_POMC_KP"
  953. ,"Total_gene_match","Total_gene_match_AgRP","Total_gene_match_POMC","Total_gene_match_KP"
  954. ,"Total_gene_match_AgRP_POMC","Total_gene_match_AgRP_KP","Total_gene_match_POMC_KP","Total_gene_match_AgRP_POMC_KP")
  955. Numbers <- data.frame(t(Numbers))
  956. Genelists <- list()
  957. for (z in 1:length(Trait_lists)) {
  958. AA <- Trait_lists[[z]]
  959. AA <- AA %>% filter(P.VALUE < 5*10^-8)
  960. AA <- AA %>% dplyr::select(18,39,40,41) %>% unique()
  961. aa <- AA %>% dplyr::select(1) %>% unique()
  962. if(length(aa$SNP_GENE_IDS) != length(AA$SNP_GENE_IDS)){print("not unique genes ")
  963. print(z)}
  964. AA1 <- AA[is.na(AA$SNP_GENE_IDS)==FALSE,] %>% unique()
  965. Numbers$Sign_SNP_GENE_IDS[z] <- rbind(length(AA1$SNP_GENE_IDS))
  966. AA2 <- AA1[is.na(AA1$exact_gene)==FALSE,]
  967. Numbers$Exact_gene_match[z] <- length(AA2$SNP_GENE_IDS)
  968. AA3 <- AA2[grepl("AgRP-POMC", AA2$neuron_type) == FALSE &
  969. grepl("AgRP-KP", AA2$neuron_type) == FALSE &
  970. grepl("AgRP-POMC-KP", AA2$neuron_type) == FALSE &
  971. grepl("AgRP", AA2$neuron_type),]
  972. Numbers$Exact_gene_match_AgRP[z] <- length(AA3$SNP_GENE_IDS)
  973. AA4 <- AA2[grepl("AgRP-POMC", AA2$neuron_type) == FALSE &
  974. grepl("POMC-KP", AA2$neuron_type) == FALSE &
  975. grepl("AgRP-POMC-KP", AA2$neuron_type) == FALSE &
  976. grepl("POMC", AA2$neuron_type),]
  977. Numbers$Exact_gene_match_POMC[z] <- length(AA4$SNP_GENE_IDS)
  978. AA5 <- AA2[grepl("AgRP-KP", AA2$neuron_type) == FALSE &
  979. grepl("POMC-KP", AA2$neuron_type) == FALSE &
  980. grepl("AgRP-POMC-KP", AA2$neuron_type) == FALSE &
  981. grepl("KP", AA2$neuron_type),]
  982. Numbers$Exact_gene_match_KP[z] <- length(AA5$SNP_GENE_IDS)
  983. AA6 <- AA2[grepl("AgRP-POMC-KP", AA2$neuron_type) == FALSE &
  984. grepl("AgRP-POMC", AA2$neuron_type),]
  985. Numbers$Exact_gene_match_AgRP_POMC[z] <- length(AA6$SNP_GENE_IDS)
  986. AA7 <- AA2[grepl("AgRP-KP", AA2$neuron_type),]
  987. Numbers$Exact_gene_match_AgRP_KP[z] <- length(AA7$SNP_GENE_IDS)
  988. AA8 <- AA2[grepl("AgRP-POMC-KP", AA2$neuron_type) == FALSE &
  989. grepl("POMC-KP", AA2$neuron_type),]
  990. Numbers$Exact_gene_match_POMC_KP[z] <- length(AA8$SNP_GENE_IDS)
  991. AA9 <- AA2[grepl("AgRP-POMC-KP", AA2$neuron_type),]
  992. Numbers$Exact_gene_match_AgRP_POMC_KP[z] <- length(AA9$SNP_GENE_IDS)
  993. AA15 <- AA1[is.na(AA1$exact_gene) & is.na(AA1$searched_genes) ==FALSE, ]
  994. if (length(AA15$SNP_GENE_IDS) >0){
  995. #AA_neutype_sum_exceptions <- length(AA15$SNP_GENE_IDS)
  996. AA15$searched_genes <- gsub("NA _ ", "", AA15$searched_genes)
  997. aa15 <- AA15$searched_genes
  998. aa15 <- separate_longer_delim(AA15, cols = 'searched_genes', delim = " _ ") %>% unique()
  999. aa15 <- separate_longer_delim(aa15, cols = 'SNP_GENE_IDS', delim = ", ") %>% unique()
  1000. aa15 <- aa15[aa15$SNP_GENE_IDS == aa15$searched_genes,] %>% unique()
  1001. AA16 <- NA
  1002. if (is.na(aa15$searched_genes[1]) == FALSE) {
  1003. for (x in 1:length(aa15$searched_genes)) {
  1004. for (y in 1:length(AA15$SNP_GENE_IDS)) {
  1005. if (grepl(aa15$searched_genes[x], AA15$SNP_GENE_IDS[y])){
  1006. AA16 <- rbind(AA16, aa15[x,])
  1007. }}
  1008. }
  1009. AA16 <-AA16[is.na(AA16$SNP_GENE_IDS) == FALSE,]
  1010. AA16 <- unique(AA16)
  1011. AA2 <- rbind(AA2, AA16) %>% unique()
  1012. AA18 <- AA16[grepl("AgRP-POMC", AA16$neuron_type) == FALSE &
  1013. grepl("AgRP-KP", AA16$neuron_type) == FALSE &
  1014. grepl("AgRP-POMC-KP", AA16$neuron_type) == FALSE &
  1015. grepl("AgRP", AA16$neuron_type),]
  1016. AA3 <- rbind(AA3, AA18) %>% unique()
  1017. AA19 <- AA16[grepl("AgRP-POMC", AA16$neuron_type) == FALSE &
  1018. grepl("POMC-KP", AA16$neuron_type) == FALSE &
  1019. grepl("AgRP-POMC-KP", AA16$neuron_type) == FALSE &
  1020. grepl("POMC", AA16$neuron_type),]
  1021. AA4 <- rbind(AA4, AA19) %>% unique()
  1022. AA17 <- AA16[grepl("AgRP-KP", AA16$neuron_type) == FALSE &
  1023. grepl("POMC-KP", AA16$neuron_type) == FALSE &
  1024. grepl("AgRP-POMC-KP", AA16$neuron_type) == FALSE &
  1025. grepl("KP", AA16$neuron_type),]
  1026. AA5 <- rbind(AA5, AA17) %>% unique()
  1027. AA14 <- AA16[grepl("AgRP-POMC-KP", AA16$neuron_type) == FALSE &
  1028. grepl("AgRP-POMC", AA16$neuron_type),]
  1029. AA6 <- rbind(AA6, AA14) %>% unique()
  1030. AA13 <- AA16[grepl("AgRP-KP", AA16$neuron_type),]
  1031. AA7 <- rbind(AA7, AA13) %>% unique()
  1032. AA12 <- AA16[grepl("AgRP-POMC-KP", AA16$neuron_type) == FALSE &
  1033. grepl("POMC-KP", AA16$neuron_type),]
  1034. AA8 <- rbind(AA8, AA12) %>% unique()
  1035. AA11 <- AA16[grepl("AgRP-POMC-KP", AA16$neuron_type),]
  1036. AA9 <- rbind(AA9, AA11) %>% unique()
  1037. }}
  1038. Numbers$Total_gene_match[z] <- length(AA2$SNP_GENE_IDS)
  1039. Numbers$Total_gene_match_AgRP[z] <- length(AA3$SNP_GENE_IDS)
  1040. Numbers$Total_gene_match_POMC[z] <- length(AA4$SNP_GENE_IDS)
  1041. Numbers$Total_gene_match_KP[z] <- length(AA5$SNP_GENE_IDS)
  1042. Numbers$Total_gene_match_AgRP_POMC[z] <- length(AA6$SNP_GENE_IDS)
  1043. Numbers$Total_gene_match_AgRP_KP[z] <- length(AA7$SNP_GENE_IDS)
  1044. Numbers$Total_gene_match_POMC_KP[z] <- length(AA8$SNP_GENE_IDS)
  1045. Numbers$Total_gene_match_AgRP_POMC_KP[z] <- length(AA9$SNP_GENE_IDS)
  1046. AA20 <- AA2 %>% mutate(Geneid = paste(exact_gene, searched_genes)) %>% dplyr::select(5)
  1047. AA20$Geneid <- gsub(" NA", "", AA20$Geneid)
  1048. AA20$Geneid <- gsub("NA ", "", AA20$Geneid)
  1049. colnames(AA20) <- names(Trait_lists[z])
  1050. Genelists[[z]] <- assign(names(Trait_lists[z]),AA20)
  1051. }
  1052. Numbers <- Numbers %>% mutate(Traits = row.names(Numbers)) %>% dplyr::select(18,1:17)
  1053. write.xlsx(Numbers, file = paste0("13_GWAS_venn_numbers_rawreadfilter",APfilter1,"_meanTPMfilter",APfilter2,"_lFCfilter",lFCfilter,"_0523.xlsx"))#
  1054. for (x in 1:length(Genelists)) {
  1055. Genelists[[x]] <- Genelists[[x]] %>% mutate(Trait = names(Genelists[[x]]))
  1056. colnames(Genelists[[x]])[1] <- "Geneid"
  1057. }
  1058. for (x in 1:length(AgRPPOMC_GWAS_lists)) {
  1059. for (y in 1:length(Genelists)) {
  1060. AgRPPOMC_GWAS_lists[[x]] <- left_join(data.frame(AgRPPOMC_GWAS_lists[[x]]),data.frame(Genelists[[y]]))
  1061. colnames(AgRPPOMC_GWAS_lists[[x]])[length(colnames(AgRPPOMC_GWAS_lists[[x]]))] <- q[y]
  1062. }
  1063. AgRPPOMC_GWAS_lists[[x]] <- unique(AgRPPOMC_GWAS_lists[[x]])
  1064. }
  1065. write.xlsx(AgRPPOMC_GWAS_lists, file = paste0("13_AgRP-POMC_GWAS_lists_rawreadfilter",APfilter1,"_meanTPMfilter",APfilter2,"_lFCfilter",lFCfilter,".xlsx"))#
  1066. for (x in 1:length(AgRPPOMC_genelist_lists)) {
  1067. for (y in 1:length(Genelists)) {
  1068. AgRPPOMC_genelist_lists[[x]] <- left_join(data.frame(AgRPPOMC_genelist_lists[[x]]),data.frame(Genelists[[y]]))
  1069. colnames(AgRPPOMC_genelist_lists[[x]])[length(colnames(AgRPPOMC_genelist_lists[[x]]))] <- q[y]
  1070. }
  1071. AgRPPOMC_genelist_lists[[x]] <- unique(AgRPPOMC_genelist_lists[[x]])
  1072. }
  1073. write.xlsx(AgRPPOMC_genelist_lists, file = paste0("13_AgRP-POMC_genelist_lists_rawreadfilter",APfilter1,"_meanTPMfilter",APfilter2,"_lFCfilter",lFCfilter,".xlsx"))#
  1074. #14.GWAS Venn -Fig 6, Table 1, Supplementary table 10, 11####
  1075. fitlist <- list()
  1076. fitlist[[1]] <- euler(c('AgRP' = length(AgRPgenelist$Geneid),
  1077. 'POMC' = length(POMCgenelist$Geneid),
  1078. 'KP' = length(KPgenelist$Geneid),
  1079. 'AgRP&POMC' = length(AgRPPOMCgenelist$Geneid),
  1080. 'AgRP&KP' = length(AgRPKPgenelist$Geneid),
  1081. 'POMC&KP' = length(POMCKPgenelist$Geneid),
  1082. 'AgRP&POMC&KP' = length(AgRPPOMCKPgenelist$Geneid)
  1083. ))
  1084. fitlist[[2]] <- euler(c('AgRP' = length(AgRPGWAS$Geneid),
  1085. 'POMC' = length(POMCGWAS$Geneid),
  1086. 'KP' = length(KPGWAS$Geneid),
  1087. 'AgRP&POMC' = length(AgRPPOMCGWAS$Geneid),
  1088. 'AgRP&KP' = length(AgRPKPGWAS$Geneid),
  1089. 'POMC&KP' = length(POMCKPGWAS$Geneid),
  1090. 'AgRP&POMC&KP' = length(AgRPPOMCKPGWAS$Geneid)
  1091. ))
  1092. fitlist[[3]] <- euler(c('AgRP' = length(AgRPGWAS$Geneid)/length(AgRPgenelist$Geneid)*100,
  1093. 'POMC' = length(POMCGWAS$Geneid)/length(POMCgenelist$Geneid)*100,
  1094. 'KP' = length(KPGWAS$Geneid)/length(KPgenelist$Geneid)*100,
  1095. 'AgRP&POMC' = length(AgRPPOMCGWAS$Geneid)/length(AgRPPOMCgenelist$Geneid)*100,
  1096. 'AgRP&KP' = length(AgRPKPGWAS$Geneid)/length(AgRPKPgenelist$Geneid)*100,
  1097. 'POMC&KP' = length(POMCKPGWAS$Geneid)/length(POMCKPgenelist$Geneid)*100,
  1098. 'AgRP&POMC&KP' = length(AgRPPOMCKPGWAS$Geneid)/length(AgRPPOMCKPgenelist$Geneid)*100
  1099. ))
  1100. AgRP_receptors <- sorted_list_rec[[1]]
  1101. POMC_receptors <- sorted_list_rec[[2]]
  1102. KP_receptors <- sorted_list_rec[[3]]
  1103. AgRPPOMC_receptors <- sorted_list_rec[[4]]
  1104. AgRPKP_receptors <- sorted_list_rec[[5]]
  1105. POMCKP_receptors <- sorted_list_rec[[6]]
  1106. AgRPPOMCKP_receptors <- sorted_list_rec[[7]]
  1107. fitlist[[4]] <- euler(c('AgRP' = length(AgRP_receptors$Geneid),
  1108. 'POMC' = length(POMC_receptors$Geneid),
  1109. 'KP' = length(KP_receptors$Geneid),
  1110. 'AgRP&POMC' = length(AgRPPOMC_receptors$Geneid),
  1111. 'AgRP&KP' = length(AgRPKP_receptors$Geneid),
  1112. 'POMC&KP' = length(POMCKP_receptors$Geneid),
  1113. 'AgRP&POMC&KP' = length(AgRPPOMCKP_receptors$Geneid)
  1114. ))
  1115. AgRP_GWASreceptors <- inner_join(AgRPGWAS,AgRP_receptors[2])
  1116. POMC_GWASreceptors <- inner_join(POMCGWAS,POMC_receptors[2])
  1117. KP_GWASreceptors <- inner_join(KPGWAS,KP_receptors[2])
  1118. AgRPPOMC_GWASreceptors <- inner_join(AgRPPOMCGWAS,AgRPPOMC_receptors[2])
  1119. AgRPKP_GWASreceptors <- inner_join(AgRPKPGWAS,AgRPKP_receptors[2])
  1120. POMCKP_GWASreceptors <- inner_join(POMCKPGWAS,POMCKP_receptors[2])
  1121. AgRPPOMCKP_GWASreceptors <- inner_join(AgRPPOMCKPGWAS,AgRPPOMCKP_receptors[2])
  1122. fitlist[[5]] <- euler(c('AgRP' = length(AgRP_GWASreceptors$Geneid),
  1123. 'POMC' = length(POMC_GWASreceptors$Geneid),
  1124. 'KP' = length(KP_GWASreceptors$Geneid),
  1125. 'AgRP&POMC' = length(AgRPPOMC_GWASreceptors$Geneid),
  1126. 'AgRP&KP' = length(AgRPKP_GWASreceptors$Geneid),
  1127. 'POMC&KP' = length(POMCKP_GWASreceptors$Geneid),
  1128. 'AgRP&POMC&KP' = length(AgRPPOMCKP_GWASreceptors$Geneid)
  1129. ))
  1130. fitlist[[6]] <- euler(c('AgRP' = length(AgRP_receptors$Geneid)/length(AgRPgenelist$Geneid)*100,
  1131. 'POMC' = length(POMC_receptors$Geneid)/length(POMCgenelist$Geneid)*100,
  1132. 'KP' = length(KP_receptors$Geneid)/length(KPgenelist$Geneid)*100,
  1133. 'AgRP&POMC' = length(AgRPPOMC_receptors$Geneid)/length(AgRPPOMCgenelist$Geneid)*100,
  1134. 'AgRP&KP' = length(AgRPKP_receptors$Geneid)/length(AgRPKPgenelist$Geneid)*100,
  1135. 'POMC&KP' = length(POMCKP_receptors$Geneid)/length(POMCKPgenelist$Geneid)*100,
  1136. 'AgRP&POMC&KP' = length(AgRPPOMCKP_receptors$Geneid)/length(AgRPPOMCKPgenelist$Geneid)*100
  1137. ))
  1138. fitlist[[7]] <- euler(c('AgRP' = length(AgRP_GWASreceptors$Geneid)/length(AgRPGWAS$Geneid)*100,
  1139. 'POMC' = length(POMC_GWASreceptors$Geneid)/length(POMCGWAS$Geneid)*100,
  1140. 'KP' = length(KP_GWASreceptors$Geneid)/length(KPGWAS$Geneid)*100,
  1141. 'AgRP&POMC' = length(AgRPPOMC_GWASreceptors$Geneid)/length(AgRPPOMCGWAS$Geneid)*100,
  1142. # 'AgRP&KP' = length(AgRPKP_GWASreceptors$Geneid)/length(AgRPKPGWAS$Geneid)*100,
  1143. 'POMC&KP' = length(POMCKP_GWASreceptors$Geneid)/length(POMCKPGWAS$Geneid)*100,
  1144. 'AgRP&POMC&KP' = length(AgRPPOMCKP_GWASreceptors$Geneid)/length(AgRPPOMCKPGWAS$Geneid)*100
  1145. ))
  1146. fitlist[[8]] <- euler(c('AgRP' = length(AgRP_GWASreceptors$Geneid)/length(AgRP_receptors$Geneid)*100,
  1147. 'POMC' = length(POMC_GWASreceptors$Geneid)/length(POMC_receptors$Geneid)*100,
  1148. 'KP' = length(KP_GWASreceptors$Geneid)/length(KP_receptors$Geneid)*100,
  1149. 'AgRP&POMC' = length(AgRPPOMC_GWASreceptors$Geneid)/length(AgRPPOMC_receptors$Geneid)*100,
  1150. 'AgRP&KP' = length(AgRPKP_GWASreceptors$Geneid)/length(AgRPKP_receptors$Geneid)*100,
  1151. 'POMC&KP' = length(POMCKP_GWASreceptors$Geneid)/length(POMCKP_receptors$Geneid)*100,
  1152. 'AgRP&POMC&KP' = length(AgRPPOMCKP_GWASreceptors$Geneid)/length(AgRPPOMCKP_receptors$Geneid)*100
  1153. ))
  1154. plotnames <- c("Genelist co-expression |lFC|>1","GWAS list co-expression |lFC|>1","1./2. %",
  1155. "Receptor genes |lFC|>1","Receptor GWAS |lFC|>1","1./4. %","2./5. %","4./5. %")
  1156. plots <- list()
  1157. for (x in 1:length(plotnames)) {
  1158. main <- plotnames[x]
  1159. fit <- fitlist[[x]]
  1160. plots[[x]] = plot(fit, fill=c('coral2', 'steelblue','gold'),
  1161. quantities = TRUE,
  1162. labels = c('AgRP','POMC','KP'),
  1163. legend = FALSE,
  1164. main = main
  1165. )
  1166. }
  1167. pdf("14_GWAS_genelist_Venn_plots.pdf")
  1168. for (x in 1:length(plots)) {
  1169. print(plots[[x]])
  1170. }
  1171. dev.off()
  1172. #15. -Fig 9c####
  1173. data <- read_excel("Human_POMC_VL_DM_all_.xlsx") # ~ Supplementary table 16
  1174. data$external_gene_name <- ifelse(is.na(data$external_gene_name), data$Geneid, data$external_gene_name)
  1175. data2 <- data
  1176. #normalize based on TPM
  1177. data2 <- data2 %>% mutate(
  1178. N_POMC_1210L = (TPM_POMC_1210L - apply(data[c(12,14)], 1, min, na.rm=TRUE))/apply(data[c(12,14)], 1, max, na.rm=TRUE),
  1179. N_POMC_146L = (TPM_POMC_146L - apply(data[c(13,15)], 1, min, na.rm=TRUE))/apply(data[c(13,15)], 1, max, na.rm=TRUE),
  1180. N_POMC_1210M = (TPM_POMC_1210M - apply(data[c(12,14)], 1, min, na.rm=TRUE))/apply(data[c(12,14)], 1, max, na.rm=TRUE),
  1181. N_POMC_146M = (TPM_POMC_146M - apply(data[c(13,15)], 1, min, na.rm=TRUE))/apply(data[c(13,15)], 1, max, na.rm=TRUE)
  1182. )
  1183. data2 <- data2[(
  1184. (rowSums((data2[,8:9]) > 4) == 2 & rowMeans(data2[,12:13]) >= 10)| (rowSums((data2[,10:11]) > 4) == 2 & rowMeans(data2[,14:15]) >= 10)
  1185. ) , ]
  1186. data2 <- data2 %>% filter((lFC_POMC_1210*lFC_POMC_146) > 0)
  1187. data2 <- data2 %>% filter(
  1188. apply(data2[c(12,14)], 1, min, na.rm=TRUE) > 10 |apply(data2[c(13,15)], 1, min, na.rm=TRUE) > 10 )
  1189. #receptors
  1190. receptors <- categories[[5]]
  1191. data2 <- data.frame(unique(inner_join(data2, receptors, by = join_by(external_gene_name == Gene_symbol))))
  1192. data2 <- data2 %>% mutate(
  1193. p1210Ldev = N_POMC_1210L - N_POMC_1210M,
  1194. p146Ldev = N_POMC_146L - N_POMC_146M,
  1195. pLmean = (lFC_POMC_1210+lFC_POMC_146)/2,
  1196. pLdev = lFC_POMC_1210-lFC_POMC_146
  1197. )
  1198. data2 <- data2 %>%
  1199. filter(
  1200. abs(lFC_POMC_1210) > 0.2, #threshold
  1201. abs(lFC_POMC_146) > 0.2, #thresholds
  1202. abs(pLmean) > 0.5 #threshold
  1203. )
  1204. data2 <- data2 %>% arrange(rowMeans(data2[,24:25]))
  1205. data2 <- data2 %>% mutate(
  1206. position = as.numeric(row.names(data2))
  1207. )
  1208. rownames(data2) <- data2$external_gene_name
  1209. data3 <- data2 %>%
  1210. pivot_longer(cols = c(p1210Ldev,p146Ldev),
  1211. names_to = "Sample",
  1212. values_to = "Deviation")
  1213. data3$Sample <- factor(data3$Sample, levels = c("p1210Ldev","p146Ldev"))
  1214. data3 <- data3 %>% mutate(
  1215. external_gene_name = reorder(external_gene_name, position),
  1216. size_value = ifelse(Sample == "p1210Ldev",
  1217. sqrt(apply(data3[c(12,14)], 1, max, na.rm=TRUE)),
  1218. sqrt(apply(data3[c(13,15)], 1, max, na.rm=TRUE)))
  1219. )
  1220. p<- ggplot(data3, aes(y = reorder(external_gene_name, position), x = Deviation, color = Sample)) +
  1221. geom_segment(
  1222. aes(x = 0, xend = Deviation, y = reorder(external_gene_name, position), yend = reorder(external_gene_name, position)),
  1223. linewidth = 1,
  1224. alpha = 0.75
  1225. ) +
  1226. geom_point(
  1227. aes(size = size_value),
  1228. alpha = 0.95#,
  1229. ) +
  1230. scale_color_manual(values = c(
  1231. "p1210" = "#1b9e77",
  1232. "p146" = "#d95f02"
  1233. )) +
  1234. scale_size_continuous(
  1235. range = c(0.5, 10),
  1236. breaks = c(1,5, 10, 50, 100),
  1237. labels = c(1,25, 100, 2500, 10000),
  1238. name = "Expression"
  1239. ) +
  1240. labs(
  1241. x = "Enrichment",
  1242. y = NULL,
  1243. color = "Sample"
  1244. ) +
  1245. theme_minimal(base_size = 13) +
  1246. theme(
  1247. panel.grid.major.y = element_blank(),
  1248. legend.position = "right"
  1249. )
  1250. ggsave("lolliplot_VL_DM.pdf", plot = p, width = 24, height = 24, units = "cm")
  1251. #16.Human-mouse comparison -Fig 8, Supplementary table 13, 14, 15####
  1252. data <- data.frame(read_excel("H_M_Agrp_POMC_Neuropeptides.xlsx")) # ~ Supplementary table 14
  1253. #Fig 8a:
  1254. colnames(data)[c(7,8,9)] <- c("hAgRP","mAgRPfed","mAgRPfast")
  1255. data2 <- data %>% mutate(max_AgRP_mean = apply(data[c(7,8,9)], 1, max, na.rm=TRUE))
  1256. data2 <- data2 %>% filter(max_AgRP_mean > 40)
  1257. data2 <- data2 %>% arrange(desc(max_AgRP_mean))
  1258. data2 <- data2 %>% mutate(Position = row_number())
  1259. data3 <- data2 %>%
  1260. pivot_longer(cols = c(hAgRP,mAgRPfed, mAgRPfast),
  1261. names_to = "Cell_type",
  1262. values_to = "TPM")
  1263. data3$Cell_type <- factor(data3$Cell_type, levels = c("hAgRP","mAgRPfed","mAgRPfast"))
  1264. df_plot <- data3 %>%
  1265. group_by(GS_human) %>%
  1266. mutate(
  1267. gene_mean = mean(TPM, na.rm = TRUE),
  1268. deviation = (TPM - gene_mean) / gene_mean
  1269. ) %>%
  1270. ungroup() %>%
  1271. group_by(GS_human) %>%
  1272. mutate(
  1273. grand_mean = mean(TPM, na.rm = TRUE)
  1274. ) %>%
  1275. ungroup() %>%
  1276. mutate(
  1277. GS_human = fct_reorder(GS_human, grand_mean, .desc = FALSE),
  1278. size_value = sqrt(TPM)
  1279. )
  1280. p <- ggplot(df_plot, aes(y = GS_human, x = deviation, color = Cell_type)) +
  1281. geom_segment(
  1282. aes(x = 0, xend = deviation, y = GS_human, yend = GS_human),
  1283. linewidth = 1,
  1284. alpha = 0.75#,
  1285. ) +
  1286. geom_point(
  1287. aes(size = size_value),
  1288. alpha = 0.95#,
  1289. ) +
  1290. scale_color_manual(values = c(
  1291. "hAgRP" = "#1b9e77",
  1292. "mAgRPfed" = "#d95f02",
  1293. "mAgRPfast" = "#7570b3"
  1294. )) +
  1295. scale_size_continuous(
  1296. range = c(0.5, 10),
  1297. breaks = c(1,5, 10, 50, 100),
  1298. labels = c(1,25, 100, 2500, 10000)
  1299. )
  1300. ggsave("Human-Mouse_AgRP_Neuropeptides_lolliplot_forSCALES.pdf", plot = p, width = 24, height = 24, units = "cm") #for Fig 8a
  1301. df_long <- data2 %>%
  1302. pivot_longer(
  1303. cols = c(hAgRP,mAgRPfed, mAgRPfast),
  1304. names_to = "Cell_type",
  1305. values_to = "TPM"
  1306. ) %>%
  1307. mutate(TPM = as.numeric(TPM))
  1308. gene_order <- df_long %>%
  1309. group_by(GS_human) %>%
  1310. arrange(desc(max_AgRP_mean)) %>%
  1311. pull(GS_human)
  1312. df_scaled <- df_long %>%
  1313. group_by(GS_human) %>%
  1314. mutate(
  1315. gene_max = max(TPM, na.rm = TRUE),
  1316. TPM_0_10 = ifelse(gene_max == 0, 0, TPM / gene_max * 10)
  1317. ) %>%
  1318. ungroup() %>%
  1319. arrange(max_AgRP_mean) %>%
  1320. mutate(
  1321. GS_human = factor(GS_human, levels = unique(gene_order))
  1322. )
  1323. radar_df <- df_scaled %>%
  1324. select(Cell_type, GS_human, TPM_0_10) %>%
  1325. pivot_wider(names_from = GS_human, values_from = TPM_0_10) %>%
  1326. as.data.frame()
  1327. radar_df <- radar_df %>% mutate(xxx = NA) %>% select(24,1:23)
  1328. rownames(radar_df) <- radar_df$Cell_type
  1329. radar_df$Cell_type <- NULL
  1330. radar_plot_df <- rbind(
  1331. rep(10, ncol(radar_df)),
  1332. rep(0, ncol(radar_df)),
  1333. radar_df
  1334. )
  1335. colnames(radar_plot_df) <- colnames(radar_df)
  1336. rownames(radar_plot_df)[1:2] <- c("Max", "Min")
  1337. line_cols <- c(
  1338. "hAgRP" = "#1b9e77",
  1339. "mAgRPfed" = "#d95f02",
  1340. "mAgRPfast" = "#7570b3"
  1341. )
  1342. fill_cols <- c(
  1343. rgb(27, 158, 119, maxColorValue = 255, alpha = 70),
  1344. rgb(217, 95, 2, maxColorValue = 255, alpha = 70),
  1345. rgb(117, 112, 179, maxColorValue = 255, alpha = 70)
  1346. )
  1347. op <- par(mar = c(2, 2, 3, 2))
  1348. radarchart( # for Fig 8a
  1349. radar_plot_df,
  1350. axistype = 1,
  1351. seg = 5,
  1352. pcol = unname(line_cols[rownames(radar_df)]),
  1353. pfcol = fill_cols,
  1354. plwd = 2,
  1355. plty = 1,
  1356. cglcol = "grey70",
  1357. cglty = 1,
  1358. cglwd = 0.8,
  1359. axislabcol = "grey30",
  1360. vlcex = 0.9,
  1361. title = "Neuropeptides in AgRP"
  1362. )
  1363. legend(
  1364. "topright",
  1365. legend = rownames(radar_df),
  1366. col = unname(line_cols[rownames(radar_df)]),
  1367. lty = 1,
  1368. lwd = 2,
  1369. bty = "n",
  1370. cex = 0.9
  1371. )
  1372. par(op)
  1373. #Fig 8b:
  1374. colnames(data)[c(13,14,15)] <- c("hPOMC","mPOMCfed","mPOMCfast")
  1375. data2 <- data %>% mutate(max_POMC_mean = apply(data[c(13,14,15)], 1, max, na.rm=TRUE))
  1376. data2 <- data2 %>% filter(max_POMC_mean > 40)
  1377. data2 <- data2 %>% arrange(desc(max_AgRP_mean))
  1378. data2 <- data2 %>% mutate(Position = row_number())
  1379. data3 <- data2 %>%
  1380. pivot_longer(cols = c(hPOMC,mPOMCfed, mPOMCfast),
  1381. names_to = "Cell_type",
  1382. values_to = "TPM")
  1383. data3$Cell_type <- factor(data3$Cell_type, levels = c("hPOMC","mPOMCfed","mPOMCfast"))
  1384. df_plot <- data3 %>%
  1385. group_by(GS_human) %>%
  1386. mutate(
  1387. gene_mean = mean(TPM, na.rm = TRUE),
  1388. deviation = (TPM - gene_mean) / gene_mean
  1389. ) %>%
  1390. ungroup() %>%
  1391. group_by(GS_human) %>%
  1392. mutate(
  1393. grand_mean = mean(TPM, na.rm = TRUE)
  1394. ) %>%
  1395. ungroup() %>%
  1396. mutate(
  1397. GS_human = fct_reorder(GS_human, grand_mean, .desc = FALSE),
  1398. size_value = sqrt(TPM)
  1399. )
  1400. p <- ggplot(df_plot, aes(y = GS_human, x = deviation, color = Cell_type)) +
  1401. geom_segment(
  1402. aes(x = 0, xend = deviation, y = GS_human, yend = GS_human),
  1403. linewidth = 1,
  1404. alpha = 0.75
  1405. ) +
  1406. geom_point(
  1407. aes(size = size_value),
  1408. alpha = 0.95
  1409. ) +
  1410. scale_color_manual(values = c(
  1411. "hPOMC" = "#1b9e77",
  1412. "mPOMCfed" = "#d95f02",
  1413. "mPOMCfast" = "#7570b3"
  1414. )) +
  1415. scale_size_continuous(
  1416. range = c(0.5, 10),
  1417. breaks = c(1,5, 10, 50, 100),
  1418. labels = c(1,25, 100, 2500, 10000)
  1419. )
  1420. ggsave("Human-Mouse_POMC_Neuropeptides_lolliplot_forSCALES.pdf", plot = p, width = 24, height = 24, units = "cm")#for Fig 8b
  1421. df_long <- data2 %>%
  1422. pivot_longer(
  1423. cols = c(hPOMC,mPOMCfed, mPOMCfast),
  1424. names_to = "Cell_type",
  1425. values_to = "TPM"
  1426. ) %>%
  1427. mutate(TPM = as.numeric(TPM))
  1428. gene_order <- df_long %>%
  1429. group_by(GS_human) %>%
  1430. arrange(desc(max_POMC_mean)) %>%
  1431. pull(GS_human)
  1432. df_scaled <- df_long %>%
  1433. group_by(GS_human) %>%
  1434. mutate(
  1435. gene_max = max(TPM, na.rm = TRUE),
  1436. TPM_0_10 = ifelse(gene_max == 0, 0, TPM / gene_max * 10)
  1437. ) %>%
  1438. ungroup() %>%
  1439. arrange(max_POMC_mean) %>%
  1440. mutate(
  1441. GS_human = factor(GS_human, levels = unique(gene_order))
  1442. )
  1443. radar_df <- df_scaled %>%
  1444. select(Cell_type, GS_human, TPM_0_10) %>%
  1445. pivot_wider(names_from = GS_human, values_from = TPM_0_10) %>%
  1446. as.data.frame()
  1447. radar_df <- radar_df %>% mutate(xxx = NA) %>% select(25,1:24)
  1448. rownames(radar_df) <- radar_df$Cell_type
  1449. radar_df$Cell_type <- NULL
  1450. radar_plot_df <- rbind(
  1451. rep(10, ncol(radar_df)),
  1452. rep(0, ncol(radar_df)),
  1453. radar_df
  1454. )
  1455. colnames(radar_plot_df) <- colnames(radar_df)
  1456. rownames(radar_plot_df)[1:2] <- c("Max", "Min")
  1457. line_cols <- c(
  1458. "hPOMC" = "#1b9e77",
  1459. "mPOMCfed" = "#d95f02",
  1460. "mPOMCfast" = "#7570b3"
  1461. )
  1462. fill_cols <- c(
  1463. rgb(27, 158, 119, maxColorValue = 255, alpha = 70),
  1464. rgb(217, 95, 2, maxColorValue = 255, alpha = 70),
  1465. rgb(117, 112, 179, maxColorValue = 255, alpha = 70)
  1466. )
  1467. op <- par(mar = c(2, 2, 3, 2))
  1468. radarchart( #for Fig 8b
  1469. radar_plot_df,
  1470. axistype = 1,
  1471. seg = 5,
  1472. pcol = unname(line_cols[rownames(radar_df)]),
  1473. pfcol = fill_cols,
  1474. plwd = 2,
  1475. plty = 1,
  1476. cglcol = "grey70",
  1477. cglty = 1,
  1478. cglwd = 0.8,
  1479. axislabcol = "grey30",
  1480. vlcex = 0.9,
  1481. title = "Neuropeptides in POMC"
  1482. )
  1483. legend(
  1484. "topright",
  1485. legend = rownames(radar_df),
  1486. col = unname(line_cols[rownames(radar_df)]),
  1487. lty = 1,
  1488. lwd = 2,
  1489. bty = "n",
  1490. cex = 0.9
  1491. )
  1492. par(op)
  1493. #Fig 8c
  1494. dat1 <- read_excel("MAP_HUMAN_Mouse.xlsx") # ~ Supplementary table 13
  1495. dat1 <- dat1 %>% filter(GS_human == "INSR" | GS_human == "ACVR1C")
  1496. dat2 <- data.frame(read_excel("Sum_receptors.xlsx")) # ~ Supplementary table 15
  1497. data <- full_join(dat2, dat1)
  1498. colnames(data)[c(7,8,9)] <- c("hAgRP","mAgRPfed","mAgRPfast")
  1499. colnames(data)[c(13,14,15)] <- c("hPOMC","mPOMCfed","mPOMCfast")
  1500. data <- data %>% mutate(max_AgRP_mean = apply(data[c(7,8,9)], 1, max, na.rm=TRUE))
  1501. data <- data %>% mutate(max_POMC_mean = apply(data[c(13,14,15)], 1, max, na.rm=TRUE))
  1502. data <- data %>% mutate(max_mean = apply(data[c(7,8,9,13,14,15)], 1, max, na.rm=TRUE))
  1503. data2 <- data %>% filter(max_AgRP_mean > 40)
  1504. datah <- data2 %>% arrange(desc(hAgRP)) %>% head(40)
  1505. datam1 <- data2 %>% arrange(desc(mAgRPfed)) %>% head(40)
  1506. datam2 <- data2 %>% arrange(desc(mAgRPfast)) %>% head(40)
  1507. data3 <- data %>% filter(max_POMC_mean > 40)
  1508. datph <- data3 %>% arrange(desc(hPOMC)) %>% head(40)
  1509. datpm1 <- data3 %>% arrange(desc(mPOMCfed)) %>% head(40)
  1510. datpm2 <- data3 %>% arrange(desc(mPOMCfast)) %>% head(40)
  1511. data4 <- unique(full_join(datph,unique(full_join(datpm1,unique(full_join(datpm2,unique(full_join(datah,unique(full_join(datam1,datam2))))))))))
  1512. #data4 <- data4[-c(20,75,78),] #eliminate comparison duplicate - many-to-one
  1513. data4 <- data4 %>% arrange(desc(max_mean))
  1514. data4 <- data4 %>% mutate(Position = row_number())# %>% select(-c(46:50))
  1515. data5 <- data4 %>%
  1516. pivot_longer(cols = c(hAgRP,mAgRPfed, mAgRPfast, hPOMC, mPOMCfed, mPOMCfast),
  1517. names_to = "Cell_type",
  1518. values_to = "TPM")
  1519. data5$Cell_type <- factor(data5$Cell_type, levels = c("hAgRP","mAgRPfed", "mAgRPfast", "hPOMC","mPOMCfed","mPOMCfast"))
  1520. data5b <- data5 %>%
  1521. mutate(TPM_rel = ifelse(TPM == 0 | is.na(TPM), NA_real_, TPM / max_mean))
  1522. p <- ggplot(data = data5b, aes(reorder(GS_human, Position), Cell_type, colour = TPM)) +
  1523. geom_point(aes(size = TPM_rel)) +
  1524. scale_color_gradient2(low = "#0000FF",high = "#FF0000", mid = "#FFCCFF", midpoint = 100,transform = "log10",
  1525. limits = c(1, max(data5b$TPM, na.rm=TRUE)),
  1526. oob = squish) +
  1527. scale_size_area(max_size = 12) +
  1528. theme_bw() +
  1529. theme(axis.text.x = element_text(hjust = 1, angle = 90))
  1530. ggsave("Human-Mouse_top40_Receptors.pdf", plot = p, width = 100, height = 10, units = "cm") #Fig 8c

Human_AgRP_POMC_KP_ILCMSeq_codes.R at commit 52ffeb7, no license · at the source

Overview

Authors: Szabolcs Takács1, Katalin Skrapits1, Balázs Göcz1, Éva Rumpler1, Miklós Sárvári1, Barbara Göblyös1,2, Dalma Biri1, Szilárd Póliska3, Gergely Rácz4, András Matolcsy4, Erik Hrabovszky1
  1. Laboratory of Reproductive Neurobiology, Hun-Ren Institute of Experimental Medicine, Budapest, Hungary
  2. Roska Tamás Doctoral School of Sciences and Technology, Faculty of Information Technology and Bionics, Pázmány Péter Catholic University, Budapest, Hungary
  3. Department of Biochemistry and Molecular Biology, Faculty of Medicine, University of Debrecen, Debrecen, Hungary
  4. Department of Pathology and Experimental Cancer Research, Semmelweis University, Budapest, Hungary
Journal: Nature communications, volume 17, issue 1, article 9801
Dates: received 21 October 2025; accepted 5 August 2026; published online 15 August 2026
Type: Research article · Language: English
License: CC BY
Identifiers: DOI 10.1038/s41467-026-76688-w · PMID 42736279 · PMCID PMC13575109 · OpenAlex W7203530439
Open access: gold, a free copy (OpenAlex)
Status: code verified
Categories: genetics / omics (modality), histology / microscopy (modality), human (organism), cellular / molecular (subfield)
Methods: Statistics
Keywords: Molecular neuroscience, Hypothalamus
MeSH: Agouti-Related Protein*, Energy Metabolism*, Gene Expression Profiling*, Hypothalamus*, Neurons*, Pro-Opiomelanocortin*, Homeostasis, Humans, Male, Transcriptome (* major topic)
Topic: Regulation of Appetite and Obesity (Endocrine and Autonomic Systems, Neuroscience), according to OpenAlex
Funding: Nemzeti Kutatási, Fejlesztési és Innovációs Hivatal (NKFI Office) (152320, PD134837, 152847)
Citations: not cited yet (Europe PMC); 62 references in the paper
Research resources: RRID:AB_2492388

Abstract

We present and validate a pioneering ‘IHC/LCM-Seq’ method for transcriptome profiling of spatially defined neuronal cell types detected with immunohistochemistry in sections of formaldehyde-fixed human brains. Application of IHC/LCM-Seq to male human hypothalami enables the identification of 14,000–16,000 transcripts in agouti-related protein (AgRP) neurons, which drive appetite and energy storage, and proopiomelanocortin (POMC) neurons, which suppress feeding and promote energy expenditure. These cell types differ from each other, and from fertility-regulating kisspeptin neurons, in their distinct enrichments of co-transmitters, transcription factors, regulatory (lnc) RNAs and receptors. The AgRP neuron transcriptome is rich in receptors for proinflammatory cytokines, metabolic hormones and growth hormone, whereas POMC neurons express reproductive hormone-, glucagon-like peptide-, calcitonin-, and endocannabinoid receptors. IHC/LCM-Seq, a versatile spatial transcriptomic approach for characterizing cell types in postmortem human brain tissue, opens a new window onto the molecular mechanisms that regulate energy homeostasis and highlights potential pharmacological targets for weight-management strategies.

Reproduced under the paper's license (CC BY), from the paper cited above.

Repository

Its files are read in the Code ↔ Paper reader above, with 6 matches between paragraphs and lines of code.

goczbalazs/PRJNA1305226_1305334

License: none: the authors keep all their rights
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Commit: 52ffeb7eba3678a3fb7fae47592e80d4beb50835, 27 April 2026
Languages: R (3), Shell (1)
Size: 7 files, 4 scripts
Software Heritage: not archived
Found in: “Code availability”
Holds: README
Not found: license file, CITATION.cff, environment file, tests, continuous integration, documentation
Tools: tidyverse (3 files), DESeq2 (1 file), ggplot2 (1 file), ggpubr (1 file), pheatmap (1 file), STAR (1 file), Subread (featureCounts) (1 file)
Availability: 1 check, the latest on 27 September 2026: the link answers
  • 27 September 2026: the link answers
5 files

Code availability

Analyses were performed in R (v4.5.0). The main packages used were DESeq2 (v1.44.0), tidyverse (v2.0.0), ggplot2 (v3.5.2), cluster (v2.1.8.1), pheatmap (v1.0.12), EnhancedVolcano (v1.22.0), eulerr (v7.0.2), and fmsb (v0.7.6). Additional packages used for file handling and graphical formatting included openxlsx (v4.2.8), ggfortify (v0.4.17), RColorBrewer (v1.1-3), ggrepel (v0.9.6), gridExtra (v2.3), ggpubr (v0.6.0), and scales (v1.4.0). Custom scripts are available at https://github.com/goczbalazs/PRJNA1305226_1305334.

Reproduced under the paper's license (CC BY), from the paper cited above.

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:

  • 1 repository of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
  • 4 scripts, each with its path and the digest of its content;
  • 6 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

Data Availability Statement

The human RNA-seq data generated in this study have been deposited in the NCBI Sequence Read Archive under the BioProject accession codes PRJNA1305226 (http://www.ncbi.nlm.nih.gov/bioproject/?term=PRJNA1305226) for AgRP- and POMC-IR neurons, PRJNA1453244 (http://www.ncbi.nlm.nih.gov/bioproject/?term=PRJNA1453244) for dorsomedial and ventrolateral POMC-IR neurons, and PRJNA1305334 (http://www.ncbi.nlm.nih.gov/bioproject/?term=PRJNA1305334) for KP-IR neurons. Whole-transcriptome profiles of human AgRP-, POMC-, and KP-IR neurons generated in this study, including raw counts, TPM values, and DESeq2-derived log2 fold change and FDR statistics, are provided in Supplementary Data 5. Whole-transcriptome profiles of dorsomedial and ventrolateral POMC-IR neurons, including raw counts, TPM values, and log2 fold change, are provided in Supplementary Data 16. The publicly available murine RNA-seq data re-analyzed in this study are available in the NCBI Sequence Read Archive under the BioProject accession code PRJNA281954 (https://www.ncbi.nlm.nih.gov/bioproject/?term=PRJNA281954).

Analyses were performed in R (v4.5.0). The main packages used were DESeq2 (v1.44.0), tidyverse (v2.0.0), ggplot2 (v3.5.2), cluster (v2.1.8.1), pheatmap (v1.0.12), EnhancedVolcano (v1.22.0), eulerr (v7.0.2), and fmsb (v0.7.6). Additional packages used for file handling and graphical formatting included openxlsx (v4.2.8), ggfortify (v0.4.17), RColorBrewer (v1.1-3), ggrepel (v0.9.6), gridExtra (v2.3), ggpubr (v0.6.0), and scales (v1.4.0). Custom scripts are available at https://github.com/goczbalazs/PRJNA1305226_1305334.

Reproduced under the paper's license (CC BY), from the paper cited above.

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, 11 authors, 2 keywords, 10 MeSH terms, 1 funder, 52 references, 1 RRID.

Cite

This paper

Takács, S., Skrapits, K., Göcz, B., Rumpler, É., Sárvári, M., Göblyös, B., Biri, D., Póliska, S., Rácz, G., Matolcsy, A., & Hrabovszky, E. (2026). Transcriptome profiling of human hypothalamic agouti-related protein and proopiomelanocortin neurons regulating energy homeostasis. Nature communications, 17(1), 9801. https://doi.org/10.1038/s41467-026-76688-w

BibTeX

@article{takacs2026transcriptome,
author = {Takács, Szabolcs and Skrapits, Katalin and Göcz, Balázs and Rumpler, Éva and Sárvári, Miklós and Göblyös, Barbara and Biri, Dalma and Póliska, Szilárd and Rácz, Gergely and Matolcsy, András and Hrabovszky, Erik},
title = {{Transcriptome profiling of human hypothalamic agouti-related protein and proopiomelanocortin neurons regulating energy homeostasis}},
journal = {Nature communications},
year = {2026},
month = aug,
volume = {17},
number = {1},
pages = {9801},
publisher = {Nature Publishing Group},
issn = {2041-1723},
doi = {10.1038/s41467-026-76688-w},
url = {https://doi.org/10.1038/s41467-026-76688-w},
pmid = {42736279},
pmcid = {PMC13575109}
}

RIS

TY - JOUR
AU - Takács, Szabolcs
AU - Skrapits, Katalin
AU - Göcz, Balázs
AU - Rumpler, Éva
AU - Sárvári, Miklós
AU - Göblyös, Barbara
AU - Biri, Dalma
AU - Póliska, Szilárd
AU - Rácz, Gergely
AU - Matolcsy, András
AU - Hrabovszky, Erik
TI - Transcriptome profiling of human hypothalamic agouti-related protein and proopiomelanocortin neurons regulating energy homeostasis
T2 - Nature communications
J2 - Nat Commun
PY - 2026
DA - 2026/08/15
VL - 17
IS - 1
SP - 9801
SN - 2041-1723
PB - Nature Publishing Group
DO - 10.1038/s41467-026-76688-w
UR - https://doi.org/10.1038/s41467-026-76688-w
LA - en
ER -

CSL-JSON

{
"id": "10.1038/s41467-026-76688-w",
"type": "article-journal",
"title": "Transcriptome profiling of human hypothalamic agouti-related protein and proopiomelanocortin neurons regulating energy homeostasis",
"container-title": "Nature communications",
"author": [
{
"family": "Takács",
"given": "Szabolcs"
},
{
"family": "Skrapits",
"given": "Katalin"
},
{
"family": "Göcz",
"given": "Balázs"
},
{
"family": "Rumpler",
"given": "Éva"
},
{
"family": "Sárvári",
"given": "Miklós"
},
{
"family": "Göblyös",
"given": "Barbara"
},
{
"family": "Biri",
"given": "Dalma"
},
{
"family": "Póliska",
"given": "Szilárd"
},
{
"family": "Rácz",
"given": "Gergely"
},
{
"family": "Matolcsy",
"given": "András"
},
{
"family": "Hrabovszky",
"given": "Erik"
}
],
"container-title-short": "Nat Commun",
"volume": "17",
"issue": "1",
"page": "9801",
"DOI": "10.1038/s41467-026-76688-w",
"PMID": "42736279",
"PMCID": "PMC13575109",
"ISSN": "2041-1723",
"publisher": "Nature Publishing Group",
"URL": "https://doi.org/10.1038/s41467-026-76688-w",
"language": "en",
"issued": {
"date-parts": [
[
2026,
8,
15
]
]
}
}

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.1093/bioinformatics/btag592 [code]
Network-based stratification of allele-specific expression reveals patient subgroups in Huntington's disease.
Journal: Bioinformatics (Oxford, England)
In common: Subread (featureCounts), STAR, DESeq2, 4 other tools, genetics / omics, 4 references
[2] doi:10.1126/sciadv.aed2952 [code]
Activation of transposable elements is linked to a region- and cell type-specific interferon response in Parkinson's disease.
Journal: Science advances
In common: Subread (featureCounts), STAR, DESeq2, 4 other tools, cellular / molecular, 4 references
[3] doi:10.1038/s41586-026-10512-9 [code]
Astrocyte glucocorticoid receptor signalling restricts neuronal plasticity.
Journal: Nature
In common: Subread (featureCounts), STAR, DESeq2, 4 other tools, cellular / molecular, 2 references
[4] doi:10.21203/rs.3.rs-9927928/v1 [code]
Genome-wide and allele-resolved maps of the radial architecture of the mouse genome
Journal: Research Square (preprint)
In common: Subread (featureCounts), STAR, DESeq2, 4 other tools, genetics / omics, 2 references
[5] doi:10.1038/s41531-026-01287-x [code]
Faecalibacterium prausnitzii, depleted in the Parkinson's disease microbiome, improves motor deficits in α-synuclein overexpressing mice.
Journal: NPJ Parkinson's disease
In common: Subread (featureCounts), STAR, DESeq2, 3 other tools, cellular / molecular, 3 references
[6] doi:10.7554/elife.107393 [code]
Chromosome-scale genome assembly of the European common cuttlefish &lt;i&gt;Sepia officinalis&lt;/i&gt;.
Journal: eLife
In common: Subread (featureCounts), STAR, DESeq2, 3 other tools, cellular / molecular, 3 references
[7] 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 advances
In common: STAR, DESeq2, pheatmap, 3 other tools, cellular / molecular, 3 references
[8] doi:10.1038/s41380-026-03578-4 [code]
Assessing molecular gene by treatment interactions using a population of neural progenitors exposed to valproic acid and lithium.
Journal: Molecular psychiatry
In common: Subread (featureCounts), STAR, DESeq2, 3 other tools, genetics / omics, cellular / molecular, 1 reference
[9] doi:10.1038/s41467-026-73796-5 [code]
Cross-species transcriptomic analysis of rodent model fidelity to human mesial temporal lobe epilepsy.
Journal: Nature communications
In common: STAR, DESeq2, pheatmap, 3 other tools, genetics / omics, cellular / molecular, 2 references
[10] doi:10.1038/s41386-026-02406-1 [code]
Functional genomic profiling of schizophrenia-associated genes reveals key microglial regulators.
Journal: Neuropsychopharmacology : official publication of the American College of Neuropsychopharmacology
In common: STAR, DESeq2, pheatmap, 3 other tools, genetics / omics, cellular / molecular, 2 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.

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.