|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "code", |
| 5 | + "execution_count": 1, |
| 6 | + "id": "7eef7d2f-cc7f-4ab7-bd03-c242ea7ad280", |
| 7 | + "metadata": {}, |
| 8 | + "outputs": [ |
| 9 | + { |
| 10 | + "name": "stderr", |
| 11 | + "output_type": "stream", |
| 12 | + "text": [ |
| 13 | + "Loading required package: ggplot2\n", |
| 14 | + "\n", |
| 15 | + "Loading required package: ggrepel\n", |
| 16 | + "\n", |
| 17 | + "Registered S3 methods overwritten by 'ggalt':\n", |
| 18 | + " method from \n", |
| 19 | + " grid.draw.absoluteGrob ggplot2\n", |
| 20 | + " grobHeight.absoluteGrob ggplot2\n", |
| 21 | + " grobWidth.absoluteGrob ggplot2\n", |
| 22 | + " grobX.absoluteGrob ggplot2\n", |
| 23 | + " grobY.absoluteGrob ggplot2\n", |
| 24 | + "\n", |
| 25 | + "── \u001b[1mAttaching packages\u001b[22m ─────────────────────────────────────────────────────────────────────────────── tidyverse 1.3.2 ──\n", |
| 26 | + "\u001b[32m✔\u001b[39m \u001b[34mtibble \u001b[39m 3.1.8 \u001b[32m✔\u001b[39m \u001b[34mdplyr \u001b[39m 1.0.10\n", |
| 27 | + "\u001b[32m✔\u001b[39m \u001b[34mtidyr \u001b[39m 1.2.1 \u001b[32m✔\u001b[39m \u001b[34mstringr\u001b[39m 1.5.0 \n", |
| 28 | + "\u001b[32m✔\u001b[39m \u001b[34mreadr \u001b[39m 2.1.3 \u001b[32m✔\u001b[39m \u001b[34mforcats\u001b[39m 0.5.2 \n", |
| 29 | + "\u001b[32m✔\u001b[39m \u001b[34mpurrr \u001b[39m 1.0.0 \n", |
| 30 | + "── \u001b[1mConflicts\u001b[22m ────────────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──\n", |
| 31 | + "\u001b[31m✖\u001b[39m \u001b[34mdplyr\u001b[39m::\u001b[32mfilter()\u001b[39m masks \u001b[34mstats\u001b[39m::filter()\n", |
| 32 | + "\u001b[31m✖\u001b[39m \u001b[34mdplyr\u001b[39m::\u001b[32mlag()\u001b[39m masks \u001b[34mstats\u001b[39m::lag()\n" |
| 33 | + ] |
| 34 | + } |
| 35 | + ], |
| 36 | + "source": [ |
| 37 | + "setwd('../../')\n", |
| 38 | + "source('.Rprofile')\n", |
| 39 | + "setwd('./case/visium_xenium')\n", |
| 40 | + "\n", |
| 41 | + "library(EnhancedVolcano)\n", |
| 42 | + "library(tidyverse)" |
| 43 | + ] |
| 44 | + }, |
| 45 | + { |
| 46 | + "cell_type": "code", |
| 47 | + "execution_count": 2, |
| 48 | + "id": "e2d0b05f-f1bf-49d0-bd83-3d5d1df4b600", |
| 49 | + "metadata": {}, |
| 50 | + "outputs": [ |
| 51 | + { |
| 52 | + "name": "stderr", |
| 53 | + "output_type": "stream", |
| 54 | + "text": [ |
| 55 | + "\u001b[1m\u001b[22mNew names:\n", |
| 56 | + "\u001b[36m•\u001b[39m `` -> `...1`\n", |
| 57 | + "\u001b[1mRows: \u001b[22m\u001b[34m18056\u001b[39m \u001b[1mColumns: \u001b[22m\u001b[34m9\u001b[39m\n", |
| 58 | + "\u001b[36m──\u001b[39m \u001b[1mColumn specification\u001b[22m \u001b[36m────────────────────────────────────────────────────────────────────────────────────────────────\u001b[39m\n", |
| 59 | + "\u001b[1mDelimiter:\u001b[22m \",\"\n", |
| 60 | + "\u001b[31mchr\u001b[39m (2): No_name, Yes_name\n", |
| 61 | + "\u001b[32mdbl\u001b[39m (7): ...1, No_pval, No_logf, No_scor, Yes_pval, Yes_logf, Yes_scor\n", |
| 62 | + "\n", |
| 63 | + "\u001b[36mℹ\u001b[39m Use `spec()` to retrieve the full column specification for this data.\n", |
| 64 | + "\u001b[36mℹ\u001b[39m Specify the column types or set `show_col_types = FALSE` to quiet this message.\n", |
| 65 | + "Warning message:\n", |
| 66 | + "“Setting row names on a tibble is deprecated.”\n" |
| 67 | + ] |
| 68 | + } |
| 69 | + ], |
| 70 | + "source": [ |
| 71 | + "hvg <- read_csv('../../data/visium/breast/hvg_align.csv')\n", |
| 72 | + "hvg <- hvg[,c('Yes_name','Yes_pval','Yes_logf','Yes_scor')]\n", |
| 73 | + "rownames(hvg) <- hvg[['Yes_name']]\n", |
| 74 | + "colnames(hvg) <- c('Name','adj.Pval','logFC2','Score')" |
| 75 | + ] |
| 76 | + }, |
| 77 | + { |
| 78 | + "cell_type": "code", |
| 79 | + "execution_count": 4, |
| 80 | + "id": "d6f16112-c341-4bb3-8145-61cc9b83f946", |
| 81 | + "metadata": {}, |
| 82 | + "outputs": [], |
| 83 | + "source": [ |
| 84 | + "# top 25\n", |
| 85 | + "top25 <- hvg %>% filter(logFC2 > 1.5 & adj.Pval < 0.05) %>% arrange(-Score) %>% head(25) \n", |
| 86 | + "top25 <- as.vector(top25$Name)" |
| 87 | + ] |
| 88 | + }, |
| 89 | + { |
| 90 | + "cell_type": "code", |
| 91 | + "execution_count": 5, |
| 92 | + "id": "760219ac-3db1-4e5b-a8c9-4df9c57df114", |
| 93 | + "metadata": { |
| 94 | + "tags": [] |
| 95 | + }, |
| 96 | + "outputs": [ |
| 97 | + { |
| 98 | + "data": { |
| 99 | + "text/html": [ |
| 100 | + "<style>\n", |
| 101 | + ".list-inline {list-style: none; margin:0; padding: 0}\n", |
| 102 | + ".list-inline>li {display: inline-block}\n", |
| 103 | + ".list-inline>li:not(:last-child)::after {content: \"\\00b7\"; padding: 0 .5ex}\n", |
| 104 | + "</style>\n", |
| 105 | + "<ol class=list-inline><li>'STC2'</li><li>'TRH'</li><li>'CACNG4'</li><li>'TMEM47'</li><li>'MUCL1'</li><li>'RIMS4'</li><li>'AFF3'</li><li>'CPB1'</li><li>'MAGED2'</li><li>'STARD10'</li><li>'NOS1AP'</li><li>'NEK10'</li><li>'LDLRAD3'</li><li>'PHGR1'</li><li>'MAPT'</li><li>'EREG'</li><li>'IFI27'</li><li>'LAMA3'</li><li>'SULT2B1'</li><li>'TBC1D9'</li><li>'ADCY1'</li><li>'KIAA1324'</li><li>'AUTS2'</li><li>'FAM3B'</li><li>'MCCC2'</li></ol>\n" |
| 106 | + ], |
| 107 | + "text/latex": [ |
| 108 | + "\\begin{enumerate*}\n", |
| 109 | + "\\item 'STC2'\n", |
| 110 | + "\\item 'TRH'\n", |
| 111 | + "\\item 'CACNG4'\n", |
| 112 | + "\\item 'TMEM47'\n", |
| 113 | + "\\item 'MUCL1'\n", |
| 114 | + "\\item 'RIMS4'\n", |
| 115 | + "\\item 'AFF3'\n", |
| 116 | + "\\item 'CPB1'\n", |
| 117 | + "\\item 'MAGED2'\n", |
| 118 | + "\\item 'STARD10'\n", |
| 119 | + "\\item 'NOS1AP'\n", |
| 120 | + "\\item 'NEK10'\n", |
| 121 | + "\\item 'LDLRAD3'\n", |
| 122 | + "\\item 'PHGR1'\n", |
| 123 | + "\\item 'MAPT'\n", |
| 124 | + "\\item 'EREG'\n", |
| 125 | + "\\item 'IFI27'\n", |
| 126 | + "\\item 'LAMA3'\n", |
| 127 | + "\\item 'SULT2B1'\n", |
| 128 | + "\\item 'TBC1D9'\n", |
| 129 | + "\\item 'ADCY1'\n", |
| 130 | + "\\item 'KIAA1324'\n", |
| 131 | + "\\item 'AUTS2'\n", |
| 132 | + "\\item 'FAM3B'\n", |
| 133 | + "\\item 'MCCC2'\n", |
| 134 | + "\\end{enumerate*}\n" |
| 135 | + ], |
| 136 | + "text/markdown": [ |
| 137 | + "1. 'STC2'\n", |
| 138 | + "2. 'TRH'\n", |
| 139 | + "3. 'CACNG4'\n", |
| 140 | + "4. 'TMEM47'\n", |
| 141 | + "5. 'MUCL1'\n", |
| 142 | + "6. 'RIMS4'\n", |
| 143 | + "7. 'AFF3'\n", |
| 144 | + "8. 'CPB1'\n", |
| 145 | + "9. 'MAGED2'\n", |
| 146 | + "10. 'STARD10'\n", |
| 147 | + "11. 'NOS1AP'\n", |
| 148 | + "12. 'NEK10'\n", |
| 149 | + "13. 'LDLRAD3'\n", |
| 150 | + "14. 'PHGR1'\n", |
| 151 | + "15. 'MAPT'\n", |
| 152 | + "16. 'EREG'\n", |
| 153 | + "17. 'IFI27'\n", |
| 154 | + "18. 'LAMA3'\n", |
| 155 | + "19. 'SULT2B1'\n", |
| 156 | + "20. 'TBC1D9'\n", |
| 157 | + "21. 'ADCY1'\n", |
| 158 | + "22. 'KIAA1324'\n", |
| 159 | + "23. 'AUTS2'\n", |
| 160 | + "24. 'FAM3B'\n", |
| 161 | + "25. 'MCCC2'\n", |
| 162 | + "\n", |
| 163 | + "\n" |
| 164 | + ], |
| 165 | + "text/plain": [ |
| 166 | + " [1] \"STC2\" \"TRH\" \"CACNG4\" \"TMEM47\" \"MUCL1\" \"RIMS4\" \n", |
| 167 | + " [7] \"AFF3\" \"CPB1\" \"MAGED2\" \"STARD10\" \"NOS1AP\" \"NEK10\" \n", |
| 168 | + "[13] \"LDLRAD3\" \"PHGR1\" \"MAPT\" \"EREG\" \"IFI27\" \"LAMA3\" \n", |
| 169 | + "[19] \"SULT2B1\" \"TBC1D9\" \"ADCY1\" \"KIAA1324\" \"AUTS2\" \"FAM3B\" \n", |
| 170 | + "[25] \"MCCC2\" " |
| 171 | + ] |
| 172 | + }, |
| 173 | + "metadata": {}, |
| 174 | + "output_type": "display_data" |
| 175 | + } |
| 176 | + ], |
| 177 | + "source": [ |
| 178 | + "top25" |
| 179 | + ] |
| 180 | + }, |
| 181 | + { |
| 182 | + "cell_type": "code", |
| 183 | + "execution_count": 21, |
| 184 | + "id": "af31222e-4ef7-4b41-a7e3-da4db650aa06", |
| 185 | + "metadata": {}, |
| 186 | + "outputs": [], |
| 187 | + "source": [ |
| 188 | + "options(repr.plot.width=13, repr.plot.height=12)\n", |
| 189 | + "p1 <- EnhancedVolcano(hvg, lab = rownames(hvg), x = 'logFC2', y= 'adj.Pval', xlim = c(-6,6), ylim = c(0,6), FCcutoff = 1.5, pCutoff = 0.05, labSize =7,axisLabSize =24,\n", |
| 190 | + " colAlpha = 1,\n", |
| 191 | + " xlab = 'log2 fold change', ylab = 'log10 adjust P.value',\n", |
| 192 | + " # selectLab = top25,\n", |
| 193 | + " # col = c(\"grey30\", \"grey30\", \"grey30\", \"red2\"),\n", |
| 194 | + " # drawConnectors = TRUE,\n", |
| 195 | + " title = '', subtitle ='',\n", |
| 196 | + " pointSize = c(ifelse((hvg$\"logFC2\">1.5 |hvg$\"logFC2\"< -1.5) & hvg$\"adj.Pval\"<0.05 , 2.5, 1.5)),\n", |
| 197 | + " legendLabels =c('NS','log2FC only','adj.P only','Significant'),\n", |
| 198 | + " legendPosition = 'right',\n", |
| 199 | + " legendLabSize = 22)" |
| 200 | + ] |
| 201 | + }, |
| 202 | + { |
| 203 | + "cell_type": "code", |
| 204 | + "execution_count": 24, |
| 205 | + "id": "a0cd6eb7-9738-42a6-9cec-74a7efee1afb", |
| 206 | + "metadata": {}, |
| 207 | + "outputs": [], |
| 208 | + "source": [ |
| 209 | + "ggsave('./volcano.svg',p1, width = 13, height = 12)" |
| 210 | + ] |
| 211 | + } |
| 212 | + ], |
| 213 | + "metadata": { |
| 214 | + "kernelspec": { |
| 215 | + "display_name": "slat_r", |
| 216 | + "language": "R", |
| 217 | + "name": "slat_r" |
| 218 | + }, |
| 219 | + "language_info": { |
| 220 | + "codemirror_mode": "r", |
| 221 | + "file_extension": ".r", |
| 222 | + "mimetype": "text/x-r-source", |
| 223 | + "name": "R", |
| 224 | + "pygments_lexer": "r", |
| 225 | + "version": "4.1.3" |
| 226 | + } |
| 227 | + }, |
| 228 | + "nbformat": 4, |
| 229 | + "nbformat_minor": 5 |
| 230 | +} |
0 commit comments