{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "84c8862c-7ddd-4ef1-b5fb-27bdd8c948f6", "metadata": { "collapsed": true, "jupyter": { "outputs_hidden": true }, "tags": [] }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "------------------------------------------------------------------------------\n", "\n", "You have loaded plyr after dplyr - this is likely to cause problems.\n", "If you need functions from both plyr and dplyr, please load plyr first, then dplyr:\n", "library(plyr); library(dplyr)\n", "\n", "------------------------------------------------------------------------------\n", "\n", "\n", "Attaching package: ‘plyr’\n", "\n", "\n", "The following objects are masked from ‘package:dplyr’:\n", "\n", " arrange, count, desc, failwith, id, mutate, rename, summarise,\n", " summarize\n", "\n", "\n", "\n", "Attaching package: ‘purrr’\n", "\n", "\n", "The following object is masked from ‘package:plyr’:\n", "\n", " compact\n", "\n", "\n" ] } ], "source": [ "suppressPackageStartupMessages(library(readxl))\n", "suppressPackageStartupMessages(library(dplyr))\n", "suppressPackageStartupMessages(library(tidyr))\n", "suppressPackageStartupMessages(library(tibble))\n", "suppressPackageStartupMessages(library(ggplot2))\n", "suppressPackageStartupMessages(library(patchwork))\n", "suppressPackageStartupMessages(library(Seurat))\n", "suppressPackageStartupMessages(library(SeuratDisk))\n", "suppressPackageStartupMessages(library(stringr))\n", "library(hise)\n", "library(plyr)\n", "library(purrr)\n", "suppressPackageStartupMessages(library(H5weaver))\n", "library(parallel)" ] }, { "cell_type": "code", "execution_count": 2, "id": "414d81e9-23a1-4293-a12d-4557273eeb84", "metadata": { "collapsed": true, "jupyter": { "outputs_hidden": true }, "tags": [] }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Loading required package: SeuratObject\n", "\n", "Loading required package: sp\n", "\n", "\n", "Attaching package: ‘SeuratObject’\n", "\n", "\n", "The following object is masked from ‘package:base’:\n", "\n", " intersect\n", "\n", "\n", "Loading required package: Seurat\n", "\n" ] } ], "source": [ "reference <- readRDS(\"/home//jupyter/pbmc_multimodal_2023.rds\")\n", "#add level 2.5 labels\n", "l3 <- as.character(reference[[]]$celltype.l3)\n", "l2 <- as.character(reference[[]]$celltype.l2)\n", "l2.5 <- l2\n", "l2.5[l3 == \"Treg Naive\"] <- \"Treg Naive\"\n", "l2.5[l3 == \"Treg Memory\"] <- \"Treg Memory\"\n", "l2.5[l3 %in% c(\"CD8 TEM_4\", \"CD8 TEM_5\")] <- \"CD8 TEMRA\"\n", "reference <- AddMetaData(reference, metadata = l2.5, col.name = \"celltype.l2.5\")" ] }, { "cell_type": "code", "execution_count": 9, "id": "541385ef-05b2-4092-8698-3a184f6f7cbd", "metadata": { "tags": [] }, "outputs": [ { "data": { "text/html": [ "\n", "
  1. 'B7-H4'
  2. 'C5L2'
  3. 'Cadherin'
  4. 'CCR10'
  5. 'CD102'
  6. 'CD103'
  7. 'CD105'
  8. 'CD106'
  9. 'CD107a'
  10. 'CD109'
  11. 'CD110'
  12. 'CD112'
  13. 'CD115'
  14. 'CD117'
  15. 'CD119'
  16. 'CD11a/CD18'
  17. 'CD11b-1'
  18. 'CD11b-2'
  19. 'CD11c'
  20. 'CD122'
  21. 'CD123'
  22. 'CD124'
  23. 'CD126'
  24. 'CD127'
  25. 'CD13'
  26. 'CD133-1'
  27. 'CD133-2'
  28. 'CD134'
  29. 'CD135'
  30. 'CD137'
  31. 'CD138-1'
  32. 'CD138-2'
  33. 'CD14'
  34. 'CD140a'
  35. 'CD140b'
  36. 'CD141'
  37. 'CD142'
  38. 'CD144'
  39. 'CD146'
  40. 'CD15'
  41. 'CD152'
  42. 'CD154'
  43. 'CD155'
  44. 'CD158'
  45. 'CD158b'
  46. 'CD158e1'
  47. 'CD158f'
  48. 'CD16'
  49. 'CD161'
  50. 'CD163'
  51. 'CD164'
  52. 'CD169'
  53. 'CD171'
  54. 'CD172a'
  55. 'CD177'
  56. 'CD178'
  57. 'CD18'
  58. 'CD184'
  59. 'CD185'
  60. 'CD186'
  61. 'CD19'
  62. 'CD192'
  63. 'CD193'
  64. 'CD194'
  65. 'CD195'
  66. 'CD196'
  67. 'CD199'
  68. 'CD1a'
  69. 'CD1c'
  70. 'CD1d'
  71. 'CD2'
  72. 'CD20'
  73. 'CD200'
  74. 'CD201'
  75. 'CD202b'
  76. 'CD203c'
  77. 'CD204'
  78. 'CD205'
  79. 'CD206'
  80. 'CD207'
  81. 'CD209'
  82. 'CD21'
  83. 'CD22'
  84. 'CD223'
  85. 'CD226'
  86. 'CD235a'
  87. 'CD235ab'
  88. 'CD24'
  89. 'CD243'
  90. 'CD244'
  91. 'CD25'
  92. 'CD252'
  93. 'CD253'
  94. 'CD26-1'
  95. 'CD26-2'
  96. 'CD267'
  97. 'CD268'
  98. 'CD269'
  99. 'CD27'
  100. 'CD270'
  101. 'CD271'
  102. 'CD272'
  103. 'CD273'
  104. 'CD274'
  105. 'CD275-1'
  106. 'CD275-2'
  107. 'CD278'
  108. 'CD279'
  109. 'CD28'
  110. 'CD284'
  111. 'CD29'
  112. 'CD294'
  113. 'CD3-1'
  114. 'CD3-2'
  115. 'CD30'
  116. 'CD301'
  117. 'CD303'
  118. 'CD304'
  119. 'CD305'
  120. 'CD307c/FcRL3'
  121. 'CD307d'
  122. 'CD307e'
  123. 'CD309'
  124. 'CD31'
  125. 'CD314'
  126. 'CD319'
  127. 'CD324'
  128. 'CD325'
  129. 'CD335'
  130. 'CD337'
  131. 'CD338'
  132. 'CD34'
  133. 'CD340'
  134. 'CD35'
  135. 'CD354'
  136. 'CD357'
  137. 'CD36'
  138. 'CD366'
  139. 'CD370'
  140. 'CD38-1'
  141. 'CD38-2'
  142. 'CD39'
  143. 'CD4-1'
  144. 'CD4-2'
  145. 'CD40'
  146. 'CD41'
  147. 'CD42b'
  148. 'CD43'
  149. 'CD44-1'
  150. 'CD44-2'
  151. 'CD45-1'
  152. 'CD45-2'
  153. 'CD45RA'
  154. 'CD45RB'
  155. 'CD45RO'
  156. 'CD46'
  157. 'CD47'
  158. 'CD48'
  159. 'CD49a'
  160. 'CD49b'
  161. 'CD49d'
  162. 'CD52'
  163. 'CD54'
  164. 'CD55'
  165. 'CD56-1'
  166. 'CD56-2'
  167. 'CD57'
  168. 'CD59'
  169. 'CD61'
  170. 'CD62E'
  171. 'CD62P'
  172. 'CD63'
  173. 'CD64'
  174. 'CD66a/c/e'
  175. 'CD66b'
  176. 'CD68'
  177. 'CD69'
  178. 'CD70'
  179. 'CD71'
  180. 'CD72'
  181. 'CD73'
  182. 'CD79a'
  183. 'CD79b'
  184. 'CD8'
  185. 'CD80'
  186. 'CD81'
  187. 'CD83'
  188. 'CD85g'
  189. 'CD86'
  190. 'CD8a'
  191. 'CD9'
  192. 'CD90'
  193. 'CD93'
  194. 'CD95'
  195. 'CD96'
  196. 'CD98'
  197. 'CD99'
  198. 'CLEC12A'
  199. 'CLEC2'
  200. 'CX3CR1'
  201. 'Folate'
  202. 'Galectin-9'
  203. 'GP130'
  204. 'HLA-DR'
  205. 'IgD'
  206. 'IgM'
  207. 'Integrin-7'
  208. 'LOX-1'
  209. 'MERTK'
  210. 'Notch-1'
  211. 'Notch-2'
  212. 'Podoplanin'
  213. 'Rag-IgG2c'
  214. 'Rat-IgG1-1'
  215. 'Rat-IgG1-2'
  216. 'Rat-IgG2b'
  217. 'Siglec-8'
  218. 'TCR-1'
  219. 'TCR-2'
  220. 'TCR-V-2'
  221. 'TCR-V-24-J-18'
  222. 'TCR-V-7.2'
  223. 'TCR-V-9'
  224. 'TIGIT'
  225. 'TIM-4'
  226. 'TSLPR'
  227. 'VEGFR-3'
  228. 'XCR1'
\n" ], "text/latex": [ "\\begin{enumerate*}\n", "\\item 'B7-H4'\n", "\\item 'C5L2'\n", "\\item 'Cadherin'\n", "\\item 'CCR10'\n", "\\item 'CD102'\n", "\\item 'CD103'\n", "\\item 'CD105'\n", "\\item 'CD106'\n", "\\item 'CD107a'\n", "\\item 'CD109'\n", "\\item 'CD110'\n", "\\item 'CD112'\n", "\\item 'CD115'\n", "\\item 'CD117'\n", "\\item 'CD119'\n", "\\item 'CD11a/CD18'\n", "\\item 'CD11b-1'\n", "\\item 'CD11b-2'\n", "\\item 'CD11c'\n", "\\item 'CD122'\n", "\\item 'CD123'\n", "\\item 'CD124'\n", "\\item 'CD126'\n", "\\item 'CD127'\n", "\\item 'CD13'\n", "\\item 'CD133-1'\n", "\\item 'CD133-2'\n", "\\item 'CD134'\n", "\\item 'CD135'\n", "\\item 'CD137'\n", "\\item 'CD138-1'\n", "\\item 'CD138-2'\n", "\\item 'CD14'\n", "\\item 'CD140a'\n", "\\item 'CD140b'\n", "\\item 'CD141'\n", "\\item 'CD142'\n", "\\item 'CD144'\n", "\\item 'CD146'\n", "\\item 'CD15'\n", "\\item 'CD152'\n", "\\item 'CD154'\n", "\\item 'CD155'\n", "\\item 'CD158'\n", "\\item 'CD158b'\n", "\\item 'CD158e1'\n", "\\item 'CD158f'\n", "\\item 'CD16'\n", "\\item 'CD161'\n", "\\item 'CD163'\n", "\\item 'CD164'\n", "\\item 'CD169'\n", "\\item 'CD171'\n", "\\item 'CD172a'\n", "\\item 'CD177'\n", "\\item 'CD178'\n", "\\item 'CD18'\n", "\\item 'CD184'\n", "\\item 'CD185'\n", "\\item 'CD186'\n", "\\item 'CD19'\n", "\\item 'CD192'\n", "\\item 'CD193'\n", "\\item 'CD194'\n", "\\item 'CD195'\n", "\\item 'CD196'\n", "\\item 'CD199'\n", "\\item 'CD1a'\n", "\\item 'CD1c'\n", "\\item 'CD1d'\n", "\\item 'CD2'\n", "\\item 'CD20'\n", "\\item 'CD200'\n", "\\item 'CD201'\n", "\\item 'CD202b'\n", "\\item 'CD203c'\n", "\\item 'CD204'\n", "\\item 'CD205'\n", "\\item 'CD206'\n", "\\item 'CD207'\n", "\\item 'CD209'\n", "\\item 'CD21'\n", "\\item 'CD22'\n", "\\item 'CD223'\n", "\\item 'CD226'\n", "\\item 'CD235a'\n", "\\item 'CD235ab'\n", "\\item 'CD24'\n", "\\item 'CD243'\n", "\\item 'CD244'\n", "\\item 'CD25'\n", "\\item 'CD252'\n", "\\item 'CD253'\n", "\\item 'CD26-1'\n", "\\item 'CD26-2'\n", "\\item 'CD267'\n", "\\item 'CD268'\n", "\\item 'CD269'\n", "\\item 'CD27'\n", "\\item 'CD270'\n", "\\item 'CD271'\n", "\\item 'CD272'\n", "\\item 'CD273'\n", "\\item 'CD274'\n", "\\item 'CD275-1'\n", "\\item 'CD275-2'\n", "\\item 'CD278'\n", "\\item 'CD279'\n", "\\item 'CD28'\n", "\\item 'CD284'\n", "\\item 'CD29'\n", "\\item 'CD294'\n", "\\item 'CD3-1'\n", "\\item 'CD3-2'\n", "\\item 'CD30'\n", "\\item 'CD301'\n", "\\item 'CD303'\n", "\\item 'CD304'\n", "\\item 'CD305'\n", "\\item 'CD307c/FcRL3'\n", "\\item 'CD307d'\n", "\\item 'CD307e'\n", "\\item 'CD309'\n", "\\item 'CD31'\n", "\\item 'CD314'\n", "\\item 'CD319'\n", "\\item 'CD324'\n", "\\item 'CD325'\n", "\\item 'CD335'\n", "\\item 'CD337'\n", "\\item 'CD338'\n", "\\item 'CD34'\n", "\\item 'CD340'\n", "\\item 'CD35'\n", "\\item 'CD354'\n", "\\item 'CD357'\n", "\\item 'CD36'\n", "\\item 'CD366'\n", "\\item 'CD370'\n", "\\item 'CD38-1'\n", "\\item 'CD38-2'\n", "\\item 'CD39'\n", "\\item 'CD4-1'\n", "\\item 'CD4-2'\n", "\\item 'CD40'\n", "\\item 'CD41'\n", "\\item 'CD42b'\n", "\\item 'CD43'\n", "\\item 'CD44-1'\n", "\\item 'CD44-2'\n", "\\item 'CD45-1'\n", "\\item 'CD45-2'\n", "\\item 'CD45RA'\n", "\\item 'CD45RB'\n", "\\item 'CD45RO'\n", "\\item 'CD46'\n", "\\item 'CD47'\n", "\\item 'CD48'\n", "\\item 'CD49a'\n", "\\item 'CD49b'\n", "\\item 'CD49d'\n", "\\item 'CD52'\n", "\\item 'CD54'\n", "\\item 'CD55'\n", "\\item 'CD56-1'\n", "\\item 'CD56-2'\n", "\\item 'CD57'\n", "\\item 'CD59'\n", "\\item 'CD61'\n", "\\item 'CD62E'\n", "\\item 'CD62P'\n", "\\item 'CD63'\n", "\\item 'CD64'\n", "\\item 'CD66a/c/e'\n", "\\item 'CD66b'\n", "\\item 'CD68'\n", "\\item 'CD69'\n", "\\item 'CD70'\n", "\\item 'CD71'\n", "\\item 'CD72'\n", "\\item 'CD73'\n", "\\item 'CD79a'\n", "\\item 'CD79b'\n", "\\item 'CD8'\n", "\\item 'CD80'\n", "\\item 'CD81'\n", "\\item 'CD83'\n", "\\item 'CD85g'\n", "\\item 'CD86'\n", "\\item 'CD8a'\n", "\\item 'CD9'\n", "\\item 'CD90'\n", "\\item 'CD93'\n", "\\item 'CD95'\n", "\\item 'CD96'\n", "\\item 'CD98'\n", "\\item 'CD99'\n", "\\item 'CLEC12A'\n", "\\item 'CLEC2'\n", "\\item 'CX3CR1'\n", "\\item 'Folate'\n", "\\item 'Galectin-9'\n", "\\item 'GP130'\n", "\\item 'HLA-DR'\n", "\\item 'IgD'\n", "\\item 'IgM'\n", "\\item 'Integrin-7'\n", "\\item 'LOX-1'\n", "\\item 'MERTK'\n", "\\item 'Notch-1'\n", "\\item 'Notch-2'\n", "\\item 'Podoplanin'\n", "\\item 'Rag-IgG2c'\n", "\\item 'Rat-IgG1-1'\n", "\\item 'Rat-IgG1-2'\n", "\\item 'Rat-IgG2b'\n", "\\item 'Siglec-8'\n", "\\item 'TCR-1'\n", "\\item 'TCR-2'\n", "\\item 'TCR-V-2'\n", "\\item 'TCR-V-24-J-18'\n", "\\item 'TCR-V-7.2'\n", "\\item 'TCR-V-9'\n", "\\item 'TIGIT'\n", "\\item 'TIM-4'\n", "\\item 'TSLPR'\n", "\\item 'VEGFR-3'\n", "\\item 'XCR1'\n", "\\end{enumerate*}\n" ], "text/markdown": [ "1. 'B7-H4'\n", "2. 'C5L2'\n", "3. 'Cadherin'\n", "4. 'CCR10'\n", "5. 'CD102'\n", "6. 'CD103'\n", "7. 'CD105'\n", "8. 'CD106'\n", "9. 'CD107a'\n", "10. 'CD109'\n", "11. 'CD110'\n", "12. 'CD112'\n", "13. 'CD115'\n", "14. 'CD117'\n", "15. 'CD119'\n", "16. 'CD11a/CD18'\n", "17. 'CD11b-1'\n", "18. 'CD11b-2'\n", "19. 'CD11c'\n", "20. 'CD122'\n", "21. 'CD123'\n", "22. 'CD124'\n", "23. 'CD126'\n", "24. 'CD127'\n", "25. 'CD13'\n", "26. 'CD133-1'\n", "27. 'CD133-2'\n", "28. 'CD134'\n", "29. 'CD135'\n", "30. 'CD137'\n", "31. 'CD138-1'\n", "32. 'CD138-2'\n", "33. 'CD14'\n", "34. 'CD140a'\n", "35. 'CD140b'\n", "36. 'CD141'\n", "37. 'CD142'\n", "38. 'CD144'\n", "39. 'CD146'\n", "40. 'CD15'\n", "41. 'CD152'\n", "42. 'CD154'\n", "43. 'CD155'\n", "44. 'CD158'\n", "45. 'CD158b'\n", "46. 'CD158e1'\n", "47. 'CD158f'\n", "48. 'CD16'\n", "49. 'CD161'\n", "50. 'CD163'\n", "51. 'CD164'\n", "52. 'CD169'\n", "53. 'CD171'\n", "54. 'CD172a'\n", "55. 'CD177'\n", "56. 'CD178'\n", "57. 'CD18'\n", "58. 'CD184'\n", "59. 'CD185'\n", "60. 'CD186'\n", "61. 'CD19'\n", "62. 'CD192'\n", "63. 'CD193'\n", "64. 'CD194'\n", "65. 'CD195'\n", "66. 'CD196'\n", "67. 'CD199'\n", "68. 'CD1a'\n", "69. 'CD1c'\n", "70. 'CD1d'\n", "71. 'CD2'\n", "72. 'CD20'\n", "73. 'CD200'\n", "74. 'CD201'\n", "75. 'CD202b'\n", "76. 'CD203c'\n", "77. 'CD204'\n", "78. 'CD205'\n", "79. 'CD206'\n", "80. 'CD207'\n", "81. 'CD209'\n", "82. 'CD21'\n", "83. 'CD22'\n", "84. 'CD223'\n", "85. 'CD226'\n", "86. 'CD235a'\n", "87. 'CD235ab'\n", "88. 'CD24'\n", "89. 'CD243'\n", "90. 'CD244'\n", "91. 'CD25'\n", "92. 'CD252'\n", "93. 'CD253'\n", "94. 'CD26-1'\n", "95. 'CD26-2'\n", "96. 'CD267'\n", "97. 'CD268'\n", "98. 'CD269'\n", "99. 'CD27'\n", "100. 'CD270'\n", "101. 'CD271'\n", "102. 'CD272'\n", "103. 'CD273'\n", "104. 'CD274'\n", "105. 'CD275-1'\n", "106. 'CD275-2'\n", "107. 'CD278'\n", "108. 'CD279'\n", "109. 'CD28'\n", "110. 'CD284'\n", "111. 'CD29'\n", "112. 'CD294'\n", "113. 'CD3-1'\n", "114. 'CD3-2'\n", "115. 'CD30'\n", "116. 'CD301'\n", "117. 'CD303'\n", "118. 'CD304'\n", "119. 'CD305'\n", "120. 'CD307c/FcRL3'\n", "121. 'CD307d'\n", "122. 'CD307e'\n", "123. 'CD309'\n", "124. 'CD31'\n", "125. 'CD314'\n", "126. 'CD319'\n", "127. 'CD324'\n", "128. 'CD325'\n", "129. 'CD335'\n", "130. 'CD337'\n", "131. 'CD338'\n", "132. 'CD34'\n", "133. 'CD340'\n", "134. 'CD35'\n", "135. 'CD354'\n", "136. 'CD357'\n", "137. 'CD36'\n", "138. 'CD366'\n", "139. 'CD370'\n", "140. 'CD38-1'\n", "141. 'CD38-2'\n", "142. 'CD39'\n", "143. 'CD4-1'\n", "144. 'CD4-2'\n", "145. 'CD40'\n", "146. 'CD41'\n", "147. 'CD42b'\n", "148. 'CD43'\n", "149. 'CD44-1'\n", "150. 'CD44-2'\n", "151. 'CD45-1'\n", "152. 'CD45-2'\n", "153. 'CD45RA'\n", "154. 'CD45RB'\n", "155. 'CD45RO'\n", "156. 'CD46'\n", "157. 'CD47'\n", "158. 'CD48'\n", "159. 'CD49a'\n", "160. 'CD49b'\n", "161. 'CD49d'\n", "162. 'CD52'\n", "163. 'CD54'\n", "164. 'CD55'\n", "165. 'CD56-1'\n", "166. 'CD56-2'\n", "167. 'CD57'\n", "168. 'CD59'\n", "169. 'CD61'\n", "170. 'CD62E'\n", "171. 'CD62P'\n", "172. 'CD63'\n", "173. 'CD64'\n", "174. 'CD66a/c/e'\n", "175. 'CD66b'\n", "176. 'CD68'\n", "177. 'CD69'\n", "178. 'CD70'\n", "179. 'CD71'\n", "180. 'CD72'\n", "181. 'CD73'\n", "182. 'CD79a'\n", "183. 'CD79b'\n", "184. 'CD8'\n", "185. 'CD80'\n", "186. 'CD81'\n", "187. 'CD83'\n", "188. 'CD85g'\n", "189. 'CD86'\n", "190. 'CD8a'\n", "191. 'CD9'\n", "192. 'CD90'\n", "193. 'CD93'\n", "194. 'CD95'\n", "195. 'CD96'\n", "196. 'CD98'\n", "197. 'CD99'\n", "198. 'CLEC12A'\n", "199. 'CLEC2'\n", "200. 'CX3CR1'\n", "201. 'Folate'\n", "202. 'Galectin-9'\n", "203. 'GP130'\n", "204. 'HLA-DR'\n", "205. 'IgD'\n", "206. 'IgM'\n", "207. 'Integrin-7'\n", "208. 'LOX-1'\n", "209. 'MERTK'\n", "210. 'Notch-1'\n", "211. 'Notch-2'\n", "212. 'Podoplanin'\n", "213. 'Rag-IgG2c'\n", "214. 'Rat-IgG1-1'\n", "215. 'Rat-IgG1-2'\n", "216. 'Rat-IgG2b'\n", "217. 'Siglec-8'\n", "218. 'TCR-1'\n", "219. 'TCR-2'\n", "220. 'TCR-V-2'\n", "221. 'TCR-V-24-J-18'\n", "222. 'TCR-V-7.2'\n", "223. 'TCR-V-9'\n", "224. 'TIGIT'\n", "225. 'TIM-4'\n", "226. 'TSLPR'\n", "227. 'VEGFR-3'\n", "228. 'XCR1'\n", "\n", "\n" ], "text/plain": [ " [1] \"B7-H4\" \"C5L2\" \"Cadherin\" \"CCR10\" \n", " [5] \"CD102\" \"CD103\" \"CD105\" \"CD106\" \n", " [9] \"CD107a\" \"CD109\" \"CD110\" \"CD112\" \n", " [13] \"CD115\" \"CD117\" \"CD119\" \"CD11a/CD18\" \n", " [17] \"CD11b-1\" \"CD11b-2\" \"CD11c\" \"CD122\" \n", " [21] \"CD123\" \"CD124\" \"CD126\" \"CD127\" \n", " [25] \"CD13\" \"CD133-1\" \"CD133-2\" \"CD134\" \n", " [29] \"CD135\" \"CD137\" \"CD138-1\" \"CD138-2\" \n", " [33] \"CD14\" \"CD140a\" \"CD140b\" \"CD141\" \n", " [37] \"CD142\" \"CD144\" \"CD146\" \"CD15\" \n", " [41] \"CD152\" \"CD154\" \"CD155\" \"CD158\" \n", " [45] \"CD158b\" \"CD158e1\" \"CD158f\" \"CD16\" \n", " [49] \"CD161\" \"CD163\" \"CD164\" \"CD169\" \n", " [53] \"CD171\" \"CD172a\" \"CD177\" \"CD178\" \n", " [57] \"CD18\" \"CD184\" \"CD185\" \"CD186\" \n", " [61] \"CD19\" \"CD192\" \"CD193\" \"CD194\" \n", " [65] \"CD195\" \"CD196\" \"CD199\" \"CD1a\" \n", " [69] \"CD1c\" \"CD1d\" \"CD2\" \"CD20\" \n", " [73] \"CD200\" \"CD201\" \"CD202b\" \"CD203c\" \n", " [77] \"CD204\" \"CD205\" \"CD206\" \"CD207\" \n", " [81] \"CD209\" \"CD21\" \"CD22\" \"CD223\" \n", " [85] \"CD226\" \"CD235a\" \"CD235ab\" \"CD24\" \n", " [89] \"CD243\" \"CD244\" \"CD25\" \"CD252\" \n", " [93] \"CD253\" \"CD26-1\" \"CD26-2\" \"CD267\" \n", " [97] \"CD268\" \"CD269\" \"CD27\" \"CD270\" \n", "[101] \"CD271\" \"CD272\" \"CD273\" \"CD274\" \n", "[105] \"CD275-1\" \"CD275-2\" \"CD278\" \"CD279\" \n", "[109] \"CD28\" \"CD284\" \"CD29\" \"CD294\" \n", "[113] \"CD3-1\" \"CD3-2\" \"CD30\" \"CD301\" \n", "[117] \"CD303\" \"CD304\" \"CD305\" \"CD307c/FcRL3\" \n", "[121] \"CD307d\" \"CD307e\" \"CD309\" \"CD31\" \n", "[125] \"CD314\" \"CD319\" \"CD324\" \"CD325\" \n", "[129] \"CD335\" \"CD337\" \"CD338\" \"CD34\" \n", "[133] \"CD340\" \"CD35\" \"CD354\" \"CD357\" \n", "[137] \"CD36\" \"CD366\" \"CD370\" \"CD38-1\" \n", "[141] \"CD38-2\" \"CD39\" \"CD4-1\" \"CD4-2\" \n", "[145] \"CD40\" \"CD41\" \"CD42b\" \"CD43\" \n", "[149] \"CD44-1\" \"CD44-2\" \"CD45-1\" \"CD45-2\" \n", "[153] \"CD45RA\" \"CD45RB\" \"CD45RO\" \"CD46\" \n", "[157] \"CD47\" \"CD48\" \"CD49a\" \"CD49b\" \n", "[161] \"CD49d\" \"CD52\" \"CD54\" \"CD55\" \n", "[165] \"CD56-1\" \"CD56-2\" \"CD57\" \"CD59\" \n", "[169] \"CD61\" \"CD62E\" \"CD62P\" \"CD63\" \n", "[173] \"CD64\" \"CD66a/c/e\" \"CD66b\" \"CD68\" \n", "[177] \"CD69\" \"CD70\" \"CD71\" \"CD72\" \n", "[181] \"CD73\" \"CD79a\" \"CD79b\" \"CD8\" \n", "[185] \"CD80\" \"CD81\" \"CD83\" \"CD85g\" \n", "[189] \"CD86\" \"CD8a\" \"CD9\" \"CD90\" \n", "[193] \"CD93\" \"CD95\" \"CD96\" \"CD98\" \n", "[197] \"CD99\" \"CLEC12A\" \"CLEC2\" \"CX3CR1\" \n", "[201] \"Folate\" \"Galectin-9\" \"GP130\" \"HLA-DR\" \n", "[205] \"IgD\" \"IgM\" \"Integrin-7\" \"LOX-1\" \n", "[209] \"MERTK\" \"Notch-1\" \"Notch-2\" \"Podoplanin\" \n", "[213] \"Rag-IgG2c\" \"Rat-IgG1-1\" \"Rat-IgG1-2\" \"Rat-IgG2b\" \n", "[217] \"Siglec-8\" \"TCR-1\" \"TCR-2\" \"TCR-V-2\" \n", "[221] \"TCR-V-24-J-18\" \"TCR-V-7.2\" \"TCR-V-9\" \"TIGIT\" \n", "[225] \"TIM-4\" \"TSLPR\" \"VEGFR-3\" \"XCR1\" " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "sort(rownames(reference@assays$ADT@data))" ] }, { "cell_type": "code", "execution_count": 4, "id": "9f820866-9c48-49b4-8be5-8bbefa4ad4eb", "metadata": { "tags": [] }, "outputs": [], "source": [ "hise_meta<-read.csv(\"hise_meta_data_2023-11-19.csv\")" ] }, { "cell_type": "code", "execution_count": 5, "id": "b402a4c3-6fd2-485a-acb8-3c21697d4a26", "metadata": { "tags": [] }, "outputs": [], "source": [ "get_last_pattern <- function(x) {\n", " split_vector <- strsplit(x, \"/\")[[1]]\n", " last_pattern <- tail(split_vector, 1)\n", " return(last_pattern)\n", "}\n", "last_patterns <- unlist(lapply(hise_meta$file.name, get_last_pattern))\n" ] }, { "cell_type": "code", "execution_count": 6, "id": "67e55b00-f47a-4080-8186-b7ccc0933d05", "metadata": { "tags": [] }, "outputs": [], "source": [ "#hise_meta$file.path<-paste0(\"cache/\",hise_meta$file.id,\"/\",last_patterns)" ] }, { "cell_type": "code", "execution_count": 7, "id": "a9bf4fd0-6c9e-4944-8925-36684ace10ae", "metadata": { "tags": [] }, "outputs": [], "source": [ "hise_meta <-hise_meta %>% arrange(file.batchID)" ] }, { "cell_type": "code", "execution_count": 8, "id": "ab9dc35e-5f27-45c1-922d-d600f3800bfc", "metadata": { "tags": [] }, "outputs": [], "source": [ "b <- seq(10, dim(hise_meta)[1]+8, 10)\n", "df_chunk_list<-lapply(seq_along(b), function(i) hise_meta[(b-9)[i]:b[i], ])" ] }, { "cell_type": "code", "execution_count": 9, "id": "4c73da3f-ae9c-4b2d-a0b8-f0b20049f90d", "metadata": { "tags": [] }, "outputs": [ { "data": { "text/html": [ "11" ], "text/latex": [ "11" ], "text/markdown": [ "11" ], "text/plain": [ "[1] 11" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "length(df_chunk_list)" ] }, { "cell_type": "code", "execution_count": null, "id": "98dd7302-49e8-4efc-b79c-480df9304770", "metadata": { "tags": [] }, "outputs": [], "source": [ "mclapply(df_chunk_list,function(x){\n", "so_list <- lapply(x$file.path[!is.na(x$file.path)],function(i){\n", " sce <- read_h5_sce(i)\n", " counts <- assay(sce, \"counts\")\n", " rownames(counts)<- make.names(rownames(counts), unique=TRUE)\n", " so<-CreateSeuratObject(\n", " counts,meta.data =data.frame(sce@colData),\n", " assay = \"RNA\")\n", " })\n", "combined <- Reduce(merge, so_list)\n", "rm(so_list)\n", "combined <- SCTransform(combined,method = \"glmGamPoi\", verbose = FALSE)\n", "\n", "#find anchors\n", "anchors <- FindTransferAnchors(\n", " reference = reference,\n", " query = combined,\n", " normalization.method = \"SCT\",\n", " reference.reduction = \"spca\",\n", " dims = 1:50\n", ") \n", " \n", "#perform projection to get labels\n", "combined <- MapQuery(\n", " anchorset = anchors,\n", " query = combined,\n", " reference = reference,\n", " refdata = list(\n", " celltype.l1 = \"celltype.l1\",\n", " celltype.l2 = \"celltype.l2\",\n", " celltype.l3 = \"celltype.l3\",\n", " celltype.l2.5 = \"celltype.l2.5\",\n", " predicted_ADT = \"ADT\"\n", " ),\n", " reference.reduction = \"spca\", \n", " reduction.model = \"wnn.umap\"\n", ")\n", "\n", "mclapply( unique(combined[[]]$pbmc_sample_id),function(i){\n", "\n", "labels<-combined[[]]%>% filter(pbmc_sample_id==i)\n", "write.csv(labels,paste0(\"Labels_20231119/\",i,\".csv\"))\n", " \n", "combined_sub<-subset(combined,subset=pbmc_sample_id==i)\n", "mat<-combined_sub@assays$predicted_ADT@data\n", "list_mat <- list(i = mat@i, p = mat@p, x = mat@x, Dim = dim(mat),rownames = rownames(mat),\n", " colnames = colnames(mat))\n", "\n", "h5createFile(paste0(\"Labels_20231119/\",i,\"_ADT.h5\"))\n", "\n", "h5write(list_mat, paste0(\"Labels_20231119/\",i,\"_ADT.h5\"), \"mat\")\n", "},mc.cores=n_distinct(combined[[]]$pbmc_sample_id))\n", " \n", "rm(combined)\n", "gc()\n", "},mc.cores=3)" ] }, { "cell_type": "code", "execution_count": null, "id": "9ebde183-49f4-44a4-befe-fe59a4e53ad3", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "R 4", "language": "R", "name": "ir4" }, "language_info": { "codemirror_mode": "r", "file_extension": ".r", "mimetype": "text/x-r-source", "name": "R", "pygments_lexer": "r", "version": "4.3.1" } }, "nbformat": 4, "nbformat_minor": 5 }