OSCR

Divalent siRNA for prion disease.

Code ↔ Paper

14 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 14 matches
  1. [1] § Results › Comparison of chemical scaffolds and AS strand 3′ tails ↔ src/divalent_manuscript_figures.R, lines 2108–2148 · score 0.73 · s2 matched tail, s2 fixed tail, s4 fixed tail, exNA, PS, PBS
  2. [2] § Results › Comparison of chemical scaffolds and AS strand 3′ tails ↔ src/divalent_manuscript_figures.R, lines 2108–2148 · score 0.68 · s4 fixed tail, matched tail, exNA, qPCR, scaffold, model
  3. [3] § Materials and methods › In silico off-targets analysis ↔ src/divalent_manuscript_figures.R, lines 4525–4590 · score 0.67 · seed region, 2–17, BLAST, Homo, sapiens, mismatch
  4. [4] § Materials and methods › Dose levels of siRNA ↔ src/divalent_manuscript_figures.R, lines 370–402 · score 0.65 · Empirical MECs, theoretical MEC, weight, divalent, doses
  5. [5] § Results › Durability and dosing regimens for drug candidate ↔ src/divalent_manuscript_figures.R, lines 2979–3044 · score 0.64 · PK model, drug accumulation, dose retained, PD, Fitting, 1 %
  6. [6] § Materials and methods › Expanded screen for potent human siRNA sequences ↔ src/divalent_manuscript_figures.R, lines 405–448 · score 0.61 · siRNA sequences, qPCR, TaqMan, untreated, assay, saline
  7. [7] § Results › Comparison of chemical scaffolds and AS strand 3′ tails ↔ src/divalent_manuscript_figures.R, lines 2150–2187 · score 0.60 · Linear model coefficients, scaffolds fit, regions fit, qPCR, error, Regional
  8. [8] § Results › Proof of concept in a prion disease model ↔ src/divalent_manuscript_figures.R, lines 474–551 · score 0.58 · mouse N2a cells, cross reactivity, predicted, siRNA, human, residual
  9. [9] § Results › Generation of human PRNP transgenic mice ↔ src/divalent_manuscript_figures.R, lines 1421–1497 · score 0.57 · PRNP transcription start, PRND, upstream, downstream, gene, BAC
  10. [10] § Materials and methods › Initial screen for human and mouse siRNA sequences ↔ src/divalent_manuscript_figures.R, lines 625–700 · score 0.56 · A549 cells, DNA assay, ratio, siRNA, 1.5 uM, human
  11. [11] § Pharmacokinetic analysis ↔ src/divalent_manuscript_figures.R, lines 2979–3044 · score 0.55 · drug accumulation, Hill, slope, LLOQ, fit, PK
  12. [12] § Pharmacokinetic analysis › IND-enabling studies ↔ src/divalent_manuscript_figures.R, lines 4464–4523 · score 0.55 · manufacture process, UMass, Hongene
  13. [13] § Materials and methods › Tissue processing, PrP quantification, and RNA analysis ↔ src/divalent_manuscript_figures.R, lines 3541–3618 · score 0.54 · low QC, mid, S6, plate, ELISA
  14. [14] § Results › Identification of compounds targeting human PRNP ↔ src/divalent_manuscript_figures.R, lines 625–700 · score 0.52 · human A549 cells, residual PRNP, predicted, sequence

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 · 4,620 lines · 176 KB · CC-BY-4.0 · 14 matches

  1. # STARTUP ####
  2. overall_start_time = Sys.time()
  3. tell_user = function(...) { cat(file=stderr(), paste0(...)); flush.console() }
  4. # DEPENDENCIES ####
  5. tell_user('Loading required packages...')
  6. options(stringsAsFactors=F)
  7. if (interactive()) {
  8. setwd('~/d/sci/src/divalent')
  9. }
  10. suppressPackageStartupMessages({
  11. library(tidyverse)
  12. library(survival)
  13. library(janitor)
  14. library(openxlsx)
  15. library(DescTools)
  16. library(magick)
  17. library(plotrix)
  18. library(drc)
  19. select = dplyr::select
  20. summarize = dplyr::summarize
  21. })
  22. # OUTPUT STREAMS ####
  23. tell_user('done.\nCreating output streams...')
  24. text_stats_path = 'display_items/stats_for_text.txt'
  25. write(paste('Last updated: ',Sys.Date(),'\n',sep=''),text_stats_path,append=F) # start anew - but all subsequent writings will be append=T
  26. write_stats = function(...) {
  27. write(paste(list(...),collapse='',sep=''),text_stats_path,append=T)
  28. write('\n',text_stats_path,append=T)
  29. }
  30. supplement_path = 'display_items/supplement.xlsx'
  31. supplement = createWorkbook()
  32. # options("openxlsx.numFmt" = "0.00") # this looks better for residuals but terrible for p values and weeks post-dose
  33. supplement_directory = tibble(name=character(0), title=character(0))
  34. write_supp_table = function(tbl, title='') {
  35. # write Excel sheet for supplement
  36. table_number = length(names(supplement)) + 1
  37. table_name = paste0('s',formatC(table_number,'d',digits=0,width=2,flag='0'))
  38. addWorksheet(supplement,table_name)
  39. bold_style = createStyle(textDecoration = "Bold")
  40. writeData(supplement,table_name,tbl,headerStyle=bold_style,withFilter=T)
  41. freezePane(supplement,table_name,firstRow=T)
  42. saveWorkbook(supplement,supplement_path,overwrite = TRUE)
  43. # also write tab-sep version for GitHub repo
  44. write_tsv(tbl,paste0('display_items/table-',table_name,'.tsv'), na='')
  45. # and save the title in the directory tibble for later
  46. assign('supplement_directory',
  47. supplement_directory %>% add_row(name=table_name, title=title),
  48. envir = .GlobalEnv)
  49. }
  50. # FUNCTIONS ####
  51. tell_user('done.\nDefining functions...')
  52. clipcopy = function(tbl) {
  53. clip = pipe("pbcopy", "w")
  54. write.table(tbl, file=clip, sep = '\t', quote=F, row.names = F, na='')
  55. close(clip)
  56. }
  57. rank_uniq = function(x) match(x, sort(unique(x)))
  58. percent = function(x, digits=0, signed=F) gsub(' ','',paste0(ifelse(x <= 0, '', ifelse(signed, '+', '')),formatC(100*x,format='f',digits=digits),'%'))
  59. upper = function(x, ci=0.95) {
  60. alpha = 1 - ci
  61. sds = qnorm(1-alpha/2)
  62. mean(x) + sds*sd(x)/sqrt(sum(!is.na(x)))
  63. }
  64. lower = function(x, ci=0.95) {
  65. alpha = 1 - ci
  66. sds = qnorm(1-alpha/2)
  67. mean(x) - sds*sd(x)/sqrt(sum(!is.na(x)))
  68. }
  69. alpha = function(rgb_hexcolor, proportion) {
  70. hex_proportion = sprintf("%02x",round(proportion*255))
  71. rgba = paste(rgb_hexcolor,hex_proportion,sep='')
  72. return (rgba)
  73. }
  74. ci_alpha = 0.35 # degree of transparency for shading confidence intervals in plot
  75. rbind_files = function(path, grepstring) {
  76. all_files = list.files(path, full.names=T)
  77. these_files = all_files[grepl(grepstring,all_files)]
  78. if (exists('rbound_table')) rm('rbound_table')
  79. for (this_file in these_files) {
  80. this_tbl = read_delim(this_file, col_types=cols()) %>% clean_names()
  81. this_tbl$file = gsub('.*\\/','',gsub('\\.[tc]sv','',this_file))
  82. if (exists('rbound_table')) {
  83. rbound_table = rbind(rbound_table, this_tbl)
  84. } else {
  85. rbound_table = this_tbl
  86. }
  87. }
  88. return (rbound_table)
  89. }
  90. weight_deltas = function(study_ids) {
  91. study %>%
  92. filter(study_id %in% study_ids) %>%
  93. inner_join(wts, by=c('study_id','animal')) %>%
  94. mutate(wt_date = as.integer(date - icv_date)) %>%
  95. select(study_id, animal, sex, tx, dose_dio, wt_date, weight) %>%
  96. group_by(animal) %>%
  97. mutate(baseline=weight[wt_date==min(wt_date)]) %>%
  98. ungroup() %>%
  99. mutate(change = weight/baseline-1) -> deltas
  100. return(deltas)
  101. }
  102. process_elisas = function(study_ids, control_group='PBS') {
  103. study %>%
  104. filter(study_id %in% study_ids) %>%
  105. inner_join(elisa, by=c('study_id','animal'='sample')) %>%
  106. group_by(plate, genotype) %>%
  107. mutate(saline_mean = mean(ngml_av[tx %in% control_group], na.rm=T),
  108. n_saline = sum(tx %in% control_group & !is.na(ngml_av))) %>%
  109. ungroup() %>%
  110. mutate(rel = ngml_av / saline_mean) %>%
  111. select(study_id, plate, animal, genotype, sex, tx, dose_dio, dosing_regimen, days_harvest, ngml_av, saline_mean, n_saline, rel) -> proc
  112. }
  113. dviz = function(tbl,
  114. xlims,
  115. ylims,
  116. xvar,
  117. yvar,
  118. colorvar=NULL,
  119. pchvar=NULL,
  120. pchbg='#FFFFFF',
  121. pchout=NULL,
  122. pchcex=1,
  123. xcols=character(0), # columns that group with x TBD
  124. xats=xbigs,
  125. xbigs,
  126. xlwds=1,
  127. xbiglabs=xbigs,
  128. xaxcex=1,
  129. xlabcex=1,
  130. xlabline=1.5,
  131. yats=ybigs,
  132. ybigs,
  133. ylwds=1,
  134. ybiglabs=ybigs,
  135. yaxcex=1,
  136. ylabcex=1,
  137. ylabline=2.25,
  138. log,
  139. mar=c(3,3,1,1),
  140. jitamt=0.1,
  141. randseed=1,
  142. boxwidth=NA,
  143. barwidth=NA,
  144. bartype='segment',
  145. polygon=NA,
  146. arrowlength=0.05,
  147. test=NA,
  148. control_group=NA,
  149. xlab='',
  150. ylab='',
  151. legtext=NULL,
  152. legcol='#000000',
  153. legtextcol=legcol,
  154. leglty=1,
  155. legpch=20,
  156. leglwd=1,
  157. legcex=1,
  158. legloc=NULL,
  159. crosshairs=F
  160. ) {
  161. if (is.null(pchvar)) {
  162. pchvar='pch'
  163. tbl$pch = 19
  164. }
  165. if (is.null(colorvar)) {
  166. colorvar='color'
  167. tbl$color = '#000000'
  168. }
  169. tbl %>%
  170. mutate(x=!!as.name(xvar), y=!!as.name(yvar), color=!!as.name(colorvar), pch=!!as.name(pchvar)) %>%
  171. select(x, y, color, pch, all_of(xcols)) -> tbl
  172. if (!crosshairs) {
  173. xcols = c('x', xcols)
  174. }
  175. tbl %>%
  176. group_by(color, across(all_of(xcols))) %>%
  177. summarize(.groups='keep',
  178. n = n(),
  179. mean = mean(y),
  180. l95 = mean(y) - 1.96 * sd(y) / sqrt(n()),
  181. u95 = mean(y) + 1.96 * sd(y) / sqrt(n()),
  182. median = median(y),
  183. q25 = quantile(y, .25),
  184. q75 = quantile(y, .75),
  185. cv = sd(y) / mean(y),
  186. x_mean = mean(x),
  187. x_l95 = mean(x) - 1.96 * sd(x) / sqrt(n()),
  188. x_u95 = mean(x) + 1.96 * sd(x) / sqrt(n())) %>%
  189. ungroup() %>%
  190. mutate(l95 = ifelse(l95 < 0 & log %in% c('xy','y'), min(ylims), l95)) %>%
  191. #mutate(x = case_when(crosshairs ~ x_mean,
  192. # TRUE ~ x)) %>%
  193. arrange(x) -> tbl_smry
  194. if (crosshairs) {
  195. tbl_smry$x = tbl_smry$x_mean
  196. }
  197. par(mar=mar)
  198. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i', log=log)
  199. axis(side=1, at=xlims, labels=NA, lwd.ticks=0)
  200. if (!is.null(xats)) {
  201. axis(side=1, at=xats, tck=-0.025, lwd.ticks=xlwds, labels=NA)
  202. }
  203. if (!is.null(xbigs)) {
  204. axis(side=1, at=xbigs, tck=-0.05, lwd.ticks=xlwds, labels=NA)
  205. axis(side=1, at=xbigs, tck=-0.05, lwd=0, line=-0.5, labels=xbiglabs, cex.axis=xaxcex)
  206. }
  207. mtext(side=1, line=xlabline, text=xlab, cex=xlabcex)
  208. if (!is.null(yats)) {
  209. axis(side=2, at=yats, tck=-0.025, labels=NA)
  210. }
  211. if (!is.null(ybigs)) {
  212. axis(side=2, at=ybigs, tck=-0.05, labels=NA)
  213. axis(side=2, at=ybigs, tck=-0.05, las=2, lwd=0, line=-0.3, labels=ybiglabs, cex.axis=yaxcex)
  214. }
  215. mtext(side=2, line=ylabline, text=ylab, cex=ylabcex)
  216. if (crosshairs) {
  217. jitamt = 0
  218. }
  219. if (crosshairs) {
  220. segments(x0=tbl_smry$x_l95, x1=tbl_smry$x_u95, y0=tbl_smry$mean, col=tbl_smry$color, lwd=1.5)
  221. segments(x0=tbl_smry$x_mean, y0=tbl_smry$l95, y1=tbl_smry$u95, col=tbl_smry$color, lwd=1.5)
  222. }
  223. if (!is.na(barwidth)) {
  224. if (bartype=='segment') {
  225. segments(x0=tbl_smry$x-barwidth, x1=tbl_smry$x+barwidth, y0=tbl_smry$mean, col=tbl_smry$color, lwd=1.5)
  226. } else if (bartype=='bar') {
  227. rect(xleft=tbl_smry$x-barwidth, xright=tbl_smry$x+barwidth, ybottom=rep(0,nrow(tbl_smry)), ytop=tbl_smry$mean, col=tbl_smry$color, border=NA)
  228. }
  229. arrows(x0=tbl_smry$x, y0=tbl_smry$l95, y1=tbl_smry$u95, code=3, angle=90, length=arrowlength, col=tbl_smry$color, lwd=1.5)
  230. }
  231. if (!is.na(boxwidth)) {
  232. rect(xleft=tbl_smry$x-boxwidth, xright=tbl_smry$x+boxwidth, ybottom=tbl_smry$q25, ytop=tbl_smry$q75, border=tbl_smry$color, lwd=1.5, col=NA)
  233. segments(x0=tbl_smry$x-boxwidth, x1=tbl_smry$x+boxwidth, y0=tbl_smry$median, col=tbl_smry$color, lwd=1.5)
  234. }
  235. set.seed(randseed)
  236. if (!is.null(pchout)) {
  237. points(x=jitter(tbl$x,amount=jitamt), y=tbl$y, col=pchout, pch=tbl$pch, bg=pchbg)
  238. } else {
  239. points(x=jitter(tbl$x,amount=jitamt), y=tbl$y, col=alpha(tbl$color,ci_alpha), pch=tbl$pch, bg=pchbg)
  240. }
  241. if (!is.na(polygon)) {
  242. for (clr in unique(tbl_smry$color)) {
  243. if (polygon=='iqr') {
  244. subs = subset(tbl_smry, color==clr & !is.na(q25) & !is.na(q75))
  245. points( x= subs$x, y= subs$median, type='l', lwd=2, col=subs$color)
  246. polygon(x=c(subs$x, rev(subs$x)), y=c(subs$q25, rev(subs$q75)), col=alpha(subs$color, ci_alpha), border=NA)
  247. } else if (polygon=='ci') {
  248. subs = subset(tbl_smry, color==clr & !is.na(l95) & !is.na(u95))
  249. points( x= subs$x, y= subs$mean, type='l', lwd=2, col=subs$color)
  250. polygon(x=c(subs$x, rev(subs$x)), y=c(subs$l95, rev(subs$u95)), col=alpha(subs$color, ci_alpha), border=NA)
  251. }
  252. }
  253. }
  254. if (!is.na(test)) {
  255. testfun = get(test) # e.g. ks.test
  256. control_color = control_group
  257. tbl_smry$p = as.numeric(NA)
  258. for (i in 1:nrow(tbl_smry)) {
  259. this_x = tbl_smry$x[i]
  260. this_rows = tbl$x == this_x & tbl$color == tbl_smry$color[i]
  261. ctrl_rows = tbl$x == this_x & tbl$color == control_group
  262. test_obj = suppressWarnings(testfun(tbl$y[this_rows], tbl$y[ctrl_rows]))
  263. tbl_smry$p[i] = test_obj$p.value
  264. }
  265. tbl_smry$p_symb = ''
  266. tbl_smry$p_symb[!is.na(tbl_smry$p) & tbl_smry$p < 0.05] = '*'
  267. tbl_smry$p_symb[!is.na(tbl_smry$p) & tbl_smry$p < 0.01] = '**'
  268. tbl_smry$p_symb[!is.na(tbl_smry$p) & tbl_smry$p < 0.001] = '***'
  269. text(x=tbl_smry$x[tbl_smry$color != control_color], y=max(ylims)*.95, labels=tbl_smry$p_symb[tbl_smry$color != control_color])
  270. }
  271. if (!is.null(legtext)) {
  272. if (is.null(legloc)) {
  273. par(xpd=T)
  274. legend(x=max(xlims),y=max(ylims),legtext,col=legcol,text.col=legtextcol,pch=legpch,lwd=leglwd, cex=legcex,lty=leglty, bty='n')
  275. par(xpd=F)
  276. } else {
  277. if (length(legloc)==1) {
  278. legend(legloc,legtext,col=legcol,text.col=legtextcol,pch=legpch,lwd=leglwd, cex=legcex,lty=leglty, bty='n')
  279. } else if (length(legloc)==2) {
  280. legend(x=legloc[1],y=legloc[2],legtext,col=legcol,text.col=legtextcol,pch=legpch,lwd=leglwd, cex=legcex,lty=leglty, bty='n')
  281. }
  282. }
  283. }
  284. return(tbl_smry)
  285. }
  286. # rcomp = function(x) {
  287. # chartr('ACGT','TGCA',paste0(rev(strsplit(gsub('U','T',toupper(x)),split='')[[1]]), collapse=''))
  288. # }
  289. rcompu_unary = function(x) {
  290. chartr('ACGU','UGCA',paste0(rev(strsplit(x,split='')[[1]]), collapse=''))
  291. }
  292. rcompu = function(x) {
  293. result = character(length(x))
  294. for (i in 1:length(x)) {
  295. result[i] = rcompu_unary(x[i])
  296. }
  297. return (result)
  298. }
  299. dna_to_rna = function(x) {
  300. chartr('T','U',x)
  301. }
  302. rna_to_dna = function(x) {
  303. chartr('U','T',x)
  304. }
  305. p_to_symbol = function(p) {
  306. case_when(p < 0.001 ~ '***',
  307. p < 0.01 ~ '**',
  308. p < 0.05 ~ '*',
  309. TRUE ~ '')
  310. }
  311. # DATA ####
  312. tell_user('done.\nReading in data...')
  313. ## Target engagement studies ####
  314. study = read_tsv('data/analytic/studysheets.tsv', col_types=cols())
  315. elisa = read_tsv('data/analytic/elisa.tsv', col_types=cols())
  316. qpcr = read_tsv('data/analytic/qpcr.tsv', col_types=cols(), guess_max=10000)
  317. wts = read_tsv('data/analytic/weights.tsv', col_types=cols(), guess_max=10000)
  318. meta = read_tsv('data/analytic/meta.tsv', col_types=cols())
  319. cellulo = read_tsv('data/analytic/in_cellulo.tsv', col_types=cols())
  320. # renaming some things
  321. # qpcr %>%
  322. # distinct(study_id, sample_group) -> qpcr_txes
  323. # write_tsv(qpcr_txes, 'data/analytic/qpcr_txes_start.tsv', na='')
  324. # annotated in google sheets, read back in
  325. qpcr_txes = read_tsv('data/analytic/qpcr_txes.tsv', col_types=cols())
  326. ## Challenge study ####
  327. yb_blind = read_tsv('data/challenge/YB_blind.tsv', col_types=cols())
  328. yb_master = read_tsv('data/challenge/YB_master.tsv', col_types=cols())
  329. yb_meta = read_tsv('data/challenge/YB_meta.tsv', col_types=cols())
  330. yb_nests = read_tsv('data/challenge/YB_nests.tsv', col_types=cols())
  331. yb_surg = read_tsv('data/challenge/YB_surgery_notes.tsv', col_types=cols())
  332. yb_wts = read_tsv('data/challenge/YB_weights.tsv', col_types=cols())
  333. ## Constants ####
  334. mw = 24952
  335. empirical_mec = 549107
  336. theoretical_mec = 766260
  337. dose_correction = theoretical_mec/empirical_mec
  338. nmol_to_ug = function(x, digits=0) { round(x * 1e-9 * mw * dose_correction * 1e6,digits=digits) }
  339. region_meta = tibble(region=c("HP", "PFC", "VC", "Str", "Thal", "CB"),
  340. x = 1:6)
  341. # table(study$tx)
  342. # mouse_init = read_tsv('data/miscellaneous/mouse_initial_screen.tsv', col_types=cols())
  343. huseq_raw = read_tsv('data/sequence/Homo_sapiens_NM_000311_4_sequence.fa', skip=1, col_names = c('seq'), col_types=cols())
  344. huseq = paste0(huseq_raw$seq,collapse='')
  345. # DISPLAY ITEMS ####
  346. ## Supplementary tables ####
  347. sirna_sequences = read_tsv('data/supptables/antisense_sequences.tsv', col_types=cols())
  348. write_supp_table(sirna_sequences, 'Antisense strand sequences of all siRNAs screened.')
  349. taqmans = read_tsv('data/miscellaneous/taqman_assays.tsv', col_types=cols())
  350. write_supp_table(taqmans, 'Taqman qPCR assays utilized.')
  351. all_studies = c("CMR-1313", "CMR-1403", "CMR-1418", "CMR-1465", "CMR-1656",
  352. "CMR-1697", "CMR-1871", "CMR-2198", "CMR-2371", "CMR-2521", "CMR-2752",
  353. "CMR-2812", "CMR-2833", "CMR-2941", "CMR-3164")
  354. proc_all = process_elisas(all_studies, control_group=c('saline','none','no injection','-')) %>%
  355. inner_join(meta, by='tx') %>%
  356. rename(prp_ngml = ngml_av, untreated_mean = saline_mean) %>%
  357. select(study_id, plate, animal, genotype, sex, display_tx, dose_dio, dosing_regimen, days_harvest, prp_ngml, untreated_mean, rel) %>%
  358. mutate(genotype = case_when(genotype=='Tg26372 HOM/ZH3 HOM' ~ 'Tg26372',
  359. T ~ genotype))
  360. proc_all %>%
  361. mutate(weeks_harvest = days_harvest %/% 7) %>%
  362. group_by(study_id, genotype, display_tx, dose_dio, dosing_regimen, weeks_harvest) %>%
  363. summarize(.groups='keep',
  364. n = n(),
  365. mean = mean(rel),
  366. l95 = lower(rel),
  367. u95 = upper(rel)) %>%
  368. ungroup() -> proc_all_smry
  369. write_supp_table(proc_all, 'All in vivo PrP ELISA results - individual animal data.')
  370. write_supp_table(proc_all_smry, 'All in vivo PrP ELISA results - summarized.')
  371. # note: things that appear only in these supp tables
  372. # - 1 nmol dio tests of 1035 and 2440
  373. ## Fig S2 - Zack's data ####
  374. tell_user('done.\nCreating Figure S2...')
  375. if ('figure-s2'=='figure-s2') {
  376. resx=300
  377. png('display_items/figure-s02.png',width=6.5*resx,height=6*resx,res=resx)
  378. layout_matrix = matrix(c(1,1,2,3,
  379. 1,1,4,5,
  380. 6,6,7,8,
  381. 6,6,9,10), nrow=4, byrow=T)
  382. layout(layout_matrix)
  383. panel = 1
  384. ### mouse screen ####
  385. species_meta = tibble(species=c('Ms','Hs','Hs_Ms'),
  386. disp = c('mouse-only','human-only','cross-reactive'))
  387. z_mo_scr = read_tsv('data/miscellaneous/mouse_screen.tsv', col_types=cols())
  388. z_mo_scr %>%
  389. filter(!is.na(ratio)) %>%
  390. filter(species=='Hs') %>% # predicted non-reactive
  391. group_by(descno) %>%
  392. summarize(.groups='keep', n_replicates = n(), mean=mean(ratio)) %>%
  393. ungroup() %>%
  394. filter(n_replicates > 1) %>%
  395. summarize(ntc_mean = mean(mean)) %>%
  396. pull() -> ntc_mean
  397. ylims = c(0,1.5)
  398. z_mo_scr %>%
  399. filter(!is.na(ratio)) %>%
  400. inner_join(species_meta, by='species') %>%
  401. mutate(resid = pmin(ratio / ntc_mean, max(ylims))) %>%
  402. arrange(disp, descno) %>%
  403. mutate(x = dense_rank(paste0(disp, formatC(descno,width=4,flag='0')))) -> scr
  404. scr %>%
  405. group_by(x, disp, descno) %>%
  406. summarize(.groups='keep',
  407. mean = mean(resid),
  408. l95 = lower(resid),
  409. u95 = upper(resid)) %>%
  410. ungroup() -> scr_smry
  411. scr_smry %>%
  412. group_by(disp) %>%
  413. summarize(.groups='keep',
  414. minx = min(x),
  415. midx = mean(x),
  416. maxx = max(x)) %>%
  417. ungroup() -> tranches
  418. xlims = range(scr_smry$x) + c(-0.5, 0.5)
  419. ybigs = 0:3/2
  420. ybiglabs = c('0%','50%','100%','≥150%')
  421. par(mar=c(4,4,2,1))
  422. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i')
  423. axis(side=1, at=xlims, lwd.ticks=0, labels=NA)
  424. axis(side=2, at=ybigs, labels=NA)
  425. axis(side=2, at=ybigs, labels=ybiglabs, cex.axis=0.8, las=2, line=-0.5, lwd=0)
  426. mtext(side=2, line=2.5, text='residual Prnp')
  427. axis(side=3, at=xlims, lwd.ticks=0, labels=NA)
  428. abline(h=1, lty=3)
  429. barwidth = 0.8
  430. rect(xleft=scr_smry$x-barwidth/2, xright=scr_smry$x+barwidth/2,
  431. ybottom=rep(0,nrow(scr_smry)), ytop=scr_smry$mean, col=alpha('#000000',ci_alpha),
  432. border=NA)
  433. arrows(x0=scr_smry$x, y0=scr_smry$l95, y1=scr_smry$u95, angle=90, length=0.05, code=3)
  434. points(scr$x, scr$resid, pch=21, bg='#FFFFFF')
  435. mtext(side=1, at=scr_smry$x, text=scr_smry$descno, las=2, cex=0.5)
  436. tranche_line = 1.75
  437. overhang_left = 0.4
  438. overhang_right = 0.4
  439. for (i in 1:nrow(tranches)) {
  440. axis(side=1, line=tranche_line, at=c(tranches$minx[i], tranches$maxx[i]) + c(-1,1)*c(overhang_left,overhang_right), tck=0.03, labels=NA)
  441. mtext(side=1, line=tranche_line+0.2, at=tranches$midx[i], text=tranches$disp[i], cex=0.8)
  442. }
  443. mtext(side=3, adj=0, text='mouse N2a cells', line=0.5)
  444. mtext(side=3, adj=-0.2, text=LETTERS[panel], line=0.5); panel = panel + 1
  445. scr_smry %>%
  446. select(-x) %>%
  447. rename(species=disp) %>%
  448. relocate(descno) -> scr_smry_out
  449. write_supp_table(scr_smry_out, 'Mouse siRNA sequence screen in N2a cells with bDNA assay readout.')
  450. ### mouse IC50 ####
  451. z_ic50_mo = read_tsv('data/miscellaneous/ic50_mo.tsv', col_types=cols())
  452. z_ic50 = z_ic50_mo
  453. cpds = unique(z_ic50_mo$compound)
  454. par(mar=c(2,3,1,1))
  455. i = 1
  456. for (cpd in cpds) {
  457. if (i == 1) {
  458. par(mar=c(0.5,3,3,1))
  459. } else if (i == 2) {
  460. par(mar=c(0.5,1,3,3))
  461. } else if (i == 3) {
  462. par(mar=c(3,3,0.5,1))
  463. } else if (i == 4) {
  464. par(mar=c(3,1,0.5,3))
  465. }
  466. ic50_points = z_ic50 %>%
  467. subset(compound==cpd) %>%
  468. rename(resid = normed, concnm = dose)
  469. ylims = c(0, 1.5)
  470. xlims = range(ic50_points$concnm[ic50_points$concnm > 0]) * c(1/3.16, 3.16)
  471. xbigs = 10^(-3:3)
  472. xbiglabs = -3:3
  473. xats = rep(1:9, 7) * rep(10^(-3:3), each=9)
  474. ybigs = 0:3/2
  475. ybiglabs = c('0%','50%','100%','≥150%')
  476. plot(NA, NA, xlim=xlims, ylim=ylims, xaxs='i', yaxs='i', ann=F, axes=F, log='x')
  477. axis(side=1, at=xlims, lwd.ticks=0, labels=NA)
  478. axis(side=1, at=xbigs, labels=NA, tck=-0.05)
  479. axis(side=1, at=xats, labels=NA, tck=-0.02)
  480. axis(side=2, at=ylims, labels=NA, lwd.ticks=0)
  481. if (i %% 2 == 1) { # first in each row
  482. axis(side=2, at=ybigs, labels=NA, tck=0.025)
  483. axis(side=2, at=ybigs, labels=ybiglabs, lwd=0, line=-.75, las=2, cex.axis=.75)
  484. }
  485. if (i > length(cpds)/2) { # bottom row
  486. axis(side=1, at=xbigs, labels=xbiglabs, lwd.ticks=0, lwd=0, line=-1.0, cex.axis=.7)
  487. mtext(side=1, line=1, text='log10(nM)', cex=0.6)
  488. }
  489. if (i==3) { # bottom left
  490. mtext(side=2, line=2.5, at=max(ylims), text='residual Prnp', cex=.8)
  491. }
  492. abline(h=c(0.5,1), lty=3, lwd=0.5)
  493. points(x=ic50_points$concnm, y=pmin(ic50_points$resid,max(ylims)), pch=20, cex=0.5)
  494. if (cpd != 1035) { # had to hard-code this because drm() non-convergence throws a tryCatch-resistant error that stops execution
  495. m = drm(resid ~ concnm, fct=LL.4(fixed=c(b=NA,c=0,d=1,e=NA)), data=ic50_points %>% mutate(resid = pmin(resid, max(ylims))))
  496. ic50 = pmin(m$coefficients['e:(Intercept)'], max(ic50_points$concnm))
  497. plot(m, type='none', add=T)
  498. } else {
  499. ic50 = max(ic50_points$concnm)
  500. }
  501. greater_than = ifelse(ic50==max(ic50_points$concnm),'≥','')
  502. mtext(side=1, line=-2, adj=0, text=paste0(' ',cpd), cex=0.7)
  503. mtext(side=1, line=-1, adj=0, text=paste0(' ',greater_than,formatC(ic50,format='f',digits=0),' nM'), cex=0.7)
  504. mtext(side=3, adj=0.05, text=LETTERS[panel], line=-1); panel = panel + 1
  505. i = i + 1
  506. }
  507. z_ic50 %>%
  508. rename(descno = compound, resid = normed, concnm = dose) %>%
  509. select(descno, concnm, resid) -> ic50_points_out
  510. write_supp_table(ic50_points_out, 'Mouse siRNA sequence IC50 determination in N2a cells with bDNA assay readout.')
  511. ### human screen ####
  512. z_hu_scr = read_tsv('data/miscellaneous/human_screen.tsv', col_types=cols())
  513. z_hu_scr %>%
  514. filter(!is.na(ratio)) %>%
  515. filter(species=='Ms') %>% # predicted non-reactive
  516. group_by(descno) %>%
  517. summarize(.groups='keep', n_replicates = n(), mean=mean(ratio)) %>%
  518. ungroup() %>%
  519. filter(n_replicates > 1) %>%
  520. summarize(ntc_mean = mean(mean)) %>%
  521. pull() -> ntc_mean
  522. ylims = c(0,1.5)
  523. z_hu_scr %>%
  524. filter(!is.na(ratio)) %>%
  525. inner_join(species_meta, by='species') %>%
  526. mutate(resid = pmin(ratio / ntc_mean, max(ylims))) %>%
  527. arrange(disp, descno) %>%
  528. mutate(x = dense_rank(paste0(disp, formatC(descno,width=4,flag='0')))) -> scr
  529. scr %>%
  530. group_by(x, disp, descno) %>%
  531. summarize(.groups='keep',
  532. mean = mean(resid),
  533. l95 = lower(resid),
  534. u95 = upper(resid)) %>%
  535. ungroup() -> scr_smry
  536. scr_smry %>%
  537. group_by(disp) %>%
  538. summarize(.groups='keep',
  539. minx = min(x),
  540. midx = mean(x),
  541. maxx = max(x)) %>%
  542. ungroup() -> tranches
  543. xlims = range(scr_smry$x) + c(-0.5, 0.5)
  544. ybigs = 0:3/2
  545. ybiglabs = c('0%','50%','100%','≥150%')
  546. par(mar=c(4,4,2,1))
  547. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i')
  548. axis(side=1, at=xlims, lwd.ticks=0, labels=NA)
  549. axis(side=2, at=ybigs, labels=NA)
  550. axis(side=2, at=ybigs, labels=ybiglabs, cex.axis=0.8, las=2, line=-0.5, lwd=0)
  551. mtext(side=2, line=2.5, text='residual Prnp')
  552. axis(side=3, at=xlims, lwd.ticks=0, labels=NA)
  553. abline(h=1, lty=3)
  554. barwidth = 0.8
  555. rect(xleft=scr_smry$x-barwidth/2, xright=scr_smry$x+barwidth/2,
  556. ybottom=rep(0,nrow(scr_smry)), ytop=scr_smry$mean, col=alpha('#000000',ci_alpha),
  557. border=NA)
  558. arrows(x0=scr_smry$x, y0=scr_smry$l95, y1=scr_smry$u95, angle=90, length=0.05, code=3)
  559. points(scr$x, scr$resid, pch=21, bg='#FFFFFF')
  560. mtext(side=1, at=scr_smry$x, text=scr_smry$descno, las=2, cex=0.5)
  561. tranche_line = 1.75
  562. overhang_left = 0.4
  563. overhang_right = 0.4
  564. for (i in 1:nrow(tranches)) {
  565. axis(side=1, line=tranche_line, at=c(tranches$minx[i], tranches$maxx[i]) + c(-1,1)*c(overhang_left,overhang_right), tck=0.03, labels=NA)
  566. mtext(side=1, line=tranche_line+0.2, at=tranches$midx[i], text=tranches$disp[i], cex=0.8)
  567. }
  568. mtext(side=3, adj=0, text='human A549 cells', line=0.5)
  569. mtext(side=3, adj=-0.2, text=LETTERS[panel], line=0.5); panel = panel + 1
  570. scr_smry %>%
  571. select(-x) %>%
  572. rename(species=disp) %>%
  573. relocate(descno) -> scr_smry_out
  574. write_supp_table(scr_smry_out, 'Human siRNA sequence screen in A549 cells with bDNA assay readout.')
  575. ### human IC50 ####
  576. z_ic50_hu = read_tsv('data/miscellaneous/ic50_hu.tsv', col_types=cols())
  577. z_ic50 = z_ic50_hu
  578. cpds = unique(z_ic50_hu$compound)
  579. par(mar=c(2,3,1,1))
  580. i = 1
  581. for (cpd in cpds) {
  582. if (i == 1) {
  583. par(mar=c(0.5,3,3,1))
  584. } else if (i == 2) {
  585. par(mar=c(0.5,1,3,3))
  586. } else if (i == 3) {
  587. par(mar=c(3,3,0.5,1))
  588. } else if (i == 4) {
  589. par(mar=c(3,1,0.5,3))
  590. }
  591. ic50_points = z_ic50 %>%
  592. subset(compound==cpd) %>%
  593. rename(resid = normed, concnm = dose)
  594. ylims = c(0, 1.5)
  595. xlims = range(ic50_points$concnm[ic50_points$concnm > 0]) * c(1/3.16, 3.16)
  596. xbigs = 10^(-3:3)
  597. xbiglabs = -3:3
  598. xats = rep(1:9, 7) * rep(10^(-3:3), each=9)
  599. ybigs = 0:3/2
  600. ybiglabs = c('0%','50%','100%','≥150%')
  601. plot(NA, NA, xlim=xlims, ylim=ylims, xaxs='i', yaxs='i', ann=F, axes=F, log='x')
  602. axis(side=1, at=xlims, lwd.ticks=0, labels=NA)
  603. axis(side=1, at=xbigs, labels=NA, tck=-0.05)
  604. axis(side=1, at=xats, labels=NA, tck=-0.02)
  605. axis(side=2, at=ylims, labels=NA, lwd.ticks=0)
  606. if (i %% 2 == 1) { # first in each row
  607. axis(side=2, at=ybigs, labels=NA, tck=0.025)
  608. axis(side=2, at=ybigs, labels=ybiglabs, lwd=0, line=-.75, las=2, cex.axis=.75)
  609. }
  610. if (i > length(cpds)/2) { # bottom row
  611. axis(side=1, at=xbigs, labels=xbiglabs, lwd.ticks=0, lwd=0, line=-1.0, cex.axis=.7)
  612. mtext(side=1, line=1, text='log10(nM)', cex=0.6)
  613. }
  614. if (i==3) { # bottom left
  615. mtext(side=2, line=2.5, at=max(ylims), text='residual Prnp', cex=.8)
  616. }
  617. abline(h=c(0.5,1), lty=3, lwd=0.5)
  618. points(x=ic50_points$concnm, y=pmin(ic50_points$resid,max(ylims)), pch=20, cex=0.5)
  619. if (cpd != 1035) { # had to hard-code this because drm() non-convergence throws a tryCatch-resistant error that stops execution
  620. m = drm(resid ~ concnm, fct=LL.4(fixed=c(b=NA,c=0,d=1,e=NA)), data=ic50_points %>% mutate(resid = pmin(resid, max(ylims))))
  621. ic50 = pmin(m$coefficients['e:(Intercept)'], max(ic50_points$concnm))
  622. plot(m, type='none', add=T)
  623. } else {
  624. ic50 = max(ic50_points$concnm)
  625. }
  626. greater_than = ifelse(ic50==max(ic50_points$concnm),'≥','')
  627. mtext(side=1, line=-2, adj=0, text=paste0(' ',cpd), cex=0.7)
  628. mtext(side=1, line=-1, adj=0, text=paste0(' ',greater_than,formatC(ic50,format='f',digits=0),' nM'), cex=0.7)
  629. mtext(side=3, adj=0.05, text=LETTERS[panel], line=-1); panel = panel + 1
  630. i = i + 1
  631. }
  632. z_ic50 %>%
  633. rename(descno = compound, resid = normed, concnm = dose) %>%
  634. select(descno, concnm, resid) -> ic50_points_out
  635. write_supp_table(ic50_points_out, 'Human siRNA sequence IC50 determination in A549 cells with bDNA assay readout.')
  636. silence_is_golden = dev.off()
  637. }
  638. # check that species cross-reactivity never contradict each other
  639. #
  640. # z_mo_scr %>% distinct(descno, species) -> mo_desig
  641. # z_hu_scr %>% distinct(descno, species) -> hu_desig
  642. #
  643. # mo_desig %>%
  644. # full_join(hu_desig, by='descno', suffix=c('_mo','_hu')) %>%
  645. # filter(species_mo == species_hu)
  646. ## Figure S3. Broad mouse reagent screening ####
  647. tell_user('done.\nCreating Figure S3...')
  648. if ('figure-s3'=='figure-s3') {
  649. resx=300
  650. png('display_items/figure-s03.png',width=6.5*resx,height=3.5*resx,res=resx)
  651. layout_matrix = matrix(c(1, 1, 2, 3,
  652. 1, 1, 4, 5), nrow=2, byrow=T)
  653. layout(layout_matrix, widths=c(1, rep(.5, .5)))
  654. par(mar=c(5,5,3,1))
  655. panel = 1
  656. #
  657. # ylims = c(0,1.5)
  658. # mouse_initial_screen_raw = read_tsv('data/miscellaneous/mouse_initial_screen.tsv', col_types=cols())
  659. #
  660. # mouse_initial_screen_raw %>%
  661. # group_by(sequence_number) %>%
  662. # summarize(.groups = 'keep',
  663. # mean = mean(residual),
  664. # l95 = lower(residual),
  665. # u95 = upper(residual),
  666. # cv = sd(residual)/mean(residual)) %>%
  667. # ungroup() -> mouse_initial_screen_stats
  668. #
  669. # mouse_initial_screen_raw %>%
  670. # anti_join(mouse_initial_screen_stats %>% filter(cv > 0.75), by='sequence_number') %>%
  671. # mutate(x = rank_uniq(sequence_number)) %>%
  672. # mutate(color = '#000000') -> init
  673. #
  674. # init %>%
  675. # group_by(x, sequence_number, color) %>%
  676. # summarize(.groups='keep',
  677. # mean = mean(residual),
  678. # l95 = lower(residual),
  679. # u95 = upper(residual)) %>%
  680. # ungroup() -> init_smry
  681. #
  682. # xlims = range(init$x + c(-0.5, 0.5))
  683. # ylims = c(0, 1.5)
  684. # yats = 0:6/4
  685. # ybigs = 0:3/2
  686. # plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i')
  687. # axis(side=1, at=xlims, lwd.ticks=0, labels=NA)
  688. # mtext(side=1, at=init_smry$x, text=init_smry$sequence_number, las=2, line=0.25)
  689. # axis(side=2, at=yats, labels=NA, tck=-0.02)
  690. # axis(side=2, at=ybigs, labels=NA, tck=-0.05)
  691. # axis(side=2, at=ybigs, labels=percent(ybigs), lwd=0, line=-0.5, las=2)
  692. # abline(h=1, lty=3)
  693. # points(x=init$x, y=pmin(init$residual,max(ylims)), col=alpha(init$color, ci_alpha), pch=19)
  694. # barwidth = 0.5
  695. # rect(xleft=init_smry$x - barwidth/2, xright=init_smry$x + barwidth/2, ybottom=rep(0, nrow(init_smry)), ytop=init_smry$mean, col=alpha(init_smry$color, ci_alpha), border=NA)
  696. # arrows(x0=init_smry$x, y0=init_smry$l95, y1=init_smry$u95, code=3, angle=90, length=0.05, lwd=1.5)
  697. cellulo %>%
  698. filter(purpose=='screen' & cells=='N2a' & concnm == 2000 & sample_group != 'untreated' & !is.na(descno)) %>%
  699. mutate(color = '#000000') %>%
  700. mutate(descno = as.integer(descno)) %>%
  701. mutate(x = rank_uniq(descno)) %>%
  702. group_by(x, descno, concnm, biorep, color) %>% # group first across techreps within biorep
  703. summarize(.groups='keep',
  704. resid = mean(resid)) %>%
  705. ungroup() -> mouse_screen
  706. mouse_screen %>%
  707. group_by(x, descno, concnm, color) %>% # now group across bioreps
  708. summarize(.groups = 'keep',
  709. n = n(),
  710. mean = mean(resid),
  711. l95 = lower(resid),
  712. u95 = upper(resid)) %>%
  713. ungroup() -> mouse_screen_smry
  714. mouse_screen_smry %>%
  715. select(descno, concnm, mean, l95, u95) -> mouse_screen_smry_out
  716. write_supp_table(mouse_screen_smry_out, 'Mouse siRNA sequence screen in N2a cells with qPCR readout.')
  717. xlims = range(mouse_screen$x + c(-0.5, 0.5))
  718. ylims = c(0, 1.5)
  719. yats = 0:6/4
  720. ybigs = 0:3/2
  721. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i')
  722. axis(side=1, at=xlims, lwd.ticks=0, labels=NA)
  723. mtext(side=1, at=mouse_screen_smry$x, text=mouse_screen_smry$descno, las=2, line=0.25)
  724. axis(side=2, at=yats, labels=NA, tck=-0.02)
  725. axis(side=2, at=ybigs, labels=NA, tck=-0.05)
  726. axis(side=2, at=ybigs, labels=percent(ybigs), lwd=0, line=0, las=2)
  727. mtext(side=2, line=3.0, text='residual RNA', cex=.75)
  728. abline(h=1, lty=3)
  729. points(x=mouse_screen$x, y=pmin(mouse_screen$resid,max(ylims)), col=alpha(mouse_screen$color, ci_alpha), pch=19)
  730. barwidth = 0.5
  731. rect(xleft=mouse_screen_smry$x - barwidth/2, xright=mouse_screen_smry$x + barwidth/2, ybottom=rep(0, nrow(mouse_screen_smry)), ytop=mouse_screen_smry$mean, col=alpha(mouse_screen_smry$color, ci_alpha), border=NA)
  732. arrows(x0=mouse_screen_smry$x, y0=mouse_screen_smry$l95, y1=mouse_screen_smry$u95, code=3, angle=90, length=0.05, lwd=1.5)
  733. mtext(LETTERS[panel], side=3, cex=2, adj = 0, line = 0.5)
  734. panel = panel + 1
  735. cellulo %>%
  736. filter(purpose=='IC50' & cells=='N2a') %>%
  737. group_by(descno, concnm, biorep) %>% # group first across techreps within biorep
  738. summarize(.groups='keep',
  739. resid = mean(resid)) %>%
  740. ungroup() %>%
  741. group_by(descno, concnm) %>%
  742. summarize(.groups = 'keep',
  743. n = n(),
  744. mean = mean(resid),
  745. l95 = lower(resid),
  746. u95 = upper(resid)) %>%
  747. ungroup() %>%
  748. filter(!is.na(descno)) -> mouse_ic50
  749. mouse_ic50 %>%
  750. distinct(descno) -> ic50s
  751. ylims = c(0, 1.25)
  752. xlims = range(mouse_ic50$concnm) * c(1/3.16, 3.16)
  753. for (i in 1:nrow(ic50s)) {
  754. cellulo %>%
  755. filter(descno %in% ic50s$descno[i] & purpose=='IC50' & cells=='N2a') %>%
  756. group_by(descno, concnm, biorep) %>% # group first across techreps within biorep
  757. summarize(.groups='keep',
  758. resid = mean(resid)) %>%
  759. ungroup() %>%
  760. select(descno, concnm, resid) -> ic50_points
  761. ic50_points %>%
  762. group_by(descno, concnm) %>%
  763. summarize(.groups = 'keep',
  764. n = n(),
  765. mean = mean(resid),
  766. l95 = lower(resid),
  767. u95 = upper(resid)) %>%
  768. ungroup() -> ic50_smry
  769. par(mar=c(3,3,3,1))
  770. plot(NA, NA, xlim=xlims, ylim=ylims, xaxs='i', yaxs='i', ann=F, axes=F, log='x')
  771. axis(side=1, at=xlims, lwd.ticks=0, labels=NA)
  772. axis(side=1, at=10^(-3:3), labels=NA, tck=-0.025)
  773. axis(side=1, at=10^(-3:3), labels=-3:3, lwd.ticks=0, lwd=0, line=-1.0, cex.axis=.7)
  774. mtext(side=1, line=1, text='log10(nM)', cex=0.75)
  775. axis(side=2, at=0:4/2, labels=NA, tck=-0.025)
  776. axis(side=2, at=0:4/2, labels=percent(0:4/2), lwd=0, line=-.75, las=2, cex.axis=.75)
  777. mtext(side=2, line=1.75, text='residual RNA', cex=.75)
  778. abline(h=c(0.5,1), lty=3, lwd=0.5)
  779. points(x=ic50_points$concnm, y=ic50_points$resid, pch=20, cex=0.5)
  780. m = drm(resid ~ concnm, fct=LL.4(), data=ic50_points)
  781. plot(m, type='none', add=T)
  782. mtext(side=3, line=1, text=ic50_smry$descno[1], cex=0.4)
  783. mtext(side=3, line=0, text=paste0(formatC(m$coefficients['e:(Intercept)'],format='f',digits=1),' nM'), cex=0.4)
  784. mtext(LETTERS[panel], side=3, cex=2, adj = -0.5, line = 0.5)
  785. panel = panel + 1
  786. }
  787. write_supp_table(mouse_ic50, 'Mouse siRNA IC50 determination in N2a cells with qPCR readout.')
  788. silence_is_golden = dev.off()
  789. }
  790. ## Figure 2. Mouse POC ####
  791. tell_user('done.\nCreating Figure 2...')
  792. if ('figure-2'=='figure-2') {
  793. resx=300
  794. png('display_items/figure-2.png',width=6.5*resx,height=7*resx,res=resx)
  795. layout_matrix = matrix(c(1, 1, 2, 3,
  796. 4, 4, 4, 4,
  797. 5, 5, 6, 6,
  798. 7, 7, 8, 8), nrow=4, byrow=T)
  799. layout(layout_matrix, heights=c(1,0.2,1,1))
  800. panel = 1
  801. ### Mouse TE in vivo screen ####
  802. mouse_te = c('CMR-1403','CMR-1656')
  803. proc = process_elisas(mouse_te, control_group='saline') %>%
  804. filter(dose_dio %in% c(0,10)) %>%
  805. arrange(dose_dio, tx) %>%
  806. inner_join(meta, by='tx') -> proc
  807. proc %>%
  808. distinct(tx, display_tx, is_reference, is_ntc, sequence_number, color) %>%
  809. mutate(is_exna = grepl('exNA',tx,ignore.case=T)) %>%
  810. arrange(!is_reference, !is_ntc, sequence_number, is_exna) %>%
  811. mutate(x = row_number()) -> xes
  812. proc$x = xes$x[match(proc$tx, xes$tx)]
  813. par(mar=c(4,4,3,1))
  814. xlims = range(proc$x)+c(-0.5,0.5)
  815. ylims = c(0,1.55)
  816. yats=0:6/4
  817. ybigs=0:3/2
  818. ybiglabs=percent(ybigs)
  819. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i')
  820. axis(side=1, at=xlims, labels=NA, lwd.ticks=0)
  821. par(xpd=T)
  822. text(x=xes$x, y=rep(-0.05, nrow(xes)), labels=xes$display_tx, srt=45, adj=1)
  823. par(xpd=F)
  824. axis(side=2, at=yats, tck = -0.02, labels=NA)
  825. axis(side=2, at=ybigs, tck = -0.05, labels=NA)
  826. axis(side=2, at=ybigs, lwd=0, labels=ybiglabs, las=2, line=-0.5)
  827. mtext(side=2, line=2.75, text='residual PrP', cex=0.8)
  828. proc %>%
  829. group_by(x, tx, display_tx, color) %>%
  830. summarize(.groups = 'keep',
  831. n = n(),
  832. mean = mean(rel),
  833. l95 = lower(rel),
  834. u95 = upper(rel),
  835. max = max(rel)) %>%
  836. ungroup() -> proc_smry
  837. barwidth=0.6
  838. rect(xleft=proc_smry$x-barwidth/2, xright=proc_smry$x+barwidth/2, ybottom=rep(0, nrow(proc_smry)), ytop=proc_smry$mean, col=alpha(proc_smry$color, ci_alpha), border=NA)
  839. arrows(x0=proc_smry$x, y0=proc_smry$l95, y1=proc_smry$u95, col=proc_smry$color, lwd=1.5, code=3, angle=90, length=0.05)
  840. abline(h=1, lty=3)
  841. points(x=proc$x, y=proc$rel, col=proc$color, bg='#FFFFFF', pch=21)
  842. text(x=proc_smry$x, y=proc_smry$max, pos=3, labels=percent(proc_smry$mean,digits=1), cex=0.7)
  843. mtext(LETTERS[panel], side=3, cex=1, adj = -0.1, line = 0.5); panel = panel + 1
  844. write_supp_table(proc, 'Mouse siRNA in vivo target engagement - individual animal data.')
  845. write_supp_table(proc_smry, 'Mouse siRNA in vivo target engagement - summarized data.')
  846. yb_wts %>%
  847. arrange(dpi) %>%
  848. group_by(animal) %>%
  849. slice(1) %>%
  850. select(animal, baseline_weight=weight) -> baselines
  851. for (this_wt_dpi in c(71,125)) {
  852. wt_thisdpi_meta = tibble(inoculum=c('none','RML'),
  853. x = c(1,2),
  854. color = c('#A9A9A9','#8E2323'))
  855. yb_wts %>%
  856. inner_join(baselines, by='animal') %>%
  857. mutate(rel=weight/baseline_weight-1) %>%
  858. inner_join(yb_blind, by='animal') %>%
  859. inner_join(yb_meta, by=c('cohort','inoculum')) %>%
  860. filter(this_wt_dpi == 71 | !grepl('75',cohort)) %>% # for 71 dpi we can include all RML-inoc'ed animals, while for 126, we must exclude those that received treatment at 75 dpi
  861. filter(dpi == this_wt_dpi) %>%
  862. inner_join(wt_thisdpi_meta, by='inoculum', suffix = c('_cohort','_inoc')) -> indiv_thisdpi_weights_rel
  863. indiv_thisdpi_weights_rel %>%
  864. select(animal, dpi, weight, baseline_weight, rel, inoculum) -> indiv_weights_out
  865. write_supp_table(indiv_weights_out, paste0('Weight changes at ',this_wt_dpi,' dpi in prion-infected vs. uninoculated mice - individual animals.'))
  866. indiv_thisdpi_weights_rel %>%
  867. group_by(inoculum, x, color_inoc) %>%
  868. summarize(.groups='keep',
  869. mean = mean(rel),
  870. sd = sd(rel),
  871. n = n(),
  872. l95 = mean(rel) - 1.96*sd(rel)/sqrt(n()),
  873. u95 = mean(rel) + 1.96*sd(rel)/sqrt(n())) %>%
  874. ungroup() -> wt_thisdpi_smry
  875. uninoc = indiv_thisdpi_weights_rel$rel[indiv_thisdpi_weights_rel$inoculum=='none']
  876. rml = indiv_thisdpi_weights_rel$rel[indiv_thisdpi_weights_rel$inoculum=='RML']
  877. t_test_result = t.test(uninoc,rml)
  878. wt_thisdpi_smry %>%
  879. select(-x, -color_inoc) %>%
  880. mutate(pval_ttest = case_when(inoculum=='none' ~ 1.0,
  881. inoculum=='RML' ~ t_test_result$p.value)) -> wt_thisdpi_smry_out
  882. write_supp_table(wt_thisdpi_smry_out, paste0('Weight changes at ',this_wt_dpi,' dpi in prion-infected vs. uninoculated mice - summarized.'))
  883. indiv_thisdpi_weights_rel -> indiv_weights_rel
  884. wt_thisdpi_smry -> wt_smry
  885. par(mar=c(1.5,4,3,1))
  886. xlims = c(0.5,2.5)
  887. ylims = c(-0.10,0.30)
  888. plot(NA, NA, xlim=xlims, ylim=ylims, xaxs='i', yaxs='i', ann=F, axes=F)
  889. axis(side=1, at=xlims, labels=NA, lwd=1, lwd.ticks=0)
  890. mtext(side=1, line=0.25, at=wt_smry$x, text=wt_smry$inoculum, cex=0.8)
  891. axis(side=2, at=seq(-.3,.4,.1), labels=NA, las=2, tck=-0.05)
  892. axis(side=2, at=seq(-.3,.4,.1), labels=percent(seq(-.3,.4,.1), signed=T), lwd=0, las=2, line=-0.5)
  893. axis(side=2, at=seq(-.3,.4,.05), labels=NA, las=2, tck=-0.025)
  894. abline(h=0, lty=3, lwd=1)
  895. set.seed(1)
  896. points(x=jitter(indiv_thisdpi_weights_rel$x, amount=.25), y=indiv_thisdpi_weights_rel$rel, pch=20, col=alpha(indiv_thisdpi_weights_rel$color_inoc, ci_alpha))
  897. barwidth=0.3
  898. segments(x0=wt_smry$x-barwidth, x1=wt_smry$x+barwidth, y0=wt_smry$mean, col=wt_smry$color_inoc, lwd=1.5)
  899. arrows(x0=wt_smry$x, y0=wt_smry$l95, y1=wt_smry$u95, code=3, angle=90, length=0.05, col=wt_smry$color_inoc, lwd=1.5)
  900. mtext(side=2, line=2.5, text='weight change', cex=0.8)
  901. mtext(side=3, line=0, text=paste0(this_wt_dpi,' dpi'), cex=0.8)
  902. axis(side=3, line=-3, at=wt_thisdpi_meta$x, tck=0.05, labels=NA)
  903. mtext(side=3, line=-2.7, at=mean(wt_thisdpi_meta$x), text=paste0("P = ",formatC(t_test_result$p.value, format='fg', digits=2)), cex=0.7)
  904. mtext(LETTERS[panel], side=3, cex=1, adj = -0.1, line = 0.5); panel = panel + 1
  905. }
  906. #
  907. # yb_wts %>%
  908. # inner_join(baselines, by='animal') %>%
  909. # mutate(rel=weight/baseline_weight-1) %>%
  910. # inner_join(yb_blind, by='animal') %>%
  911. # inner_join(yb_meta, by=c('cohort','inoculum')) %>%
  912. # filter(!grepl('75',cohort)) %>%
  913. # filter(dpi == 125) -> indiv_125_weights_rel
  914. #
  915. # wt_125_meta = tibble(inoculum=c('none','RML'),
  916. # x = c(1,2),
  917. # color = c('#A9A9A9','#8E2323'))
  918. #
  919. # indiv_125_weights_rel %>%
  920. # group_by(inoculum) %>%
  921. # summarize(.groups='keep',
  922. # mean = mean(rel),
  923. # sd = sd(rel),
  924. # n = n(),
  925. # l95 = mean(rel) - 1.96*sd(rel)/sqrt(n()),
  926. # u95 = mean(rel) + 1.96*sd(rel)/sqrt(n())) %>%
  927. # ungroup() %>%
  928. # inner_join(wt_125_meta, by='inoculum') -> wt_125_smry
  929. #
  930. # uninoc = indiv_125_weights_rel$rel[indiv_125_weights_rel$inoculum=='none']
  931. # rml = indiv_125_weights_rel$rel[indiv_125_weights_rel$inoculum=='RML']
  932. #
  933. # t.test(uninoc,rml)
  934. #
  935. # indiv_125_weights_rel -> indiv_weights_rel
  936. # wt_125_smry -> wt_smry
  937. # par(mar=c(1.5,4,3,1))
  938. # xlims = c(0.5,2.5)
  939. # ylims = c(-0.10,0.30)
  940. # plot(NA, NA, xlim=xlims, ylim=ylims, xaxs='i', yaxs='i', ann=F, axes=F)
  941. # axis(side=1, at=xlims, labels=NA, lwd=1, lwd.ticks=0)
  942. # mtext(side=1, line=0.25, at=wt_smry$x, text=wt_smry$inoculum)
  943. # axis(side=2, at=seq(-.3,.4,.1), labels=NA, las=2, tck=-0.05)
  944. # axis(side=2, at=seq(-.3,.4,.1), labels=percent(seq(-.3,.4,.1), signed=T), lwd=0, las=2, line=-0.5)
  945. # axis(side=2, at=seq(-.3,.4,.05), labels=NA, las=2, tck=-0.025)
  946. # abline(h=0, lty=3, lwd=1)
  947. # set.seed(1)
  948. # points(x=jitter(rep(1,length(uninoc)),amount=.25), y=uninoc, pch=20, col=alpha(uninoc_col, ci_alpha))
  949. # points(x=jitter(rep(2,length(rml)),amount=.25), y=rml, pch=20, col=alpha(rml_col, ci_alpha))
  950. # barwidth=0.3
  951. # segments(x0=wt_smry$x-barwidth, x1=wt_smry$x+barwidth, y0=wt_smry$mean, col=wt_smry$color, lwd=1.5)
  952. # arrows(x0=wt_smry$x, y0=wt_smry$l95, y1=wt_smry$u95, code=3, angle=90, length=0.05, col=wt_smry$color, lwd=1.5)
  953. # mtext(side=2, line=2.5, text='weight change', cex=0.8)
  954. # mtext(side=3, line=0, text='125 dpi', cex=0.8)
  955. # mtext(LETTERS[panel], side=3, cex=2, adj = 0, line = 0.5)
  956. # panel = panel + 1
  957. par(mar=c(0,0,0,0))
  958. plot(NA, NA, xlim=c(0,1), ylim=c(0,1), axes=F, ann=F, xaxs='i', yaxs='i')
  959. yb_meta %>% distinct(color, lty, legdisp) -> leg
  960. legend('top', horiz=T, bty='n', cex=0.9, lwd=2, leg$legdisp, col=leg$color, text.col=leg$color, lty=leg$lty)
  961. yb_master %>%
  962. inner_join(yb_blind, by='animal') %>%
  963. inner_join(yb_meta, by='cohort') %>%
  964. select(animal, cohort, dpi, acm, prion_endpoint, color, lty, inoculation_date) -> survdata
  965. survdata %>%
  966. select(-color, -lty, -inoculation_date) -> survdata_out
  967. write_supp_table(survdata_out, 'Survival in challenge study - individual animal data.')
  968. survdata %>%
  969. mutate(intervention_dpi = gsub('.*-','',cohort)) %>%
  970. mutate(tx = gsub('.*-','',gsub('-[0-9]*$','',cohort)) ) %>%
  971. filter(acm & tx != 'uninoc') %>%
  972. group_by(cohort, intervention_dpi, tx) %>%
  973. summarize(.groups='keep',
  974. n=n(),
  975. mean_dpi=mean(dpi),
  976. sd_dpi = sd(dpi),
  977. median_dpi = median(dpi)) %>%
  978. ungroup() %>%
  979. arrange(desc(intervention_dpi), desc(tx)) -> yb_survdata_smry
  980. write_supp_table(yb_survdata_smry, 'Survival in challenge study - summarized.')
  981. survdiff(Surv(dpi, acm) ~ cohort, data=subset(survdata, grepl('75',cohort)))
  982. survdiff(Surv(dpi, acm) ~ cohort, data=subset(survdata, grepl('126',cohort)))
  983. sf = survfit(Surv(dpi, acm) ~ cohort, data=survdata)
  984. sf$color = yb_meta$color[match(gsub('cohort=','',names(sf$strata)), yb_meta$cohort)]
  985. sf$lty = yb_meta$lty[match(gsub('cohort=','',names(sf$strata)), yb_meta$cohort)]
  986. allsurvdata = survdata
  987. for (this_txdpi in c(75,126)) {
  988. txdpi_marks = this_txdpi
  989. if (this_txdpi == 75) {
  990. txdpi_marks = c(75, 194, 315, 439)
  991. }
  992. allsurvdata %>%
  993. filter(grepl(this_txdpi,cohort) | grepl('(uninoc|none)',cohort)) -> survdata
  994. sf = survfit(Surv(dpi, acm) ~ cohort, data=survdata)
  995. sf$color = yb_meta$color[match(gsub('cohort=','',names(sf$strata)), yb_meta$cohort)]
  996. sf$lty = yb_meta$lty[match(gsub('cohort=','',names(sf$strata)), yb_meta$cohort)]
  997. par(mar=c(3,4,1,1))
  998. xlims = c(0,500)
  999. ylims = c(0,1.05)
  1000. plot(sf, col=sf$color, lwd=2, lty=sf$lty, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i')
  1001. axis(side=1, at=seq(0,600,100), labels=NA, tck=-0.05)
  1002. axis(side=1, at=seq(0,600,100), lwd=0, labels=seq(0,600,100), line=-0.5)
  1003. axis(side=1, at=seq(0,600,10), labels=NA, tck=-0.025)
  1004. mtext(side=1, line=1.5, text='days post-inoculation')
  1005. axis(side=2, at=0:4/4, labels=percent(0:4/4), las=2)
  1006. mtext(side=2, line=2.75, text='survival', cex=0.8)
  1007. par(xpd=T)
  1008. points(x=c(txdpi_marks), y=rep(max(ylims),length(txdpi_marks)), pch=25, bg='#000000')
  1009. par(xpd=F)
  1010. mtext(LETTERS[panel], side=3, cex=1, adj = -0.1, line = 0.5); panel = panel + 1
  1011. yb_wts %>%
  1012. inner_join(yb_blind %>% select(-inoculum), by='animal') %>%
  1013. inner_join(yb_meta, by='cohort') %>%
  1014. filter(txdpi == this_txdpi | is.na(txdpi)) -> weights_curr
  1015. weights_curr %>%
  1016. arrange(dpi) %>%
  1017. group_by(animal) %>%
  1018. slice(1) %>%
  1019. select(animal, baseline_weight=weight) -> baselines
  1020. weights_curr %>%
  1021. inner_join(baselines, by='animal') %>%
  1022. mutate(rel=weight/baseline_weight-1) %>%
  1023. group_by(cohort, dpi, color, lty) %>%
  1024. summarize(.groups='keep',
  1025. mean = mean(rel),
  1026. sd = sd(rel),
  1027. n = n(),
  1028. l95 = mean(rel) - 1.96*sd(rel)/sqrt(n()),
  1029. u95 = mean(rel) + 1.96*sd(rel)/sqrt(n())) %>%
  1030. ungroup() %>%
  1031. filter(n > 2) -> weights_rel
  1032. weights_rel %>% filter(grepl(this_txdpi, cohort) | grepl('(uninoc|none)',cohort)) -> weights_curr
  1033. weights_rel %>%
  1034. select(-color, -lty) -> weights_rel_out
  1035. write_supp_table(weights_rel_out, paste0('Weight changes in challenge study ',this_txdpi,' dpi - individual animal data.'))
  1036. weights_curr %>%
  1037. select(-color, -lty) -> weights_curr_out
  1038. write_supp_table(weights_curr_out, paste0('Weight changes in challenge study ',this_txdpi,' dpi - summarized.'))
  1039. par(mar=c(3,4,1,4))
  1040. xlims = c(0, 500)
  1041. ylims = c(-.3, .3)
  1042. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i')
  1043. axis(side=1, at=seq(0,600,100), labels=NA, tck=-0.05)
  1044. axis(side=1, at=seq(0,600,100), lwd=0, labels=seq(0,600,100), line=-0.5)
  1045. axis(side=1, at=seq(0,600,10), labels=NA, tck=-0.025)
  1046. mtext(side=1, line=1.5, text='days post-inoculation')
  1047. axis(side=2, at=seq(-.3,.4,.1), labels=NA, las=2, tck=-0.05)
  1048. axis(side=2, at=seq(-.3,.4,.1), labels=percent(seq(-.3,.4,.1), signed=T), lwd=0, las=2, line=-0.5)
  1049. axis(side=2, at=seq(-.3,.4,.05), labels=NA, las=2, tck=-0.025)
  1050. abline(h=0)
  1051. abline(h=-.2, col='red', lty=3)
  1052. mtext(side=4, at=-.2, las=2, col='red', text='endpoint', cex=.8)
  1053. mtext(side=2, line=2.75, text='weight change', cex=0.8)
  1054. for (coh in unique(weights_curr$cohort)) {
  1055. subs = weights_curr[weights_curr$cohort==coh,]
  1056. points(subs$dpi, subs$mean, type='l', lwd=2, col=subs$color, lty=subs$lty)
  1057. polygon(x=c(subs$dpi,rev(subs$dpi)),y=c(subs$l95,rev(subs$u95)),col=alpha(subs$color,ci_alpha),border=NA)
  1058. }
  1059. par(xpd=T)
  1060. points(x=c(txdpi_marks), y=rep(max(ylims),length(txdpi_marks)), pch=25, bg='#000000')
  1061. par(xpd=F)
  1062. mtext(LETTERS[panel], side=3, cex=1, adj = -0.1, line = 0.5); panel = panel + 1
  1063. }
  1064. silence_is_golden = dev.off()
  1065. }
  1066. ## Table 1. Humanized mouse models ####
  1067. tell_user('done.\nCreating Table 1...')
  1068. elisa_hu = rbind_files('data/elisa/','02[67]_summary.tsv') %>%
  1069. filter(!grepl('QC|Neg',sample)) %>%
  1070. rename(animal=sample) %>%
  1071. mutate(plate = as.integer(substr(file,1,3)))
  1072. samples = read_tsv('data/humanized/mouse_genotypes.tsv', col_types=cols()) %>%
  1073. mutate(animal = as.character(id))
  1074. params = read_tsv('data/humanized/mouse_genotypes_params.tsv', col_types=cols()) %>%
  1075. mutate(y = max(row_number()) - row_number())
  1076. elisa_hu %>%
  1077. inner_join(samples, by=c('animal')) %>%
  1078. group_by(plate) %>%
  1079. mutate(rel = ngml_av / mean(ngml_av[gt=='wild-type'])) %>%
  1080. ungroup() %>%
  1081. select(animal, gt, sex, age_wks, rel, ngml_av, plate) %>%
  1082. inner_join(params, by='gt') -> mashup
  1083. mashup %>%
  1084. rename(genotype=disp) %>%
  1085. select(genotype, color, animal, sex, age_wks, plate, ngml_av, rel) -> mashup_out
  1086. write_supp_table(mashup_out, 'PrP expression in human PrP transgenic mouse lines - individual animal data.')
  1087. # check there is no age effect (at least within the narrow age range included here)
  1088. m = lm(rel ~ age_wks + gt + sex, data=mashup)
  1089. # summary(m)
  1090. smry = mashup %>%
  1091. group_by(y, disp, color, copy_number) %>%
  1092. summarize(.groups='keep',
  1093. mean_raw = mean(ngml_av),
  1094. mean = mean(rel),
  1095. l95 = lower(rel),
  1096. u95 = upper(rel),
  1097. n = n(),
  1098. mf = paste0(sum(sex=='M'),'M/',sum(sex=='F'),'F')) %>%
  1099. ungroup()
  1100. write_supp_table(smry, 'PrP expression in human PrP transgenic mouse lines - summarized.')
  1101. ## Figure 3 humanized mice ####
  1102. if ('figure-3'=='figure-3') {
  1103. tell_user('done.\nCreating Figure 3...')
  1104. resx=300
  1105. png('display_items/figure-3.png', width=6.5*resx, height=5*resx, res=resx)
  1106. layout_matrix = matrix(c(1,1,2,
  1107. 3,3,3,
  1108. 4,4,4), nrow=3, byrow=T)
  1109. layout(layout_matrix, heights=c(1,.8,.2))
  1110. panel = 1
  1111. ### PrP expression by ELISA ####
  1112. par(mar=c(4,8,3,1))
  1113. xlims = c(0, 6.7)
  1114. ylims = range(smry$y) + c(-0.5, 0.5)
  1115. barwidth=0.33
  1116. dilution = 200
  1117. llq = 0.05
  1118. meanwt = smry$mean_raw[smry$disp=='WT']
  1119. llq_relative = llq * dilution / meanwt
  1120. plot(NA, NA, xlim=xlims, ylim=ylims, xaxs='i', yaxs='i', axes=F, ann=F)
  1121. axis(side=1, at=0:6, tck=-0.05, labels=NA)
  1122. axis(side=1, at=0:60/10, tck=-0.02, labels=NA)
  1123. axis(side=1, at=0:6, line=-0.5, lwd=0)
  1124. mtext(side=1, line=1.5, text='brain PrP (fold WT)', cex=0.8)
  1125. axis(side=2, at=ylims, labels=NA, lwd.ticks=0)
  1126. mtext(side=2, at=smry$y, text=smry$disp, col='#000000', las=2, line=0.25,cex=0.8)
  1127. abline(v=llq_relative, lwd=0.75, lty=3, col='red')
  1128. abline(v=1,lty=3)
  1129. mtext(side=3, at=llq_relative, cex=0.75, font=2, line=0.25, text=' LLQ', col='red')
  1130. arrows(x0=smry$l95, x1=smry$u95, y0=smry$y, angle=90, length=0.05, code=3, lwd=1, col=smry$color)
  1131. rect(xleft=rep(0 ,nrow(smry)), xright=smry$mean, ybottom=smry$y-barwidth, ytop=smry$y+barwidth, lwd=1, col=alpha(smry$color,ci_alpha), border=NA)
  1132. points(x=mashup$rel, y=mashup$y, pch=21, col=mashup$color, bg='#FFFFFF')
  1133. mtext(LETTERS[panel], side=3, cex=1, adj = -0.3, line = 0.0); panel = panel + 1
  1134. ### copy number vs. ELISA ####
  1135. par(mar=c(4,4,3,1))
  1136. plot(smry$copy_number, smry$mean, xlim=c(0,22), ylim=c(0,11),
  1137. col=smry$color, xaxs='i', yaxs='i', pch=19, axes=F,
  1138. ann=F)
  1139. mtext(side=1, line=1.6, text='DNA copy number')
  1140. mtext(side=2, line=1.7, text='PrP expression (fold WT)')
  1141. abline(a=0, b=0.5, lty=3, lwd=0.5)
  1142. axis(side=1, at=0:22, tck=-0.02, labels=NA)
  1143. axis(side=1, at=0:4*5, cex.axis=0.8, lwd=0, line=-0.5)
  1144. axis(side=1, at=0:4*5, tck=-0.05, labels=NA)
  1145. axis(side=2, at=0:11, tck=-0.02, labels=NA)
  1146. axis(side=2, at=0:2*5, lwd=0, line=-0.25, las=2, cex.axis=0.8)
  1147. axis(side=2, at=0:2*5, labels=NA, tck=-0.05)
  1148. mtext(LETTERS[panel], side=3, cex=1, adj = -0.1, line = 0.0); panel = panel + 1
  1149. ### BAC coverage ####
  1150. #
  1151. # layout_matrix = matrix(1:2, nrow=2, byrow=T)
  1152. # layout(layout_matrix, heights=c(1,.25))
  1153. # twist targets = c(4570000, 4710000)
  1154. # relevant region for BAC appears to be: 4640000, 4710000
  1155. # original BAM was aligned to GRCh37, need to offset to GRCh38
  1156. grch38_coding_offset = 4699605 - 4680251
  1157. depth = read_tsv('data/humanized/CYAGEN307331_depth.tsv', col_types=cols()) %>%
  1158. mutate(pos = pos + grch38_coding_offset)
  1159. all_possible_pos = tibble(pos=seq(4570000,4740000),by=1)
  1160. depth %>%
  1161. select(-chrom) %>%
  1162. right_join(all_possible_pos, by='pos') %>%
  1163. mutate(depth=replace_na(depth,0)) %>%
  1164. arrange(pos) -> depthtbl
  1165. depthtbl %>%
  1166. mutate(pos100 = floor(pos/100)*100) %>%
  1167. group_by(pos100) %>%
  1168. summarize(.groups='keep',
  1169. p30 = mean(depth >= 30),
  1170. p10 = mean(depth >= 10),
  1171. mn = mean(depth)) %>%
  1172. ungroup() -> depth100
  1173. depth100 %>%
  1174. rename(chr20_position_rounded_to_nearest_100 = pos100,
  1175. proportion_at_30x_depth_or_higher = p30,
  1176. proportion_at_10x_depth_or_higher = p10,
  1177. mean_depth = mn) -> depth100_out
  1178. write_supp_table(depth100_out, 'Sequencing depth by 100 bp chromosomal interval in Tg26372 mouse.')
  1179. #xlims = c(4640000, 4710000)
  1180. xlims = c(4570000, 4740000)
  1181. pseudozero = 1
  1182. ylims = c(pseudozero,1e5)
  1183. ybigs = c(1, 10, 100, 1000, 10000)
  1184. yats = rep(1:9, 6) * 10^(rep(-1:4, each=9))
  1185. ybiglabs = c('≤1', '10', '100', '1K','10K')
  1186. xbigs = seq(min(xlims), max(xlims), 10000)
  1187. xats = seq(min(xlims), max(xlims), 1000)
  1188. par(mar=c(1,4,1,2))
  1189. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i', log='y')
  1190. axis(side=1, at=xbigs, labels=NA,tck=-0.05)
  1191. axis(side=1, at=xats, labels=NA,tck=-0.02)
  1192. axis(side=1, at=xbigs, line=-0.5, labels=paste0(formatC(xbigs/1e6,digits=2,format='f'),'M'), lwd=0)
  1193. axis(side=2, at=ybigs, labels=NA,tck=-0.05)
  1194. axis(side=2, at=yats, labels=NA,tck=-0.02)
  1195. axis(side=2, at=ybigs, line=-0.25, las=2, labels=ybiglabs, lwd=0)
  1196. mtext(side=2, line=2.5, text='sequencing depth', cex=0.8)
  1197. mtext(side=1, line=1.6, adj=0, text='chr20 position', cex=0.8)
  1198. polygon(c(depth100$pos100,max(depth100$pos100),rev(depth100$pos100)), c(pmax(depth100$mn,pseudozero),pseudozero,rep(0,nrow(depth100))), lwd=3, col='#CEAB1277', border='#CEAB12')
  1199. mtext(LETTERS[panel], side=3, cex=1, adj = -0.05, line = 0.0); panel = panel + 1
  1200. exon1_start = c(4686456,4721909 )# transcription start site
  1201. exon1_end = c(4686512,4721969)
  1202. exon2_start =c(4699211,4724541)
  1203. exon2_end = c(4701588,4728460) # transcription end site
  1204. cds_start = c(4699221,4724552)
  1205. cds_end = c(4699982,4725079)
  1206. landmarks = tibble(gene = c('PRNP','PRND'),
  1207. exon1_start = exon1_start,
  1208. exon2_start = exon2_start,
  1209. exon1_end = exon1_end,
  1210. exon2_end = exon2_end,
  1211. cds_start = cds_start,
  1212. cds_end = cds_end,
  1213. exon2_fill = '#A3A3A3',
  1214. y = 2)
  1215. intron_lwd = 1
  1216. utr_lwd = 10
  1217. cds_lwd = 20
  1218. default_fill = '#000000'
  1219. utr_height = 2
  1220. cds_height = 4
  1221. prnd_height = 1
  1222. par(mar=c(0,4,0,2))
  1223. ylims = c(-2, 6)
  1224. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i')
  1225. segments(x0=landmarks$exon1_start, x1=landmarks$exon2_end, y0=landmarks$y, lwd=intron_lwd, lend=1)
  1226. rect(xleft=landmarks$exon1_start, xright=landmarks$exon1_end, ybottom=landmarks$y-utr_height/2, ytop=landmarks$y+utr_height/2, col=default_fill, border=NA)
  1227. rect(xleft=landmarks$exon2_start, xright=landmarks$exon2_end, ybottom=landmarks$y-utr_height/2, ytop=landmarks$y+utr_height/2, col=default_fill, border=NA)
  1228. rect(xleft=landmarks$cds_start, xright=landmarks$cds_end, ybottom=landmarks$y-cds_height/2, ytop=landmarks$y+cds_height/2, col=default_fill, border=NA)
  1229. text(x=(landmarks$exon2_end + landmarks$exon1_start)/2, y=landmarks$y-1.4, pos=1, labels=landmarks$gene, font=3, cex=0.8)
  1230. #text(x=(landmarks$exon2_end + landmarks$exon1_start)/2, y=landmarks$y, pos=1, labels=landmarks$gene, font=3, cex=0.8)
  1231. silence_is_golden = dev.off() ### end Fig 3 humanized mice ####
  1232. }
  1233. tla_primers = read_tsv('data/supptables/tla_primers.tsv', col_types=cols())
  1234. write_supp_table(tla_primers, 'PCR primers used for TLA transgene mapping analysis.')
  1235. depthtbl %>%
  1236. filter(depth > 100) %>%
  1237. summarize(minpos = min(pos), maxpos=max(pos)) -> bacrange
  1238. # upstream distance
  1239. upstream_distance = bacrange$minpos - landmarks$exon1_start[1]
  1240. # downstream distance
  1241. downstream_distance = bacrange$maxpos - landmarks$exon2_end[1]
  1242. bacrange_out = tibble(property=c('span upstream of TSS','span downstream of TES'),
  1243. distance_bases = c(upstream_distance, downstream_distance))
  1244. write_supp_table(bacrange_out, 'Span of human BAC in transgenic mice relative to PRNP transcript.')
  1245. ## Figure 4. Human TE screen ####
  1246. # layout_matrix = matrix(c(1,2,
  1247. # 3,3), nrow=2, byrow=T)
  1248. # layout(layout_matrix, widths=c(1.25, 1))
  1249. cellulo %>%
  1250. filter(purpose=='IC50' & cells=='U251-MG') %>%
  1251. filter(!is.na(descno)) %>%
  1252. group_by(source_well, biorep, descno, concnm) %>%
  1253. summarize(.groups='keep',
  1254. n_techreps = n(),
  1255. mean_resid = mean(resid)) %>%
  1256. ungroup() -> human_ic50
  1257. human_ic50 %>%
  1258. distinct(descno) -> human_ic50_descnos
  1259. human_te_screen = c('CMR-1313','CMR-1465','CMR-1697')
  1260. process_elisas(human_te_screen, control_group='saline') %>%
  1261. filter(dose_dio %in% c(0,10)) %>%
  1262. arrange(dose_dio, tx) %>%
  1263. inner_join(meta, by='tx') %>%
  1264. distinct(sequence_number) %>%
  1265. filter(!is.na(sequence_number)) -> in_vivo_descnos
  1266. screen_meta = tibble(status=c('advanced','not advanced'),
  1267. color = c('#DD4400','#7979A9'))
  1268. cellulo %>%
  1269. filter(purpose=='screen' & cells=='U251-MG') %>%
  1270. filter(source_well != 'no') %>%
  1271. mutate(x = rank_uniq(descno)) %>%
  1272. mutate(x = case_when(source_well=='untreated' ~ 0,
  1273. TRUE ~ x)) %>%
  1274. mutate(y = max(x) - x + 1) %>%
  1275. group_by(x, y, source_well, biorep, descno, concnm) %>%
  1276. summarize(.groups='keep',
  1277. n_techreps = n(),
  1278. mean_resid = mean(resid)) %>%
  1279. ungroup() %>%
  1280. mutate(status = case_when(descno %in% c(human_ic50_descnos$descno, in_vivo_descnos$sequence_number) ~ 'advanced',
  1281. TRUE ~ 'not advanced')) %>%
  1282. inner_join(screen_meta, by='status') -> bioreps
  1283. bioreps %>%
  1284. group_by(x, y, descno, concnm, status, color) %>%
  1285. summarize(.groups='keep',
  1286. n_bioreps = n(),
  1287. mean = mean(mean_resid),
  1288. l95 = lower(mean_resid),
  1289. u95 = upper(mean_resid)) %>%
  1290. ungroup() %>%
  1291. mutate(disp = case_when(is.na(descno) ~ 'UNT',
  1292. TRUE ~ as.character(descno))) -> cellulo_smry
  1293. cellulo_smry %>%
  1294. rename(sequence=disp) %>%
  1295. select(sequence, concnm, status, n_bioreps, mean, l95, u95) -> cellulo_smry_out
  1296. write_supp_table(cellulo_smry_out, 'Human siRNA sequences screened in U251-MG cells with qPCR readout.')
  1297. cellulo_smry %>%
  1298. filter(concnm==2000) %>%
  1299. filter(mean < 0.1) %>%
  1300. nrow() -> n_10pctresid_2000nm
  1301. cellulo_smry %>%
  1302. filter(concnm==500) %>%
  1303. filter(mean < 0.1) %>%
  1304. nrow() -> n_10pctresid_500nm
  1305. #
  1306. #
  1307. # for (this_conc in c(500, 2000)) {
  1308. # bioreps %>% filter(concnm==this_conc) -> bioreps_this
  1309. # cellulo_smry %>% filter(concnm==this_conc) -> cellulo_this
  1310. # if(this_conc==500) {
  1311. # par(mar=c(3,3,3,0.5))
  1312. # } else {
  1313. # par(mar=c(3,0,3,0.5))
  1314. # }
  1315. #
  1316. # ylims = range(cellulo_this$y) + c(-0.5, 0.5)
  1317. # xlims = c(-0.05, 1.25)
  1318. # xats = 0:13/10
  1319. # xbigs = 0:2/2
  1320. # plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i')
  1321. # axis(side=1, at=xats, tck=-0.02, labels=NA)
  1322. # axis(side=1, at=xbigs, tck=-0.05, labels=NA)
  1323. # axis(side=1, at=xbigs, lwd=0, line=-0.5, labels=percent(xbigs))
  1324. # axis(side=2, at=ylims, labels=NA, lwd.ticks=0)
  1325. # abline(v=1, lty=3)
  1326. # if(this_conc==500) {
  1327. # mtext(side=2, at=cellulo_this$y, text=cellulo_this$disp, col=cellulo_this$color, las=2, cex=0.5)
  1328. # }
  1329. # barwidth=0.7
  1330. # rect(xleft=rep(0,nrow(cellulo_this)), xright=cellulo_this$mean, ybottom=cellulo_this$y-barwidth/2, ytop=cellulo_this$y + barwidth/2, border=NA, col=alpha(cellulo_this$color, ci_alpha))
  1331. # arrows(x0=cellulo_this$l95, x1=cellulo_this$u95, y0=cellulo_this$y, angle=90, code=3, length=0.02, col=cellulo_this$color)
  1332. # points(x=bioreps_this$mean_resid, y=bioreps_this$y, col=bioreps_this$color, bg='#FFFFFF', pch=21, cex=0.5)
  1333. #
  1334. # }
  1335. # idx = 2439
  1336. # # full target:
  1337. # rcompu(substr(huseq, idx, idx+20-1))
  1338. #
  1339. # # actual sequence:
  1340. # paste0('U',dna_to_rna(rcompu(substr(huseq, idx+2, idx+20-1))),'UU')
  1341. # idx=1803
  1342. # paste0('U',dna_to_rna(rcomp(substr(huseq, idx+2, idx+20-1))),'UU')
  1343. #
  1344. #
  1345. # # for off-target search:
  1346. # "GAATACTCACAAAGTGCA"
  1347. # rcomp("AATACTCACAAAGTGCA")
  1348. # "TGCACTTTGTGAGTATT"
  1349. ### actual Figure 4 beginning ####
  1350. if ('figure-4'=='figure-4') {
  1351. tell_user('done.\nCreating Figure 4...')
  1352. resx=600
  1353. png('display_items/figure-4.png',width=6.5*resx,height=4.5*resx,res=resx)
  1354. layout_matrix = matrix(c(1, 1, 1, 1, 1, 4, 5, 6, 7, 8,
  1355. 1, 1, 1, 1, 1, 9, 10, 11, 12, 13,
  1356. 2, 2, 2, 2, 2, 14, 14, 14, 14, 14,
  1357. 3, 3, 3, 3, 3, 14, 14, 14, 14, 14,
  1358. 15, 15, 15, 15, 15, 15, 16, 16, 16,16), nrow=5, byrow=T)
  1359. layout(layout_matrix, heights = c(.5, .5, 1, .5, 1))
  1360. # layout.show(17)
  1361. panel = 1
  1362. ### U251-MG screening ####
  1363. for (this_conc in c(2000, 500)) {
  1364. bioreps %>% filter(concnm==this_conc) -> bioreps_this
  1365. cellulo_smry %>% filter(concnm==this_conc) -> cellulo_this
  1366. if(this_conc==500) {
  1367. par(mar=c(0.5,3,0.5,3))
  1368. } else {
  1369. par(mar=c(0.1,3,1,3))
  1370. }
  1371. xlims = range(cellulo_this$x) + c(-0.5, 0.5)
  1372. ylims = c(0, 1.25)
  1373. yats = 0:13/10
  1374. ybigs = 0:2/2
  1375. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i')
  1376. axis(side=1, at=xlims, labels=NA, lwd.ticks=0)
  1377. axis(side=2, at=yats, tck=-0.02, labels=NA)
  1378. axis(side=2, at=ybigs, tck=-0.05, labels=NA)
  1379. axis(side=2, at=ybigs, lwd=0, line=-0.75, labels=percent(ybigs), las=2,cex=0.8)
  1380. axis(side=2, at=xlims, labels=NA, lwd.ticks=0)
  1381. mtext(side=3, line=-1.25, adj=1, text=paste0(this_conc/1000,' µM'), cex=0.8)
  1382. mtext(side=2, at=mean(ylims), text=expression(residual~italic(PRNP)), cex=0.7, line=2.1)
  1383. abline(h=1, lty=3)
  1384. if(this_conc==500) {
  1385. mtext(side=1, at=cellulo_this$x, text=cellulo_this$disp, col=cellulo_this$color, las=2, cex=0.2, line=0.1, font=2)
  1386. }
  1387. barwidth=0.7
  1388. rect(ybottom=rep(0,nrow(cellulo_this)), ytop=cellulo_this$mean, xleft=cellulo_this$x-barwidth/2, xright=cellulo_this$x + barwidth/2, border=NA, col=alpha(cellulo_this$color, ci_alpha))
  1389. arrows(y0=cellulo_this$l95, y1=cellulo_this$u95, x0=cellulo_this$x, angle=90, code=3, length=0.02, col=cellulo_this$color)
  1390. points(y=bioreps_this$mean_resid, x=bioreps_this$x, col=bioreps_this$color, bg='#FFFFFF', pch=21, cex=0.5)
  1391. if (this_conc==2000) { # only on the first iteration
  1392. mtext(LETTERS[panel], side=3, cex=1, adj = -0.1, line = -0.3); panel = panel + 1
  1393. }
  1394. }
  1395. ### CDS diagram ####
  1396. landmarks = tibble(gene = c('PRNP'),
  1397. tss = 362, #
  1398. cds_start = 429,
  1399. cds_end = 429+762,
  1400. tes = 2808,
  1401. y=0.5)
  1402. intron_lwd = 1
  1403. utr_lwd = 10
  1404. cds_lwd = 20
  1405. default_fill = '#000000'
  1406. utr_height = 0.3
  1407. cds_height = 1
  1408. par(mar=c(1.5,3,0.2,3))
  1409. ylims = c(0, 2.4)
  1410. xlims = c(0, nchar(huseq))
  1411. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i')
  1412. minimum_y = 1.3
  1413. maximum_y = 1.8
  1414. top_xlims = range(cellulo_this$x) + c(-0.5, 0.5)
  1415. new_xlims = c(0, nchar(huseq))
  1416. cellulo_this$xpos = min(new_xlims) + diff(new_xlims) * ((cellulo_this$x - min(top_xlims)) / diff(top_xlims))
  1417. segments(x0=cellulo_this$descno, x1=cellulo_this$xpos, y0=rep(minimum_y, nrow(cellulo_this)), y1=rep(maximum_y,nrow(cellulo_this)), col=cellulo_this$color, lwd=0.5)
  1418. segments(x0=cellulo_this$descno, y0=rep(minimum_y, nrow(cellulo_this)), y1=rep(minimum_y, nrow(cellulo_this))-0.9, col=cellulo_this$color, lwd=0.5)
  1419. segments(x0=cellulo_this$xpos[cellulo_this$disp!='UNT'], y0=rep(maximum_y, nrow(cellulo_this)-1), y1=rep(max(ylims), nrow(cellulo_this)-1), col=cellulo_this$color[cellulo_this$disp!='UNT'], lwd=0.5)
  1420. mtext(side=2, at=landmarks$y, text='PRNP',line = 2, adj=0, font=3, las=2)
  1421. mtext(side=1, at=c(landmarks$tss-50,
  1422. (landmarks$cds_start+ landmarks$cds_end) /2,
  1423. (landmarks$cds_end + landmarks$tes)/2),
  1424. text=c("5'UTR","CDS","3'UTR"),line = 0.25, font=1, cex=0.7)
  1425. rect(xleft=landmarks$tss, xright=landmarks$tes, ybottom=landmarks$y-utr_height/2, ytop=landmarks$y+utr_height/2, col=default_fill, border=NA)
  1426. rect(xleft=landmarks$cds_start, xright=landmarks$cds_end, ybottom=landmarks$y-cds_height/2, ytop=landmarks$y+cds_height/2, col=default_fill, border=NA)
  1427. ### IC50s ####
  1428. cellulo %>%
  1429. filter(purpose=='IC50' & cells=='U251-MG' & !is.na(descno)) %>%
  1430. distinct(descno, concnm) -> human_ic50
  1431. human_ic50 %>%
  1432. distinct(descno) -> ic50s
  1433. ylims = c(0, 1.25)
  1434. xlims = range(human_ic50$concnm) * c(1/3.16, 3.16)
  1435. xbigs = 10^(-3:3)
  1436. xbiglabs = -3:3
  1437. xats = rep(1:9, 7) * rep(10^(-3:3), each=9)
  1438. cellulo %>%
  1439. filter(!is.na(descno) & purpose=='IC50' & cells=='U251-MG') %>%
  1440. select(descno, concnm, biorep, resid) %>%
  1441. group_by(descno, concnm, biorep) %>% # group technical replicates & take mean
  1442. summarize(.groups='keep', resid=mean(resid)) %>%
  1443. ungroup() %>%
  1444. group_by(descno, concnm) %>%
  1445. summarize(.groups = 'keep',
  1446. n_bioreps = n(), # we already grouped techreps, so this n is bioreps
  1447. mean = mean(resid),
  1448. l95 = lower(resid),
  1449. u95 = upper(resid)) %>%
  1450. ungroup() -> ic50_smry_out
  1451. write_supp_table(ic50_smry_out, 'Human siRNA sequence IC50 determination in U251-MG cells by qPCR.')
  1452. for (i in 1:nrow(ic50s)) {
  1453. cellulo %>%
  1454. filter(descno %in% ic50s$descno[i] & !is.na(descno) & purpose=='IC50' & cells=='U251-MG') %>%
  1455. select(descno, concnm, biorep, resid) %>%
  1456. group_by(descno, concnm, biorep) %>% # group technical replicates & take mean
  1457. summarize(.groups='keep', resid=mean(resid)) %>%
  1458. ungroup() -> ic50_points
  1459. ic50_points %>%
  1460. group_by(descno, concnm) %>%
  1461. summarize(.groups = 'keep',
  1462. n_bioreps = n(), # we already grouped techreps, so this n is bioreps
  1463. mean = mean(resid),
  1464. l95 = lower(resid),
  1465. u95 = upper(resid)) %>%
  1466. ungroup() -> ic50_smry
  1467. if (i <= nrow(ic50s)/2) {
  1468. par(mar=c(0.25,0,2,0))
  1469. } else {
  1470. par(mar=c(2,0,0.25,0))
  1471. }
  1472. plot(NA, NA, xlim=xlims, ylim=ylims, xaxs='i', yaxs='i', ann=F, axes=F, log='x')
  1473. axis(side=1, at=xlims, lwd.ticks=0, labels=NA)
  1474. axis(side=1, at=xbigs, labels=NA, tck=-0.05)
  1475. axis(side=1, at=xats, labels=NA, tck=-0.02)
  1476. axis(side=2, at=ylims, labels=NA, lwd.ticks=0)
  1477. if (i==1) { # first panel only
  1478. mtext(LETTERS[panel], side=3, cex=1, adj = -0.2, line = 0.25); panel = panel + 1
  1479. }
  1480. if (i %% 5 == 1) { # first in each row
  1481. axis(side=2, at=0:4/2, labels=NA, tck=0.025)
  1482. axis(side=2, at=0:4/2, labels=percent(0:4/2), lwd=0, line=-.75, las=2, cex.axis=.75)
  1483. }
  1484. if (i > nrow(ic50s)/2) { # bottom row
  1485. axis(side=1, at=xbigs, labels=xbiglabs, lwd.ticks=0, lwd=0, line=-1.0, cex.axis=.7)
  1486. mtext(side=1, line=1, text='log10(nM)', cex=0.6)
  1487. }
  1488. if (i==6) { # bottom left
  1489. mtext(side=2, line=1.75, at=max(ylims), text=expression(residual~italic(PRNP)), cex=.8)
  1490. }
  1491. abline(h=c(0.5,1), lty=3, lwd=0.5)
  1492. points(x=ic50_points$concnm, y=ic50_points$resid, pch=20, cex=0.5)
  1493. m = drm(resid ~ concnm, fct=LL.4(), data=ic50_points)
  1494. plot(m, type='none', add=T)
  1495. mtext(side=1, line=-1.5, adj=0, text=paste0(' ',ic50_smry$descno[1]), cex=0.35)
  1496. mtext(side=1, line=-1, adj=0, text=paste0(' ',formatC(m$coefficients['e:(Intercept)'],format='f',digits=1),' nM'), cex=0.35)
  1497. #mtext(LETTERS[panel], side=3, cex=2, adj = -0.5, line = 0.5)
  1498. #panel = panel + 1
  1499. }
  1500. human_te_screen = c('CMR-1313','CMR-1465','CMR-1697')
  1501. process_elisas(human_te_screen, control_group='saline') %>%
  1502. filter(dose_dio %in% c(0,10)) %>%
  1503. arrange(dose_dio, tx) %>%
  1504. inner_join(meta, by='tx') -> proc
  1505. proc %>%
  1506. distinct(tx, display_tx, is_reference, is_ntc, sequence_number, color) %>%
  1507. mutate(is_exna = grepl('exNA',tx,ignore.case=T)) %>%
  1508. arrange(!is_reference, !is_ntc, sequence_number, is_exna) %>%
  1509. mutate(x = row_number()) -> xes
  1510. proc$x = xes$x[match(proc$tx, xes$tx)]
  1511. #
  1512. # proc_smry = dviz(proc, xlims=range(proc$x)+c(-0.5,0.5), ylims=c(0,1.55),
  1513. # xvar='x', yvar='rel', xcols='tx', log='', colorvar = 'color',
  1514. # xats=proc$x, xbigs=proc$x, xbiglabs=NA, xlwds=0, yats=0:6/4, ybigs=0:2/2, ybiglabs=percent(0:2/2),
  1515. # xlab = 'compound', ylab='PrP (% saline)', barwidth=0.3, mar=c(5,4,1,1), xlabline=4, ylabline=3)
  1516. # mtext(side=1, at=xes$x, text=xes$tx, las=2, cex=0.8)
  1517. # abline(h=1, lty=3)
  1518. ### in vivo screening ####
  1519. par(mar=c(4,2,3,1))
  1520. xlims = range(proc$x)+c(-0.5,0.5)
  1521. ylims = c(0,1.55)
  1522. yats=0:6/4
  1523. ybigs=0:3/2
  1524. ybiglabs=percent(ybigs)
  1525. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i')
  1526. axis(side=1, at=xlims, labels=NA, lwd.ticks=0)
  1527. axis(side=2, at=yats, tck = -0.02, labels=NA)
  1528. axis(side=2, at=ybigs, tck = -0.05, labels=NA)
  1529. axis(side=2, at=ybigs, lwd=0, labels=ybiglabs, las=2, line=-0.5)
  1530. mtext(side=2, line=2.75, text='residual PrP', cex=0.8)
  1531. proc %>%
  1532. group_by(x, tx, display_tx, color) %>%
  1533. summarize(.groups = 'keep',
  1534. n = n(),
  1535. mean = mean(rel),
  1536. l95 = lower(rel),
  1537. u95 = upper(rel),
  1538. max = max(rel)) %>%
  1539. ungroup() -> proc_smry
  1540. barwidth=0.6
  1541. rect(xleft=proc_smry$x-barwidth/2, xright=proc_smry$x+barwidth/2, ybottom=rep(0, nrow(proc_smry)), ytop=proc_smry$mean, col=alpha(proc_smry$color, ci_alpha), border=NA)
  1542. arrows(x0=proc_smry$x, y0=proc_smry$l95, y1=proc_smry$u95, col=proc_smry$color, lwd=1.5, code=3, angle=90, length=0.05)
  1543. abline(h=1, lty=3, lwd=0.5)
  1544. points(x=proc$x, y=proc$rel, col=proc$color, bg='#FFFFFF', pch=21)
  1545. par(xpd=T)
  1546. text(x=proc_smry$x, y=proc_smry$max+0.2, labels=percent(proc_smry$mean,digits=1), cex=0.7, srt=90)
  1547. par(xpd=F)
  1548. # plot the PBS and NTC as a diagonal
  1549. par(xpd=T)
  1550. text(x=xes$x[1:4], y=-0.05, labels=xes$display_tx[1:4], srt=45, adj=1)
  1551. par(xpd=F)
  1552. # plot the rest as tranches
  1553. proc_smry %>%
  1554. mutate(scaffold = case_when(grepl('(PBS|NTC)',display_tx) ~ '', TRUE ~ gsub('.+-','',display_tx)),
  1555. sequence = case_when(grepl('(PBS|NTC)',display_tx) ~ '', TRUE ~ gsub('-.*','',display_tx))) -> xleg
  1556. mtext(side=1, line=0.15, at=xleg$x, text=xleg$scaffold, cex=0.7)
  1557. xleg %>%
  1558. group_by(sequence) %>%
  1559. summarize(.groups='keep', xmid=mean(x), xmin=min(x), xmax=max(x)) %>%
  1560. ungroup() -> xlegouter
  1561. mtext(side=1, line=1.25, at=xlegouter$xmid, text=xlegouter$sequence, cex=0.6)
  1562. overhang = 0.4
  1563. for (i in 2:nrow(xlegouter)) {
  1564. axis(side=1, line=1.25, tck=0.02, at=c(xlegouter$xmin[i]-overhang, xlegouter$xmax[i]+overhang), labels=NA)
  1565. }
  1566. mtext(LETTERS[panel], side=3, cex=1, adj = -0.1, line = 0.5); panel = panel + 1
  1567. proc %>%
  1568. select(study_id, plate, animal, genotype, sex, display_tx, dose_dio, dosing_regimen, days_harvest, ngml_av, saline_mean, rel) -> proc_out
  1569. write_supp_table(proc_out, 'Human siRNA sequences tested in vivo - individual animal data.')
  1570. proc_smry %>%
  1571. select(display_tx, n, mean, l95, u95) -> proc_smry_out
  1572. write_supp_table(proc_smry_out, 'Human siRNA sequences tested in vivo - summarized.')
  1573. ### Regional qPCR on top human candidates ####
  1574. regional_qpcr_studies = c('CMR-1313', 'CMR-1697') # CMR-1313 is 2440 only (both hiPS and exNA). CMR-1697 includes 2439, 2520, and 2768
  1575. qpcr %>%
  1576. filter(study_id %in% regional_qpcr_studies) %>%
  1577. filter(target=='PRNP') %>%
  1578. group_by(study_id, qpcr_id, region, biorep, sample_group) %>%
  1579. summarize(.groups='keep',
  1580. n_techreps = n(),
  1581. mean_twoddct = mean(twoddct)) %>%
  1582. ungroup() %>%
  1583. group_by(study_id, qpcr_id, region) %>%
  1584. mutate(residual = mean_twoddct / mean(mean_twoddct[sample_group %in% c('saline','PBS')])) %>%
  1585. ungroup() -> regional_qpcr
  1586. tx_compared_by_qpcr = tibble(tx_on_qpcr_plate=c('2768','2520','2439','2440-exNA','saline','PBS'),
  1587. tx = c('2768-s4','2520-s4','2439-s4','2440-s4','PBS','PBS'),
  1588. x_offset = c(-0.15, 0.0, 0.3, 0.15, -0.3, -0.3))
  1589. tx_compared_by_qpcr$color = meta$color[match(tx_compared_by_qpcr$tx, meta$display_tx)]
  1590. region_meta = tibble(region=c("HP", "PFC", "VC", "Str", "Thal", "CB"),
  1591. x = 1:6)
  1592. regional_qpcr %>%
  1593. inner_join(tx_compared_by_qpcr, by=c('sample_group'='tx_on_qpcr_plate')) %>%
  1594. select(tx, region, residual, x_offset, color) %>%
  1595. inner_join(region_meta, by='region') -> regional_indivs
  1596. regional_indivs %>%
  1597. group_by(tx, region, x, x_offset, color) %>%
  1598. summarize(.groups='keep',
  1599. n=n(),
  1600. mean = mean(residual),
  1601. l95 = lower(residual),
  1602. u95 = upper(residual)) %>%
  1603. ungroup() -> regional_smry
  1604. regional_smry %>%
  1605. select(tx, region, n, mean, l95, u95) -> regional_smry_out
  1606. write_supp_table(regional_smry_out, 'Brain regional qPCR analysis of human siRNA sequences in vivo.')
  1607. par(mar=c(2,4,2,5))
  1608. xlims = range(region_meta$x) + c(-0.5, 0.5)
  1609. ylims = range(0, 1.5)
  1610. yats=0:6/4
  1611. ybigs=0:3/2
  1612. ybiglabs=percent(ybigs)
  1613. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i')
  1614. axis(side=1, at=xlims, labels=NA, lwd.ticks=0)
  1615. #par(xpd=T)
  1616. #text(x=region_meta$x, y=rep(-0.05, nrow(region_meta)), labels=region_meta$region, srt=45, adj=1)
  1617. #par(xpd=F)
  1618. mtext(side=1, line=0.25, at=region_meta$x, text=region_meta$region, cex=0.8)
  1619. axis(side=2, at=yats, tck = -0.02, labels=NA)
  1620. axis(side=2, at=ybigs, tck = -0.05, labels=NA)
  1621. axis(side=2, at=ybigs, lwd=0, labels=ybiglabs, las=2, line=-0.5)
  1622. mtext(side=2, line=2.75, text=expression(residual~italic(PRNP)), cex=0.8)
  1623. abline(h=1, lty=3)
  1624. barwidth=0.15
  1625. rect(xleft=regional_smry$x + regional_smry$x_offset - barwidth/2, xright=regional_smry$x + regional_smry$x_offset + barwidth/2, ybottom=rep(0, nrow(regional_smry)), ytop=regional_smry$mean, col=alpha(regional_smry$color, ci_alpha), border=NA)
  1626. arrows(x0=regional_smry$x + regional_smry$x_offset, y0=regional_smry$l95, y1=regional_smry$u95, code=3, angle=90, length=0.025, col=regional_smry$color)
  1627. points(x=regional_indivs$x + regional_indivs$x_offset, y=pmin(regional_indivs$residual, max(ylims)), pch=21, col=regional_indivs$color, bg='#FFFFFF', cex=0.5)
  1628. tx_compared_by_qpcr %>%
  1629. arrange(x_offset) %>%
  1630. distinct(tx,color) -> leg
  1631. par(xpd=T)
  1632. legend(x=max(xlims),y=max(ylims)*1.1,leg$tx,col=leg$color,pch=15,bty='n',cex=0.7)
  1633. par(xpd=F)
  1634. mtext(LETTERS[panel], side=3, cex=1, adj = -0.0, line = 0.5); panel = panel + 1
  1635. proc_smry %>%
  1636. mutate(descno = substr(display_tx,1,4)) %>%
  1637. mutate(scaffold = substr(display_tx,6,7)) %>%
  1638. filter(descno %in% c('1035','2226','2439','2440','2520','2768')) %>%
  1639. select(descno, scaffold, mean, color) %>%
  1640. mutate(orig_scaffold = scaffold) %>%
  1641. mutate(scaffold = case_when(scaffold %in% c('s1','s2') ~ 's1_2',
  1642. scaffold == 's4' ~ 's4')) %>%
  1643. pivot_wider(names_from = scaffold, values_from=c(mean,color,orig_scaffold)) %>%
  1644. select(-color_s1_2, orig_scaffold_s4) %>%
  1645. rename(s1_2 = mean_s1_2, s4 = mean_s4) %>%
  1646. mutate(diff = s4 - s1_2) %>%
  1647. arrange(-s1_2) %>%
  1648. mutate(x = row_number()) -> scafdiff
  1649. scafdiff %>%
  1650. select(descno, s1_2, s4, diff) -> scafdiff_out
  1651. write_supp_table(scafdiff_out, 'Difference in target engagement between scaffolds for human siRNA sequences in vivo.')
  1652. par(mar=c(2,4,2,1))
  1653. xlims = range(scafdiff$x) + c(-0.5, 0.5)
  1654. ylims = c(0, 1)
  1655. yats=0:6/4
  1656. ybigs=0:3/2
  1657. ybiglabs=percent(ybigs)
  1658. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i')
  1659. axis(side=1, at=xlims, labels=NA, lwd.ticks=0)
  1660. mtext(side=1, line=0.25, at=scafdiff$x, text=scafdiff$descno, cex=0.6)
  1661. axis(side=2, at=yats, tck = -0.02, labels=NA)
  1662. axis(side=2, at=ybigs, tck = -0.05, labels=NA)
  1663. axis(side=2, at=ybigs, lwd=0, labels=ybiglabs, las=2, line=-0.5)
  1664. mtext(side=2, line=2.5, text='mean residual PrP', cex=0.8)
  1665. boxwidth = 0.5
  1666. rect(xleft=scafdiff$x - boxwidth/2,
  1667. xright=scafdiff$x + boxwidth/2,
  1668. ybottom = scafdiff$s4,
  1669. ytop = scafdiff$s1_2,
  1670. col='#A9A9A9', border=NA)
  1671. segments(x0=scafdiff$x - boxwidth/2,
  1672. x1=scafdiff$x + boxwidth/2,
  1673. y0 = scafdiff$s4,lwd=2)
  1674. text(x=scafdiff$x, y = scafdiff$s4, pos=1, labels='s4', cex=0.8)
  1675. segments(x0=scafdiff$x - boxwidth/2,
  1676. x1=scafdiff$x + boxwidth/2,
  1677. y0 = scafdiff$s1_2,lwd=2)
  1678. text(x=scafdiff$x, y = scafdiff$s1_2, pos=3, labels=scafdiff$orig_scaffold_s1_2, cex=0.8)
  1679. mtext(LETTERS[panel], side=3, cex=1, adj = -0.0, line = 0.5); panel = panel + 1
  1680. silence_is_golden = dev.off()
  1681. } #### end Figure 4 ####
  1682. ## Figure 5 beginning ####
  1683. if ('figure-5'=='figure-5') {
  1684. tell_user('done.\nCreating Figure 5...')
  1685. resx=300
  1686. png('display_items/figure-5.png',width=6.5*resx,height=4.0*resx,res=resx)
  1687. layout_matrix = matrix(c(1,1,1,1,1,12,
  1688. 2,2,3,4,5,6,
  1689. 2,2,3,7,8,9,
  1690. 10,10,10,11,11,11), nrow=4, byrow=T)
  1691. layout(layout_matrix, heights = c(1.2,1,1,1.5), widths=c(1,1,.25,1,1,1))
  1692. #layout.show(9)
  1693. panel = 1
  1694. ### diagram across top ####
  1695. par(mar=c(0.5,0,1.5,0))
  1696. raster_panel = image_convert(image_read('received/h2h_legend.png'),'png')
  1697. plot(as.raster(raster_panel))
  1698. mtext(side=3, adj=0.05, text=LETTERS[panel], line=0.0); panel = panel + 1
  1699. ### H2H - ELISA ####
  1700. scaffold_comparison = c('CMR-1871')
  1701. proc = process_elisas(scaffold_comparison, control_group = 'saline') %>%
  1702. inner_join(meta, by='tx') %>%
  1703. mutate(color = case_when(dose_dio==0 ~ color,
  1704. dose_dio==0.2 ~ color,
  1705. dose_dio==1 ~ color,
  1706. dose_dio==5 ~ color))
  1707. proc %>%
  1708. distinct(tx, display_tx, is_reference, is_ntc, sequence_number, color, dose_dio) %>%
  1709. mutate(is_exna = grepl('exNA',tx,ignore.case=T)) %>%
  1710. mutate(is_hips = grepl('hiPS',tx,ignore.case=T)) %>%
  1711. arrange(!is_reference, !is_ntc, !is_hips, desc(tx), is_exna, dose_dio) %>%
  1712. mutate(x = row_number()) %>%
  1713. mutate(y = max(x) - x + 1) %>%
  1714. mutate(group_id = paste0(display_tx,' ',dose_dio,' nmol')) %>%
  1715. mutate(short_disp = gsub('2439-','',gsub(' tail','',display_tx))) -> xes
  1716. proc %>%
  1717. inner_join(xes %>% select(tx, short_disp, dose_dio, x, y), by=c('tx','dose_dio')) %>%
  1718. mutate(pch=21) -> proc
  1719. proc %>%
  1720. group_by(x, y, tx, display_tx, dose_dio, color) %>%
  1721. summarize(.groups = 'keep',
  1722. n = n(),
  1723. mean = mean(rel),
  1724. l95 = lower(rel),
  1725. u95 = upper(rel),
  1726. max = max(rel)) %>%
  1727. ungroup() -> proc_smry
  1728. par(mar=c(2,5,2,1))
  1729. xlims = c(0,1.25)
  1730. ylims = range(proc$y) + c(-0.5, 0.5)
  1731. xats = 0:6/4
  1732. xbigs = 0:3/2
  1733. xbiglabs = percent(0:3/2)
  1734. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i')
  1735. abline(v=1, lty=3)
  1736. axis(side=1, at=xbigs, tck=-0.05, labels=NA)
  1737. axis(side=1, at=xats, tck=-0.02, labels=NA)
  1738. axis(side=1, at=xbigs, lwd=0, line=-0.75, labels=xbiglabs, cex=0.8)
  1739. mtext(side=3, line=0.25, text='residual PrP', cex=0.8)
  1740. axis(side=2, at=ylims, lwd.ticks=0, labels=NA)
  1741. mtext(side=2, at=proc_smry$y, line=0.25, text=nmol_to_ug(proc_smry$dose_dio), las=2, cex=0.6)
  1742. mtext(side=2, at=max(ylims) + 0.5, las=2, line=0.25, text='dose\n(µg)', cex=0.6, padj=0)
  1743. xes %>%
  1744. group_by(display_tx, short_disp) %>%
  1745. summarize(.groups='keep',
  1746. miny = min(y),
  1747. midy = mean(y),
  1748. maxy = max(y)) %>%
  1749. ungroup() -> tranches
  1750. tranche_line = 1.75
  1751. overhang_left = 0.4
  1752. overhang_right = 0.4
  1753. for (i in 1:nrow(tranches)) {
  1754. axis(side=2, line=tranche_line, at=c(tranches$miny[i], tranches$maxy[i]) + c(-1,1)*c(overhang_left,overhang_right), tck=0.03, labels=NA)
  1755. mtext(side=2, line=tranche_line+0.2, at=tranches$midy[i], adj=1, las=2, text=tranches$short_disp[i], cex=0.4)
  1756. }
  1757. barwidth=0.8
  1758. rect(xleft=rep(0, nrow(proc_smry)), xright=proc_smry$mean, ybottom=proc_smry$y-barwidth/2, , ytop=proc_smry$y+barwidth/2, col=alpha(proc_smry$color, ci_alpha), border=NA)
  1759. arrows(x0=proc_smry$l95, x1=proc_smry$u95, y0=proc_smry$y, col=proc_smry$color, lwd=1.5, code=3, angle=90, length=0.05)
  1760. points(x=proc$rel, y=proc$y, col=proc$color, bg='#FFFFFF', pch=21)
  1761. abline(v=min(proc_smry$mean), col=proc_smry %>% arrange(mean) %>% slice(1) %>% pull(color), lty=3, lwd=0.5)
  1762. mtext(side=3, adj=0.0, text=LETTERS[panel], line=0.5); panel = panel + 1
  1763. proc %>%
  1764. select(study_id, plate, animal, genotype, sex, display_tx, dose_dio, dosing_regimen, days_harvest, ngml_av, saline_mean, rel) -> proc_out
  1765. write_supp_table(proc_out, 'Comparison of 2439 with different scaffolds and matched vs. fixed tail - individual animal data.')
  1766. proc_smry %>%
  1767. select(display_tx, n, mean, l95, u95) -> proc_smry_out
  1768. write_supp_table(proc_smry_out, 'Comparison of 2439 with different scaffolds and matched vs. fixed tail - summarized.')
  1769. ### H2H - qPCR regional ####
  1770. # the qPCR spreadsheets use alterantive names for each scaffold. map
  1771. # these to the xes table from the H2H ELISA above.
  1772. name_map = read_tsv('data/analytic/qpcr_name_mapping.tsv',col_types=cols()) %>%
  1773. inner_join(xes, by='group_id')
  1774. qpcr %>%
  1775. filter(study_id %in% scaffold_comparison) %>%
  1776. filter(target=='PRNP') %>%
  1777. group_by(study_id, qpcr_id, region, biorep, sample_group) %>%
  1778. summarize(.groups='keep',
  1779. n_techreps = n(),
  1780. mean_twoddct = mean(twoddct)) %>%
  1781. ungroup() %>%
  1782. group_by(study_id, qpcr_id, region) %>%
  1783. mutate(residual = mean_twoddct / mean(mean_twoddct[sample_group %in% c('saline','PBS')])) %>%
  1784. ungroup() %>%
  1785. inner_join(name_map, by=c('sample_group'='qpcr_name')) %>%
  1786. filter(tx %in% c('fixed tail-exNA','matched tail-hiPS','fixed tail-hiPS')) -> h2h_qpcr
  1787. h2h_layout = read_tsv('data/miscellaneous/h2h_plate_layout.tsv', col_types=cols()) %>%
  1788. mutate(well = paste0(row, col)) %>%
  1789. mutate(id = as.character(id))
  1790. scaffold_levels_in_order = c('s2 matched', 's2 fixed', 's4 fixed')
  1791. regions_in_order = region_meta$region
  1792. h2h_qpcr %>%
  1793. mutate(well = gsub('-.*','',gsub('CMR-1871-JES0034-','',biorep))) %>%
  1794. inner_join(h2h_layout, by=c('well')) %>%
  1795. rename(scaffold = short_disp, animal=id) %>%
  1796. select(scaffold, region, dose_dio, animal, residual, color) %>%
  1797. mutate(scaffold = factor(scaffold, levels=scaffold_levels_in_order)) %>%
  1798. mutate(region = factor(region, levels=regions_in_order)) -> h2h_model_data
  1799. h2h_model_data %>%
  1800. select(animal, scaffold, region, dose_dio, residual) %>%
  1801. arrange(scaffold, animal, region, dose_dio) -> h2h_model_out
  1802. write_supp_table(h2h_model_out, 'Regional qPCR data for scaffold/tail comparison.')
  1803. # overall model
  1804. lm_model = lm(residual ~ scaffold + log(dose_dio) + region,
  1805. data=h2h_model_data)
  1806. summary(lm_model)$coefficients %>%
  1807. as_tibble(rownames='variable') %>%
  1808. rename(estimate = Estimate, se = `Std. Error`, t=`t value`, p=`Pr(>|t|)`) -> h2h_coefs
  1809. write_supp_table(h2h_coefs, 'Linear model coefficients for regional qPCR data in scaffold/tail comparison.')
  1810. h2h_model_data %>%
  1811. distinct(scaffold, color) -> h2h_leg
  1812. alpha_value = 0.05
  1813. ci_size = qnorm(1-alpha_value/2)
  1814. h2h_coefs %>%
  1815. filter(grepl('Intercept|scaffold',variable)) %>%
  1816. mutate(estimate = case_when(variable=='(Intercept)' ~ 0,
  1817. TRUE ~ estimate),
  1818. variable = case_when(variable=='(Intercept)' ~ 's2 matched',
  1819. TRUE ~ gsub('scaffold','',variable))) %>%
  1820. mutate(l95 = estimate - ci_size * se, u95 = estimate + ci_size * se) %>%
  1821. mutate(x = row_number()) %>%
  1822. inner_join(h2h_leg, by =c('variable'='scaffold')) -> scaffold_fits
  1823. h2h_coefs %>%
  1824. filter(grepl('Intercept|region',variable)) %>%
  1825. mutate(estimate = case_when(variable=='(Intercept)' ~ 0,
  1826. TRUE ~ estimate),
  1827. variable = case_when(variable=='(Intercept)' ~ regions_in_order[1],
  1828. TRUE ~ gsub('region','',variable))) %>%
  1829. mutate(l95 = estimate - ci_size * se, u95 = estimate + ci_size * se) %>%
  1830. mutate(x = row_number()) -> region_fits
  1831. # nested anova version - Error(animal means treat animal as random effect)
  1832. # anova_model = aov(residual ~ scaffold + dose_dio + region + Error(animal), data=h2h_model_data)
  1833. # summary(anova_model)
  1834. # coefficients(anova_model)
  1835. ### dose-response curves ####
  1836. xlims = c(4,300)
  1837. xats = rep(1:9, 5) * rep(10^(-1:3),each=9)
  1838. xbigs = 10^(-1:3)
  1839. xlabs = nmol_to_ug(c(0.2, 1, 5))
  1840. xlablabs = xlabs
  1841. # xats = xats[xats >= min(xbigs) & xats <= max(xbigs)]
  1842. ylims = c(0, 1.5)
  1843. yats = 0:6/4
  1844. ybigs = 0:2/2
  1845. ybiglabs = percent(0:2/2)
  1846. # blanks for y axis flowover
  1847. par(mar=c(0,0,3,0))
  1848. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i', log='x')
  1849. ##par(mar=c(3,0,0,0))
  1850. ##plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i', log='x')
  1851. mtext(side=3, adj=0.0, text=LETTERS[panel], line=1.0); panel = panel + 1
  1852. if(exists('ed50_table')) {
  1853. rm(ed50_table)
  1854. }
  1855. ed50_table = tibble(region=character(0), scaffold=character(0), ed50=numeric(0))
  1856. for (i in 1:nrow(region_meta)) {
  1857. if (i <= 3) {
  1858. par(mar=c(0.125,0,2,0))
  1859. } else {
  1860. par(mar=c(2,0,0.125,0))
  1861. }
  1862. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i', log='x')
  1863. axis(side=1, at=xats, tck=0.02, labels=NA)
  1864. axis(side=1, at=xbigs, tck=0.05, labels=NA)
  1865. axis(side=2, at=yats, tck=-0.02, labels=NA)
  1866. axis(side=2, at=ybigs, tck=-0.05, labels=NA)
  1867. if (i %in% c(1,4)) {
  1868. axis(side=2, at=ybigs, labels=ybiglabs, line=-0.5, las=2, lwd=0)
  1869. }
  1870. abline(h=1, lty=3)
  1871. if (i <= 3) {
  1872. } else {
  1873. axis(side=1, at=xlabs, lwd=0, line=-0.5, labels=xlablabs)
  1874. }
  1875. if (i==4) {
  1876. mtext(side=2, at=max(ylims), text=expression(residual~italic(PRNP)), line=2.5, cex=0.8)
  1877. }
  1878. h2h_qpcr %>%
  1879. filter(region==region_meta$region[i]) -> subs
  1880. points(nmol_to_ug(subs$dose_dio), pmin(subs$residual, max(ylims)), pch=21, col=subs$color, bg='#FFFFFF')
  1881. for (scaf in unique(subs$tx)) {
  1882. subs %>% filter(tx==scaf) %>% mutate(ug = nmol_to_ug(dose_dio)) -> this_subs
  1883. m = drm(residual ~ ug, data=this_subs, fct=LL.4(fixed=c(b=NA, c=0, d=1, e=NA)))
  1884. x = seq(7,174,1)
  1885. y = suppressWarnings(predict(m, newdata=data.frame(dose=x)))
  1886. points(x, y, type='l', col=this_subs$color[1])
  1887. ed50_obj = ED(m, 50, display=F)
  1888. ed50 = as.numeric(ed50_obj[1,'Estimate'])
  1889. this_row = tibble(region=region_meta$region[i], scaffold=this_subs$display_tx[1], ed50=ed50)
  1890. # fix instances where the ed50 is a poor fit because even the top dose is >50% residual
  1891. if (mean(this_subs$residual[this_subs$dose_dio==5]) > 0.5) {
  1892. #this_row$ed50 = NA
  1893. }
  1894. ed50_table = rbind(ed50_table, this_row)
  1895. }
  1896. mtext(side=3, line=-0.75, text=region_meta$region[i], cex=0.8)
  1897. }
  1898. write_supp_table(ed50_table, 'ED50 values by brain region and scaffold for 2439 based on qPCR.')
  1899. ### model fits ####
  1900. par(mar=c(2,4,2,1))
  1901. xlims = range(scaffold_fits$x) + c(-0.5, 0.5)
  1902. ylims = c(-.35, .10)
  1903. ybigs = -8:8/20
  1904. ybiglabs = percent(ybigs, signed=T)
  1905. yats = seq(min(ylims),max(ylims),by=.01)
  1906. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i')
  1907. axis(side=1, at=xlims, labels=NA, lwd.ticks=0)
  1908. mtext(side=1, line=0.25, at=scaffold_fits$x, text=scaffold_fits$variable, cex=0.8)
  1909. axis(side=2, at=yats, tck = -0.02, labels=NA)
  1910. axis(side=2, at=ybigs, tck = -0.05, labels=NA)
  1911. axis(side=2, at=ybigs, lwd=0, labels=ybiglabs, las=2, line=-0.5)
  1912. abline(h=0, lty=3)
  1913. mtext(side=2, line=2.75, text='relative effect', cex=0.8)
  1914. barwidth = 0.8
  1915. segments(x0=scaffold_fits$x[1]-barwidth/2, x1=scaffold_fits$x[1]+barwidth/2, y0=0, col='#000000')
  1916. rect(xleft=scaffold_fits$x-barwidth/2, xright=scaffold_fits$x+barwidth/2,
  1917. ybottom=scaffold_fits$estimate, ytop=rep(0,nrow(scaffold_fits)),
  1918. col=alpha(scaffold_fits$color,ci_alpha), border=NA)
  1919. arrows(x0=scaffold_fits$x, y0=scaffold_fits$l95, y1=scaffold_fits$u95, code=3, angle=90, length=0.05)
  1920. mtext(side=3, text='effect of scaffold/tail', cex=0.8)
  1921. mtext(side=3, adj=0.0, text=LETTERS[panel], line=0.5); panel = panel + 1
  1922. xlims = range(region_fits$x) + c(-0.5, 0.5)
  1923. ylims = c(-.15, .25)
  1924. ybigs = -6:6/20
  1925. ybiglabs = percent(ybigs, signed=T)
  1926. yats = seq(min(ylims),max(ylims),by=.01)
  1927. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i')
  1928. axis(side=1, at=xlims, labels=NA, lwd.ticks=0)
  1929. mtext(side=1, line=0.25, at=region_fits$x, text=region_fits$variable, cex=0.8)
  1930. axis(side=2, at=yats, tck = -0.02, labels=NA)
  1931. axis(side=2, at=ybigs, tck = -0.05, labels=NA)
  1932. axis(side=2, at=ybigs, lwd=0, labels=ybiglabs, las=2, line=-0.5)
  1933. abline(h=0, lty=3)
  1934. mtext(side=2, line=2.75, text='relative effect', cex=0.8)
  1935. barwidth = 0.8
  1936. segments(x0=region_fits$x[1]-barwidth/2, x1=region_fits$x[1]+barwidth/2, y0=0, col='#000000')
  1937. rect(xleft=region_fits$x-barwidth/2, xright=region_fits$x+barwidth/2,
  1938. ybottom=region_fits$estimate, ytop=rep(0,nrow(region_fits)),
  1939. col=alpha('#A9A9A9',ci_alpha), border=NA)
  1940. arrows(x0=region_fits$x, y0=region_fits$l95, y1=region_fits$u95, code=3, angle=90, length=0.05)
  1941. mtext(side=3, text='effect of region', cex=0.8)
  1942. mtext(side=3, adj=0.0, text=LETTERS[panel], line=0.5); panel = panel + 1
  1943. ### rest of legend at top ####
  1944. par(mar=c(1,0,2,0))
  1945. raster_panel = image_convert(image_read('received/oligo-legend.png'),'png')
  1946. plot(as.raster(raster_panel))
  1947. silence_is_golden = dev.off()
  1948. } ### end of figure 5 ####
  1949. ### move to supp - Gfap, Iba1 ####
  1950. qpcr %>%
  1951. filter(study_id %in% scaffold_comparison) %>%
  1952. filter(target %in% c('GFAP','IBA1')) %>%
  1953. group_by(study_id, qpcr_id, target, region, biorep, sample_group) %>%
  1954. summarize(.groups='keep',
  1955. n_techreps = n(),
  1956. mean_twoddct = mean(twoddct)) %>%
  1957. ungroup() %>%
  1958. group_by(study_id, qpcr_id, region, target) %>%
  1959. mutate(residual = mean_twoddct / mean(mean_twoddct[sample_group %in% c('saline','PBS')])) %>%
  1960. ungroup() -> inflam_qpcr
  1961. target_meta = tibble(target=c('GFAP','IBA1'),
  1962. target_disp = c('Gfap','Iba1'),
  1963. panel=c(1,2))
  1964. for (i in 1:nrow(target_meta)) {
  1965. this_target = target_meta$target[i]
  1966. inflam_qpcr %>%
  1967. inner_join(name_map, by=c('sample_group'='qpcr_name')) %>%
  1968. inner_join(target_meta, by='target') %>%
  1969. filter(target==this_target) %>%
  1970. select(group_id, tx, dose_dio, target, target_disp, region, residual, x, y, color, panel) %>%
  1971. arrange(group_id) -> inflam_indivs
  1972. control_group_values = inflam_indivs$residual[inflam_indivs$tx=='saline']
  1973. inflam_indivs %>%
  1974. group_by(group_id, tx, dose_dio, target, target_disp, panel, x, y, color) %>%
  1975. summarize(.groups='keep',
  1976. n=n(),
  1977. mean = mean(residual),
  1978. l95 = lower(residual),
  1979. u95 = upper(residual),
  1980. ks_p = ks.test(residual,control_group_values)$p.value) %>%
  1981. ungroup() %>%
  1982. mutate(psymb = p_to_symbol(ks_p)) -> inflam_smry
  1983. par(mar=c(2,0,2,0.5))
  1984. xlims = range(0, 1.5)
  1985. ylims = range(xes$y) + c(-0.5, 0.5)
  1986. xats = 0:6/4
  1987. xbigs = 0:3/2
  1988. xbiglabs = percent(xbigs)
  1989. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i')
  1990. axis(side=1, at=xbigs, tck=-0.05, labels=NA)
  1991. axis(side=1, at=xats, tck=-0.02, labels=NA)
  1992. axis(side=1, at=xbigs, lwd=0, line=-0.75, labels=xbiglabs, cex=0.8)
  1993. mtext(side=3, line=0.25, text=target_meta$target_disp[i], cex=0.8, font=3)
  1994. axis(side=2, at=ylims, lwd.ticks=0, labels=NA)
  1995. abline(v=1, lty=3)
  1996. barwidth = 0.5
  1997. rect(ybottom=inflam_smry$y - barwidth/2, ytop=inflam_smry$y + barwidth/2, xleft=rep(0, nrow(inflam_smry)), xright=inflam_smry$mean, col=alpha(inflam_smry$color, ci_alpha), border=NA)
  1998. arrows(y0=inflam_smry$y, x0=inflam_smry$l95, x1=inflam_smry$u95, code=3, angle=90, length=0.05, col=inflam_smry$color)
  1999. points(x=inflam_indivs$residual, y=pmin(inflam_indivs$y, max(ylims)), pch=21, col=inflam_indivs$color, bg='#FFFFFF', cex=0.5)
  2000. mtext(side=4, at=inflam_smry$y, text=inflam_smry$psymb, cex=0.5, las=2, line=0, adj=1)
  2001. }
  2002. ## Figure S4 - genotype comparison ####
  2003. tell_user('done.\nCreating Figure S4...')
  2004. if ('figure-s4'=='figure-s4') {
  2005. resx=300
  2006. png('display_items/figure-s04.png',width=6.5*resx,height=2.75*resx,res=resx)
  2007. layout_matrix = matrix(c(1,2,3,4), byrow=T, nrow=1)
  2008. layout(layout_matrix, widths=c(0.5, 1.0, 0.5, 1.0))
  2009. par(mar=c(3,4,4,1))
  2010. panel = 1
  2011. ### prep ####
  2012. gc_tg26 = process_elisas('CMR-1313', control_group='saline') %>%
  2013. filter(grepl('2440|saline',tx)) %>%
  2014. filter(dose_dio %in% c(0,10)) %>%
  2015. inner_join(meta, by='tx')
  2016. gc_tg25 = process_elisas('CMR-1418', control_group='saline') %>%
  2017. filter(grepl('2440|saline',tx)) %>%
  2018. filter(dose_dio %in% c(0,10)) %>%
  2019. inner_join(meta, by='tx')
  2020. gc_tg26 %>%
  2021. distinct(tx, is_reference, is_ntc, sequence_number, color) %>%
  2022. mutate(is_exna = grepl('exNA',tx,ignore.case=T)) %>%
  2023. arrange(!is_reference, !is_ntc, sequence_number, is_exna) %>%
  2024. mutate(x = row_number()) -> xes
  2025. gc_tg26$x = xes$x[match(gc_tg26$tx, xes$tx)]
  2026. gc_tg25$x = xes$x[match(gc_tg25$tx, xes$tx)]
  2027. ### Tg26372 ELISA 2440 ####
  2028. gc_tg26 %>%
  2029. group_by(x, tx, color) %>%
  2030. summarize(.groups='keep',
  2031. n= n(),
  2032. mean = mean(rel),
  2033. l95 = lower(rel),
  2034. u95 = upper(rel),
  2035. max = max(rel)) %>%
  2036. ungroup() -> gc_tg26_smry
  2037. xlims=range(gc_tg26$x)+c(-0.5,0.5)
  2038. ylims=c(0,1.5)
  2039. yats=0:6/4
  2040. ybigs=0:3/2
  2041. ybiglabs=percent(ybigs)
  2042. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i')
  2043. axis(side=1, at=xlims, labels=NA, lwd.ticks=0)
  2044. mtext(side=1, line=0.25, text='whole hemi', cex=0.8)
  2045. axis(side=2, at=yats, tck = -0.02, labels=NA)
  2046. axis(side=2, at=ybigs, tck = -0.05, labels=NA)
  2047. axis(side=2, at=ybigs, lwd=0, labels=ybiglabs, las=2, line=-0.5)
  2048. mtext(side=2, line=2.75, text='residual PrP', cex=0.8)
  2049. abline(h=1, lty=3)
  2050. barwidth=0.8
  2051. rect(xleft=gc_tg26_smry$x - barwidth/2, xright=gc_tg26_smry$x + barwidth/2, ybottom=rep(0, nrow(gc_tg26_smry)), ytop=gc_tg26_smry$mean, col=alpha(gc_tg26_smry$color, ci_alpha), border=NA)
  2052. arrows(x0=gc_tg26_smry$x, y0=gc_tg26_smry$l95, y1=gc_tg26_smry$u95, code=3, angle=90, length=0.05, col=gc_tg26_smry$color)
  2053. points(x=gc_tg26$x, y=pmin(gc_tg26$rel, max(ylims)), pch=21, col=gc_tg26$color, bg='#FFFFFF', cex=0.5)
  2054. par(xpd=T)
  2055. text(x=gc_tg26_smry$x, y=gc_tg26_smry$max+.15, labels=percent(gc_tg26_smry$mean,digits=1), srt=90, cex=0.7)
  2056. par(xpd=F)
  2057. gc_tg26_smry %>%
  2058. distinct(tx, color) -> tx_leg
  2059. # par(xpd=T)
  2060. # legend(x=3.5, y=1.75, legend=tx_leg$tx, pch=15, col=tx_leg$color, bty='n', cex=0.8)
  2061. # par(xpd=F)
  2062. mtext(side=3, line=3, at=2.5, text='20x transgenics (Tg26372 hom)', cex=0.8, adj=0)
  2063. mtext(LETTERS[panel], side=3, cex=2, adj = -0.7, line = 0.5)
  2064. panel = panel + 1
  2065. #### Tg26372 regional of hiPS vs. exNA for 2440 ####
  2066. regional_qpcr_studies = c('CMR-1313') # 2440 exNA & hiPS in 26372
  2067. qpcr %>%
  2068. filter(study_id %in% regional_qpcr_studies) %>%
  2069. filter(target=='PRNP') %>%
  2070. group_by(study_id, qpcr_id, region, biorep, sample_group) %>%
  2071. summarize(.groups='keep',
  2072. n_techreps = n(),
  2073. mean_twoddct = mean(twoddct)) %>%
  2074. ungroup() %>%
  2075. group_by(study_id, qpcr_id, region) %>%
  2076. mutate(residual = mean_twoddct / mean(mean_twoddct[sample_group %in% c('saline','PBS')])) %>%
  2077. ungroup() -> regional_qpcr
  2078. tx_compared_by_qpcr = tibble(tx_on_qpcr_plate=c('2440-hiPS','2440-exNA','saline','PBS'),
  2079. tx = c('2440-s1','2440-s4','PBS','PBS'),
  2080. x_offset = c(0, 0.25, -0.25, -0.25))
  2081. tx_compared_by_qpcr$color = meta$color[match(tx_compared_by_qpcr$tx, meta$display_tx)]
  2082. region_meta = tibble(region=c("HP", "PFC", "VC", "Str", "Thal", "CB"),
  2083. x = 1:6)
  2084. regional_qpcr %>%
  2085. inner_join(tx_compared_by_qpcr, by=c('sample_group'='tx_on_qpcr_plate')) %>%
  2086. select(tx, region, residual, x_offset, color) %>%
  2087. filter(!is.na(residual)) %>%
  2088. inner_join(region_meta, by='region') -> regional_indivs
  2089. xlims = range(region_meta$x) + c(-0.5, 0.5)
  2090. ylims = range(0, 1.5)
  2091. regional_indivs %>%
  2092. group_by(tx, region, x, x_offset, color) %>%
  2093. summarize(.groups='keep',
  2094. n=n(),
  2095. mean = mean(residual),
  2096. l95 = lower(residual),
  2097. u95 = upper(residual),
  2098. max = pmin(max(residual),max(ylims))) %>%
  2099. ungroup() -> regional_smry
  2100. yats=0:6/4
  2101. ybigs=0:3/2
  2102. ybiglabs=percent(ybigs)
  2103. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i')
  2104. axis(side=1, at=xlims, labels=NA, lwd.ticks=0)
  2105. par(xpd=T)
  2106. text(x=region_meta$x, y=rep(-0.05, nrow(region_meta)), labels=region_meta$region, srt=45, adj=1)
  2107. par(xpd=F)
  2108. axis(side=2, at=yats, tck = -0.02, labels=NA)
  2109. axis(side=2, at=ybigs, tck = -0.05, labels=NA)
  2110. axis(side=2, at=ybigs, lwd=0, labels=ybiglabs, las=2, line=-0.5)
  2111. mtext(side=2, line=2.75, text=expression(residual~italic(PRNP)), cex=0.8)
  2112. abline(h=1, lty=3)
  2113. barwidth=0.25
  2114. rect(xleft=regional_smry$x + regional_smry$x_offset - barwidth/2, xright=regional_smry$x + regional_smry$x_offset + barwidth/2, ybottom=rep(0, nrow(regional_smry)), ytop=regional_smry$mean, col=alpha(regional_smry$color, ci_alpha), border=NA)
  2115. arrows(x0=regional_smry$x + regional_smry$x_offset, y0=regional_smry$l95, y1=regional_smry$u95, code=3, angle=90, length=0.025, col=regional_smry$color)
  2116. points(x=regional_indivs$x + regional_indivs$x_offset, y=pmin(regional_indivs$residual, max(ylims)), pch=21, col=regional_indivs$color, bg='#FFFFFF', cex=0.5)
  2117. par(xpd=T)
  2118. # text(x=regional_smry$x + regional_smry$x_offset, y=rep(max(ylims),nrow(regional_smry))+.1, labels=percent(regional_smry$mean,digits=1), srt=90, cex=0.6)
  2119. par(xpd=F)
  2120. mtext(LETTERS[panel], side=3, cex=2, adj = 0, line = 0.5)
  2121. panel = panel + 1
  2122. ### Tg25109 ELISA 2440 ####
  2123. gc_tg25 %>%
  2124. group_by(x, tx, color) %>%
  2125. summarize(.groups='keep',
  2126. n= n(),
  2127. mean = mean(rel),
  2128. l95 = lower(rel),
  2129. u95 = upper(rel),
  2130. max = max(rel)) %>%
  2131. ungroup() -> gc_tg25_smry
  2132. xlims=range(gc_tg25$x)+c(-0.5,0.5)
  2133. ylims=c(0,1.5)
  2134. yats=0:6/4
  2135. ybigs=0:3/2
  2136. ybiglabs=percent(ybigs)
  2137. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i')
  2138. axis(side=1, at=xlims, labels=NA, lwd.ticks=0)
  2139. mtext(side=1, line=0.25, text='whole hemi', cex=0.8)
  2140. axis(side=2, at=yats, tck = -0.02, labels=NA)
  2141. axis(side=2, at=ybigs, tck = -0.05, labels=NA)
  2142. axis(side=2, at=ybigs, lwd=0, labels=ybiglabs, las=2, line=-0.5)
  2143. mtext(side=2, line=2.75, text='residual PrP', cex=0.8)
  2144. abline(h=1, lty=3)
  2145. barwidth=0.8
  2146. rect(xleft=gc_tg25_smry$x - barwidth/2, xright=gc_tg25_smry$x + barwidth/2, ybottom=rep(0, nrow(gc_tg25_smry)), ytop=gc_tg25_smry$mean, col=alpha(gc_tg25_smry$color, ci_alpha), border=NA)
  2147. arrows(x0=gc_tg25_smry$x, y0=gc_tg25_smry$l95, y1=gc_tg25_smry$u95, code=3, angle=90, length=0.05, col=gc_tg25_smry$color)
  2148. points(x=gc_tg25$x, y=pmin(gc_tg25$rel, max(ylims)), pch=21, col=gc_tg25$color, bg='#FFFFFF', cex=0.5)
  2149. par(xpd=T)
  2150. text(x=gc_tg25_smry$x, y=gc_tg25_smry$max+.15, labels=percent(gc_tg25_smry$mean,digits=1), srt=90, cex=0.7)
  2151. par(xpd=F)
  2152. mtext(LETTERS[panel], side=3, cex=2, adj = -0.7, line = 0.5)
  2153. panel = panel + 1
  2154. gc_tg25_smry %>%
  2155. distinct(tx, color) -> tx_leg
  2156. # par(xpd=T)
  2157. # legend(x=3.5, y=1.75, legend=tx_leg$tx, pch=15, col=tx_leg$color, bty='n', cex=0.8)
  2158. # par(xpd=F)
  2159. mtext(side=3, line=3, at=2.5, text='3x transgenics (Tg25109 het)', cex=0.8, adj=0)
  2160. #### Tg25109 regional of 2440 hiPS vs. exNA ####
  2161. regional_qpcr_studies = c('CMR-1418') # 2440 exNA & hiPS in 25109
  2162. qpcr %>%
  2163. filter(study_id %in% regional_qpcr_studies) %>%
  2164. filter(target=='PRNP') %>%
  2165. group_by(study_id, qpcr_id, region, biorep, sample_group) %>%
  2166. summarize(.groups='keep',
  2167. n_techreps = n(),
  2168. mean_twoddct = mean(twoddct)) %>%
  2169. ungroup() %>%
  2170. group_by(study_id, qpcr_id, region) %>%
  2171. mutate(residual = mean_twoddct / mean(mean_twoddct[sample_group %in% c('saline','PBS')])) %>%
  2172. ungroup() -> regional_qpcr
  2173. tx_compared_by_qpcr = tibble(tx_on_qpcr_plate=c('2440-hiPS','2440-exNA','saline','PBS'),
  2174. tx = c('2440-s1','2440-s4','PBS','PBS'),
  2175. x_offset = c(0, 0.25, -0.25, -0.25))
  2176. tx_compared_by_qpcr$color = meta$color[match(tx_compared_by_qpcr$tx, meta$display_tx)]
  2177. region_meta = tibble(region=c("HP", "PFC", "VC", "Str", "Thal", "CB"),
  2178. x = 1:6)
  2179. regional_qpcr %>%
  2180. inner_join(tx_compared_by_qpcr, by=c('sample_group'='tx_on_qpcr_plate')) %>%
  2181. select(tx, region, residual, x_offset, color) %>%
  2182. filter(!is.na(residual)) %>%
  2183. inner_join(region_meta, by='region') -> regional_indivs
  2184. regional_indivs %>%
  2185. group_by(tx, region, x, x_offset, color) %>%
  2186. summarize(.groups='keep',
  2187. n=n(),
  2188. mean = mean(residual),
  2189. l95 = lower(residual),
  2190. u95 = upper(residual),
  2191. max = max(residual)) %>%
  2192. ungroup() -> regional_smry
  2193. xlims = range(region_meta$x) + c(-0.5, 0.5)
  2194. ylims = range(0, 1.5)
  2195. yats=0:6/4
  2196. ybigs=0:3/2
  2197. ybiglabs=percent(ybigs)
  2198. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i')
  2199. axis(side=1, at=xlims, labels=NA, lwd.ticks=0)
  2200. par(xpd=T)
  2201. text(x=region_meta$x, y=rep(-0.05, nrow(region_meta)), labels=region_meta$region, srt=45, adj=1)
  2202. par(xpd=F)
  2203. axis(side=2, at=yats, tck = -0.02, labels=NA)
  2204. axis(side=2, at=ybigs, tck = -0.05, labels=NA)
  2205. axis(side=2, at=ybigs, lwd=0, labels=ybiglabs, las=2, line=-0.5)
  2206. mtext(side=2, line=2.75, text=expression(residual~italic(PRNP)), cex=0.8)
  2207. abline(h=1, lty=3)
  2208. barwidth=0.25
  2209. rect(xleft=regional_smry$x + regional_smry$x_offset - barwidth/2, xright=regional_smry$x + regional_smry$x_offset + barwidth/2, ybottom=rep(0, nrow(regional_smry)), ytop=regional_smry$mean, col=alpha(regional_smry$color, ci_alpha), border=NA)
  2210. suppressWarnings(arrows(x0=regional_smry$x + regional_smry$x_offset, y0=regional_smry$l95, y1=regional_smry$u95, code=3, angle=90, length=0.025, col=regional_smry$color))
  2211. points(x=regional_indivs$x + regional_indivs$x_offset, y=pmin(regional_indivs$residual, max(ylims)), pch=21, col=regional_indivs$color, bg='#FFFFFF', cex=0.5)
  2212. par(xpd=T)
  2213. # text(x=regional_smry$x + regional_smry$x_offset, y=regional_smry$max+.1, labels=percent(regional_smry$mean,digits=1), srt=90, cex=0.6)
  2214. par(xpd=F)
  2215. mtext(LETTERS[panel], side=3, cex=2, adj = 0, line = 0.5)
  2216. panel = panel + 1
  2217. tx_compared_by_qpcr %>%
  2218. distinct(tx, color) -> tx_leg
  2219. par(xpd=T)
  2220. legend(x=3.5, y=1.75, legend=tx_leg$tx, pch=15, col=tx_leg$color, bty='n', cex=1)
  2221. par(xpd=F)
  2222. silence_is_golden = dev.off()
  2223. }
  2224. ## Figure S5 - weights, Gfap, Iba1 ####
  2225. tell_user('done.\nCreating Figure S5...')
  2226. if ('figure-s5'=='figure-s5') {
  2227. resx=300
  2228. png('display_items/figure-s05.png',width=6.5*resx,height=6*resx,res=resx)
  2229. ### prep weights ####
  2230. weights_qpcr_studies = c('CMR-1313', 'CMR-1418', 'CMR-1465', 'CMR-1697', 'CMR-1871', 'CMR-2198', 'CMR-2371')
  2231. process_elisas(weights_qpcr_studies, control_group='PBS') %>%
  2232. arrange(dose_dio, tx) %>%
  2233. inner_join(meta, by='tx') -> proc
  2234. proc %>%
  2235. distinct(study_id, tx, is_reference, is_ntc, sequence_number, color, dose_dio) %>%
  2236. mutate(is_exna = grepl('exNA',tx,ignore.case=T)) %>%
  2237. arrange(study_id, !is_reference, !is_ntc, sequence_number, is_exna, tx, dose_dio) %>%
  2238. mutate(x = row_number()) -> xes
  2239. weight_deltas(weights_qpcr_studies) %>%
  2240. inner_join(meta, by='tx') %>%
  2241. inner_join(xes %>% select(study_id, tx, dose_dio, x), by=c('study_id','tx','dose_dio')) -> deltas
  2242. deltas %>%
  2243. select(study_id, animal, sex, display_tx, dose_dio, wt_date, weight, baseline, change) -> deltas_out
  2244. write_supp_table(deltas_out, 'Animal weight change relative to baseline in target engagement studies.')
  2245. deltas %>%
  2246. mutate(wt_week = round(wt_date/7)) %>%
  2247. group_by(study_id, tx, x, wt_week, color, display_tx, dose_dio) %>%
  2248. summarize(.groups='keep',
  2249. wt_dates = toString(unique(wt_date)),
  2250. n = n(),
  2251. mean=mean(change),
  2252. l95 = lower(change),
  2253. u95 = upper(change)) %>%
  2254. ungroup() %>%
  2255. mutate(disp = paste0(gsub(' tail','',display_tx), ' ', nmol_to_ug(dose_dio),' µg')) -> deltas_smry
  2256. deltas_smry %>%
  2257. filter(!is.na(x)) %>%
  2258. arrange(x) -> deltas_smry
  2259. deltas %>%
  2260. distinct(tx) %>%
  2261. arrange(desc(tx)) %>%
  2262. pull() -> tx_in_order_with_saline_first
  2263. deltas$tx_fct = factor(deltas$tx, levels=tx_in_order_with_saline_first)
  2264. ### layout ####
  2265. layout_matrix = matrix(c(50,51,51,51,52,52,52,
  2266. 1:49), nrow=8, byrow=T)
  2267. layout(layout_matrix, widths=c(.35, rep(1,6)), heights=c(2, rep(1,6),.3))
  2268. panel = 3
  2269. par(mar=c(0.5,0.5,0.5,0))
  2270. xlims = c(-3,35)
  2271. ylims = c(-0.3, 0.3)
  2272. ybigs = -3:3/10
  2273. xats = -1:34
  2274. xbigs = 0:3*10
  2275. # for (actual_panel in 1:4) {
  2276. # plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i')
  2277. # axis(side=2, line=-2.5, at=ybigs, labels=percent(ybigs, signed=T), lwd=0, las=2)
  2278. # }
  2279. par(mar=c(0.5,0,0.5,0))
  2280. this_x = 1
  2281. for (i in 1:49) {
  2282. if (i %% 7 == 1 & i != 43) {
  2283. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i')
  2284. axis(side=2, line=-3.2, at=ybigs, labels=percent(ybigs, signed=T), lwd=0, las=2, cex.axis=.7)
  2285. } else if (i == 43) {
  2286. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i')
  2287. } else if (i >= 44) {
  2288. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i')
  2289. # axis(side=1, line=-3, at=xlims, lwd.ticks=0, labels=NA)
  2290. axis(side=1, line=-2.5, at=xbigs, lwd=0, labels=xbigs)
  2291. } else {
  2292. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i')
  2293. #axis(side=2, at=ybigs, labels=NA, tck=-0.05)
  2294. #axis(side=2, at=ybigs, labels=percent(ybigs, signed=T), line=-0.5, lwd=0, las=2)
  2295. abline(h=0, lty=2)
  2296. subs = deltas %>% filter(x==this_x)
  2297. subs_smry = deltas_smry %>% filter(x==this_x)
  2298. for (anml in unique(deltas$animal)) {
  2299. subsubs = subs %>% filter(animal==anml)
  2300. points(subsubs$wt_date, subsubs$change, lwd=0.5, type='l', col=subsubs$color)
  2301. }
  2302. #points(subs_smry$wt_date, subs_smry$mean, lwd=1.5, type='l', col=subs_smry$color)
  2303. #polygon(x=c(subs_smry$wt_date,rev(subs_smry$wt_date)), y=c(subs_smry$l95, rev(subs_smry$u95)), col=alpha(subs_smry$color[1], ci_alpha), border=NA)
  2304. axis(side=2, line=0, at=ybigs, labels=NA, tck=-0.05)
  2305. mtext(side=3, line=-0.5, at=0, adj=0, text=subs_smry$disp[1], col=subs_smry$color[1], cex=0.5)
  2306. axis(side=1, line=0, at=xbigs, tck=-0.05, labels=NA)
  2307. axis(side=1, line=0, at=xats, tck=-0.02, labels=NA)
  2308. this_x = this_x + 1
  2309. }
  2310. if (i == 1) {
  2311. mtext(side=3, adj=0.05, text=LETTERS[panel], line=0.0)
  2312. }
  2313. }
  2314. xlims = 0:1
  2315. ylims = c(0,1.5)
  2316. ybigs = 0:6/4
  2317. par(mar=c(3,0,2,0))
  2318. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i')
  2319. axis(side=2, line=-3.5, at=ybigs, labels=percent(ybigs), lwd=0, las=2)
  2320. ### neuroinflam markers ####
  2321. inflam_qpcr_studies = c('CMR-1313', 'CMR-1418', 'CMR-1465', 'CMR-1697')
  2322. qpcr %>%
  2323. filter(study_id %in% inflam_qpcr_studies) %>%
  2324. filter(target %in% c('GFAP','IBA1')) %>%
  2325. inner_join(qpcr_txes, by=c('sample_group','study_id')) %>%
  2326. group_by(study_id, qpcr_id, target, region, biorep, tx) %>%
  2327. summarize(.groups='keep',
  2328. n_techreps = n(),
  2329. mean_twoddct = mean(twoddct)) %>%
  2330. ungroup() %>%
  2331. group_by(study_id, qpcr_id, region, target) %>%
  2332. mutate(residual = mean_twoddct / mean(mean_twoddct[tx %in% c('saline')])) %>%
  2333. ungroup() %>%
  2334. filter(!is.na(tx)) %>%
  2335. inner_join(meta, by='tx') %>%
  2336. mutate(xid = paste0(study_id, tx)) %>%
  2337. mutate(x = dense_rank(xid)) -> inflam_qpcr
  2338. # statistics on GFAP & IBA1 - first set saline as refernece group
  2339. inflam_qpcr %>%
  2340. distinct(tx) %>%
  2341. arrange(desc(tx)) %>%
  2342. pull() -> tx_in_order_with_saline_first
  2343. inflam_qpcr$tx_fct = factor(inflam_qpcr$tx, levels=tx_in_order_with_saline_first)
  2344. subs = inflam_qpcr %>% filter(target=='GFAP')
  2345. DunnettTest(subs$residual, subs$tx_fct)
  2346. subs = inflam_qpcr %>% filter(target=='IBA1')
  2347. DunnettTest(subs$residual, subs$tx_fct)
  2348. target_meta = tibble(target=c('GFAP','IBA1'),
  2349. target_disp = c('Gfap','Iba1'),
  2350. panel = c(1,2))
  2351. inflam_qpcr %>%
  2352. inner_join(target_meta, by='target') %>%
  2353. group_by(panel, target, target_disp, study_id, tx, display_tx, x, xid, color) %>%
  2354. summarize(.groups='keep',
  2355. n=n(),
  2356. mean = mean(residual),
  2357. l95 = lower(residual),
  2358. u95 = upper(residual)) %>%
  2359. ungroup() -> inflam_smry
  2360. inflam_smry %>%
  2361. group_by(target) %>%
  2362. mutate(xrank = rank(mean, ties.method='first')) %>%
  2363. mutate(xrank = max(xrank) - xrank + 1) %>% # reverse order on x axis
  2364. ungroup() -> new_xes
  2365. inflam_qpcr %>%
  2366. inner_join(new_xes %>% select(target, xid, xrank), by=c('target','xid')) -> inflam_qpcr
  2367. inflam_smry %>%
  2368. inner_join(new_xes %>% select(target, xid, xrank), by=c('target','xid')) -> inflam_smry
  2369. inflam_qpcr %>%
  2370. select(study_id, display_tx, region, target, residual) -> inflam_qpcr_out
  2371. write_supp_table(inflam_qpcr_out, 'Gfap and Iba1 inflammatory markers in target engagement studies - individual animal data.')
  2372. inflam_smry %>%
  2373. select(study_id, display_tx, target, n, mean, l95, u95) -> inflam_smry_out
  2374. write_supp_table(inflam_smry_out, 'Gfap and Iba1 inflammatory markers in target engagement studies - summarized.')
  2375. panel = 1
  2376. for (this_panel in target_meta$panel) {
  2377. indiv_subs = inflam_qpcr %>% filter(target == target_meta$target[target_meta$panel==this_panel])
  2378. smry_subs = inflam_smry %>% filter(target == target_meta$target[target_meta$panel==this_panel])
  2379. par(mar=c(3,0,2,1))
  2380. xlims = range(new_xes$x) + c(-0.5, 0.5)
  2381. ylims = range(0, 1.5)
  2382. yats=0:6/4
  2383. ybigs=0:3/2
  2384. ybiglabs = percent(ybigs)
  2385. ybiglabs[ybigs==1.5] = '≥150%'
  2386. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i')
  2387. axis(side=1, at=xlims, labels=NA, lwd.ticks=0)
  2388. #axis(side=2, at=yats, tck = -0.02, labels=NA)
  2389. #axis(side=2, at=ybigs, tck = -0.05, labels=NA)
  2390. #axis(side=2, at=ybigs, lwd=0, labels=ybiglabs, las=2, line=-0.5)
  2391. mtext(side=3, line=0, text=smry_subs$target_disp[1], cex=1, font=3)
  2392. abline(h=1, lty=3)
  2393. barwidth=0.8
  2394. rect(xleft=smry_subs$xrank - barwidth/2, xright=smry_subs$xrank + barwidth/2, ybottom=rep(0, nrow(smry_subs)), ytop=smry_subs$mean, col=alpha(smry_subs$color, ci_alpha), border=NA)
  2395. arrows(x0 =smry_subs$xrank , y0=smry_subs$l95, y1=smry_subs$u95, code=3, angle=90, length=0.025, col=smry_subs$color)
  2396. points(x =indiv_subs$xrank , y=pmin(indiv_subs$residual, max(ylims)), pch=21, col=indiv_subs$color, bg='#FFFFFF', cex=0.5)
  2397. # mtext(side=1, line=0.1, at=smry_subs$xrank, las=2, cex=0.8, text=paste0(smry_subs$study_id, ' ', smry_subs$display_tx))
  2398. mtext(side=1, line=0.1, at=smry_subs$xrank, las=2, cex=0.6, text=smry_subs$display_tx)
  2399. mtext(side=3, adj=0.05, text=LETTERS[panel], line=0.0); panel = panel + 1
  2400. }
  2401. silence_is_golden = dev.off()
  2402. }
  2403. ### end Figure S5 ####
  2404. ## Figure 6 - durability, dosing regimen, PD/PK, tox ####
  2405. if ('figure-6'=='figure-6') {
  2406. tell_user('done.\nCreating Figure 6...')
  2407. resx=300
  2408. png('display_items/figure-6.png',width=4.5*resx,height=5.0*resx,res=resx)
  2409. layout_matrix = matrix(c(1,2,
  2410. 3,4,
  2411. 5,5), byrow=T, nrow=3)
  2412. layout(layout_matrix, heights=c(1,1,1), widths=c(1,1))
  2413. panel = 1
  2414. ### space for diagram across top ####
  2415. par(mar=c(5,0.5,2,0.1))
  2416. raster_panel = image_convert(image_read('data/miscellaneous/2439-s4_structure.png'),'png')
  2417. plot(as.raster(raster_panel))
  2418. mtext(side=3, adj=0.05, text=LETTERS[panel], line=0.0); panel = panel + 1
  2419. # and a legend in A for the panels below it
  2420. durability_study1 = c('CMR-2371')
  2421. study %>%
  2422. filter(study_id %in% durability_study1) %>%
  2423. distinct(tx) %>%
  2424. inner_join(meta, by='tx') %>%
  2425. filter(display_tx %in% c('2439-s4','none','-')) %>%
  2426. select(color, display_tx) -> leg
  2427. par(xpd=T)
  2428. legxmin = par()$usr[1]
  2429. legxmax = par()$usr[2]
  2430. legymin = par()$usr[3]
  2431. legymax = par()$usr[4]
  2432. legend(x=legxmin, y=legymin-(legymax-legymin)/2.5, horiz=T, bty='n', cex=1.2, leg$display_tx, col=leg$color, text.col=leg$color, pch=15)
  2433. par(xpd=F)
  2434. ### PD/PK study ####
  2435. pdpk_qpcr_studies = c('CMR-2521') #
  2436. pdpk_meta = tribble(
  2437. ~dose_ug, ~color,
  2438. 0, '#A9A9A9',
  2439. 3, '#d4b9da',
  2440. 10, '#c994c7',
  2441. 35, '#df65b0',
  2442. 104, '#dd1c77',
  2443. 348, '#980043'
  2444. )
  2445. pk = read_tsv('data/analytic/pk.tsv', col_types=cols())
  2446. mouse_brain_weight = 0.4 # grams
  2447. qpcr %>%
  2448. filter(study_id %in% pdpk_qpcr_studies) %>%
  2449. filter(target=='PRNP') %>%
  2450. group_by(sample_id, study_id, qpcr_id, region, biorep, sample_group) %>%
  2451. summarize(.groups='keep',
  2452. n_techreps = n(),
  2453. mean_twoddct = mean(twoddct)) %>%
  2454. ungroup() %>%
  2455. group_by(study_id, qpcr_id, region) %>%
  2456. mutate(residual = mean_twoddct / mean(mean_twoddct[sample_group %in% c('saline','PBS')])) %>%
  2457. ungroup() -> pdpk_qpcr
  2458. study %>%
  2459. filter(study_id %in% pdpk_qpcr_studies) %>%
  2460. inner_join(pdpk_qpcr, by=c('animal'='sample_id','study_id')) %>%
  2461. mutate(dose_ug = nmol_to_ug(dose_dio)) %>%
  2462. mutate(pseudo_ug = case_when(dose_ug == 0 ~ 1,
  2463. TRUE ~ dose_ug)) %>%
  2464. inner_join(meta, by='tx') %>%
  2465. mutate(residual = mean_twoddct / mean(mean_twoddct[sample_group=='aCSF'])) %>%
  2466. left_join(pk %>% mutate(id=as.character(id)), by=c('animal'='id')) %>%
  2467. mutate(plotconc_ng_g = coalesce(concentration_ng_g,lloq_ng_g)) %>%
  2468. left_join(pdpk_meta, by='dose_ug', suffix=c('_tx','_dose')) %>%
  2469. mutate(dose_retained = case_when(dose_ug == 0 ~ NA,
  2470. TRUE ~ concentration_ng_g / 1000 * mouse_brain_weight / dose_ug)) -> pdpk
  2471. # double check annotations
  2472. # sum(pdpk$dose_dio != pdpk$dose_nmole) # 0, good
  2473. pdpk %>%
  2474. group_by(dose_ug, pseudo_ug, color_tx, color_dose) %>%
  2475. summarize(.groups='keep',
  2476. n=n(),
  2477. pd_mean = mean(residual),
  2478. pd_l95 = lower(residual),
  2479. pd_u95 = upper(residual),
  2480. pk_llq = mean(lloq_ng_g),
  2481. pk_mean = mean(plotconc_ng_g, na.rm=T),
  2482. pk_l95 = lower(plotconc_ng_g),
  2483. pk_u95 = upper(plotconc_ng_g),
  2484. retained_mean = mean(dose_retained, na.rm=T),
  2485. retained_l95 = lower(dose_retained),
  2486. retained_u95 = upper(dose_retained)) %>%
  2487. ungroup() -> pdpk_smry
  2488. par(mar=c(3,3.5,2,2))
  2489. xlims = c(7, 20000)
  2490. xats = rep(2:9, 6) * rep(10^(0:5),each=8)
  2491. xbigs = 10^(0:5)
  2492. xbiglabs = c('1 ng/g','10 ng/g','100 ng/g','1 µg/g','10 µg/g','100 µg/g')
  2493. ylims = c(0, 1.125)
  2494. yats = 0:6/4
  2495. ybigs = 0:2/2
  2496. ybiglabs = percent(0:2/2)
  2497. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i', log='x')
  2498. abline(h=1, lty=3)
  2499. axis(side=1, at=xbigs, tck=-0.05, labels=NA)
  2500. axis(side=1, at=xbigs, lwd=0, labels=xbiglabs, line=-0.5, cex.axis=0.8)
  2501. axis(side=1, at=xats, tck=-0.02, labels=NA)
  2502. abline(v=pdpk_smry$pk_llq[1], lty=3)
  2503. mtext(side=3, at=pdpk_smry$pk_llq[1], text='LLQ', cex=0.6)
  2504. mtext(side=1, line=1.5, text='drug accumulation', cex=0.8)
  2505. mtext(side=2, line=2.25, text=expression(residual~italic(PRNP)), cex=0.7)
  2506. axis(side=2, at=ylims, lwd.ticks=0, labels=NA)
  2507. axis(side=2, at=yats, tck=-0.02, labels=NA)
  2508. axis(side=2, at=ybigs, tck=-0.05, labels=NA)
  2509. axis(side=2, at=ybigs, lwd=0, labels=ybiglabs, las=2, line=-0.75, cex.axis=0.8)
  2510. points(pdpk$plotconc_ng_g, pdpk$residual, pch=19, col=alpha(pdpk$color_dose, ci_alpha))
  2511. segments(x0=pdpk_smry$pk_l95, x1=pdpk_smry$pk_u95, y0=pdpk_smry$pd_mean, col=pdpk_smry$color_dose, lwd=2)
  2512. segments(x0=pdpk_smry$pk_mean, y0=pdpk_smry$pd_l95, y1=pdpk_smry$pd_u95, col=pdpk_smry$color_dose, lwd=2)
  2513. dr = drm(residual ~ concentration_ng_g, data=pdpk %>% filter(dose_ug > 0), fct=LL.4(fixed=c(b=NA,c=0,d=1,e=NA)))
  2514. ic50 = as.numeric(dr$coefficients['e:(Intercept)'])
  2515. x = 10^seq(0,5,.01)
  2516. y = predict(dr, newdata=data.frame(concentration_ng_g=x))
  2517. points(x,y,type='l',lwd=1,col='#000000')
  2518. par(xpd=T)
  2519. text(x=pdpk_smry$pk_mean*1.17, y=pdpk_smry$pd_mean+.05, labels=paste(pdpk_smry$dose_ug, 'µg'), col='#000000', adj=c(0,0), srt=20, cex=.6)
  2520. par(xpd=F)
  2521. mtext(side=3, adj=-0.2, text=LETTERS[panel], line=0.5); panel = panel + 1
  2522. summary(dr)$coefficients %>%
  2523. as_tibble(rownames='parameter') %>%
  2524. mutate(description = case_when(grepl('^b',parameter) ~ "Hill's slope",
  2525. grepl('^e',parameter) ~ "IC50 (ng/g)")) %>%
  2526. rename(estimate = `Estimate`,
  2527. se = `Std. Error`,
  2528. t_value = `t-value`,
  2529. p_value = `p-value`) %>%
  2530. select(parameter, description, estimate, se, t_value, p_value) -> dr_out
  2531. write_supp_table(dr_out, 'PD/PK model fit coefficients.')
  2532. ### durability 1 ####
  2533. par(mar=c(3,4,2,1))
  2534. durability_study1 = c('CMR-2371') # 'CMR-2198',
  2535. process_elisas(durability_study1, control_group=c('none')) %>%
  2536. arrange(dose_dio, days_harvest, tx) %>%
  2537. filter(days_harvest %in% c(0,34,120)) %>%
  2538. inner_join(meta, by='tx') %>%
  2539. filter(display_tx %in% c('2439-s4','none','-')) %>%
  2540. mutate(x = round(days_harvest / 30.44)) -> proc
  2541. xlims = c(0,5)
  2542. xbigs = c(1,4)
  2543. xbiglabs = c(34, 120)
  2544. xats = 0:5
  2545. ylims = c(0, 1.25)
  2546. ybigs = 0:3/2
  2547. yats = 0:6/4
  2548. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i')
  2549. axis(side=1, at=xbigs, tck=-0.05, labels=NA)
  2550. axis(side=1, at=xats, tck=-0.02, labels=NA)
  2551. axis(side=1, at=xbigs, lwd=0, line=-0.75, labels=xbiglabs, cex=0.8)
  2552. axis(side=2, at=yats, labels=NA, tck=-0.02)
  2553. axis(side=2, at=ybigs, labels=NA, tck=-0.05)
  2554. axis(side=2, at=ybigs, labels=percent(ybigs), line=-0.75, lwd=0, las=2, cex=0.8)
  2555. mtext(side=2, line=2.25, text='residual PrP', cex=0.8)
  2556. abline(h=1, lty=3)
  2557. proc %>%
  2558. group_by(x, display_tx, color) %>%
  2559. summarize(.groups='keep',
  2560. n = n(),
  2561. mean = mean(rel),
  2562. l95 = lower(rel),
  2563. u95 = upper(rel),
  2564. max = max(rel)) %>%
  2565. ungroup() -> proc_smry
  2566. barwidth = 0.4
  2567. segments(x0=proc_smry$x-barwidth, x1=proc_smry$x+barwidth, y0=proc_smry$mean, col=proc_smry$color, lwd=1.5)
  2568. arrows(x0=proc_smry$x, y0=proc_smry$l95, y1=proc_smry$u95, code=3, angle=90, length=0.05, col=proc_smry$color, lwd=1.5)
  2569. points(x=proc$x, y=proc$rel, pch=20, col=alpha(proc$color,ci_alpha))
  2570. proc_smry %>%
  2571. filter(display_tx != 'none') -> subs
  2572. par(xpd=T)
  2573. text(x=subs$x, y=subs$mean, pos=4, col='#000000', labels=paste0(' ',percent(subs$mean, digits=1)), cex=0.6)
  2574. par(xpd=F)
  2575. mtext(side=3, line=0, text='single 348 µg dose', cex=0.8)
  2576. mtext(side=1, line=1, text='harvest (days post-dose)', cex=0.7)
  2577. mtext(side=3, adj=-0.0, text=LETTERS[panel], line=0.5); panel = panel + 1
  2578. ### durability 2 ####
  2579. durability_study2 = c('CMR-2198')
  2580. process_elisas(durability_study2, control_group=c('-')) %>%
  2581. arrange(dose_dio, days_harvest, tx) %>%
  2582. filter(days_harvest %in% c(0, 29, 91, 180)) %>%
  2583. inner_join(meta, by='tx') %>%
  2584. mutate(display_tx = gsub(' fixed tail','',display_tx)) %>%
  2585. filter(grepl('s4|none', display_tx)) %>%
  2586. mutate(x = round(days_harvest / 30.44)) -> proc
  2587. xlims = c(0,7)
  2588. xbigs = c(1, 3, 6)
  2589. xbiglabs = c(29, 91, 180)
  2590. xats = 0:7
  2591. ylims = c(0, 1.25)
  2592. ybigs = 0:3/2
  2593. yats = 0:6/4
  2594. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i')
  2595. axis(side=1, at=xbigs, tck=-0.05, labels=NA)
  2596. axis(side=1, at=xats, tck=-0.02, labels=NA)
  2597. axis(side=1, at=xbigs, lwd=0, line=-0.75, labels=xbiglabs, cex=0.8)
  2598. axis(side=2, at=yats, labels=NA, tck=-0.02)
  2599. axis(side=2, at=ybigs, labels=NA, tck=-0.05)
  2600. axis(side=2, at=ybigs, labels=percent(ybigs), line=-0.75, lwd=0, las=2, cex=0.8)
  2601. mtext(side=2, line=2.25, text='residual PrP', cex=0.8)
  2602. abline(h=1, lty=3)
  2603. proc %>%
  2604. group_by(x, display_tx, color) %>%
  2605. summarize(.groups='keep',
  2606. n = n(),
  2607. mean = mean(rel),
  2608. l95 = lower(rel),
  2609. u95 = upper(rel),
  2610. max = max(rel)) %>%
  2611. ungroup() -> proc_smry
  2612. barwidth = 0.4
  2613. segments(x0=proc_smry$x-barwidth, x1=proc_smry$x+barwidth, y0=proc_smry$mean, col=proc_smry$color, lwd=1.5)
  2614. arrows(x0=proc_smry$x, y0=proc_smry$l95, y1=proc_smry$u95, code=3, angle=90, length=0.05, col=proc_smry$color, lwd=1.5)
  2615. points(x=proc$x, y=proc$rel, pch=20, col=alpha(proc$color,ci_alpha))
  2616. proc_smry %>%
  2617. filter(display_tx != 'none') -> subs
  2618. par(xpd=T)
  2619. text(x=subs$x, y=subs$mean, pos=4, col='#000000', labels=paste0(' ',percent(subs$mean, digits=1)), cex=0.6)
  2620. par(xpd=F)
  2621. mtext(side=3, line=0, text='single 174 µg dose', cex=0.8)
  2622. mtext(side=1, line=1, text='harvest (days post-dose)', cex=0.7)
  2623. mtext(side=3, adj=-0.0, text=LETTERS[panel], line=0.5); panel = panel + 1
  2624. ### CMR-3164 repeat dosing ####
  2625. repeat_dose_study = c('CMR-3164')
  2626. proc = process_elisas(repeat_dose_study, control_group = 'none') %>%
  2627. inner_join(meta, by='tx') %>%
  2628. mutate(days_harvest = round(days_harvest/10)*10) %>%
  2629. mutate(dosing_regimen = case_when(dosing_regimen == '0, 70, 90' ~ '0, 7, 90',
  2630. TRUE ~ dosing_regimen))
  2631. proc %>%
  2632. distinct(tx, dose_dio, dosing_regimen, days_harvest) %>%
  2633. arrange(days_harvest, dose_dio) %>%
  2634. mutate(x = row_number()) %>%
  2635. mutate(y = max(x) - x + 1) %>%
  2636. mutate(group_id = paste0(tx,' ',dose_dio,' ',dosing_regimen,' ',days_harvest)) -> xes
  2637. proc %>%
  2638. inner_join(xes, by=c('tx', 'dose_dio', 'dosing_regimen','days_harvest')) %>%
  2639. mutate(pch=21) -> proc
  2640. proc %>%
  2641. group_by(x, y, tx, dose_dio, dosing_regimen, days_harvest, color) %>%
  2642. summarize(.groups = 'keep',
  2643. n = n(),
  2644. mean = mean(rel),
  2645. l95 = lower(rel),
  2646. u95 = upper(rel),
  2647. max = max(rel)) %>%
  2648. ungroup() %>%
  2649. mutate(disp_dose = case_when(dose_dio > 0 ~ paste0(nmol_to_ug(dose_dio), ' µg'),
  2650. dose_dio == 0 ~ 'no dose')) %>%
  2651. mutate(disp_dosing_days = str_pad(paste0('day ',dosing_regimen),side='right',pad=' ',width=21)) %>%
  2652. mutate(disp = paste0(disp_dosing_days, ', harvest day ',days_harvest)) -> proc_smry
  2653. par(mar=c(2,13,2,2))
  2654. xlims = c(0,1.60)
  2655. ylims = range(proc$y) + c(-0.5, 0.5)
  2656. xats = 0:6/4
  2657. xbigs = 0:3/2
  2658. xbiglabs = percent(0:3/2)
  2659. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i')
  2660. abline(v=1, lty=3)
  2661. axis(side=1, at=xbigs, tck=-0.05, labels=NA)
  2662. axis(side=1, at=xats, tck=-0.02, labels=NA)
  2663. axis(side=1, at=xbigs, lwd=0, line=-0.75, labels=xbiglabs, cex=0.8)
  2664. mtext(side=3, line=0.25, text='residual PrP', cex=0.8)
  2665. axis(side=2, at=ylims, lwd.ticks=0, labels=NA)
  2666. mtext(side=2, at=proc_smry$y, line=9, text=proc_smry$disp_dose, las=2, cex=0.6, adj = 1)
  2667. mtext(side=2, at=proc_smry$y, line=8, text=proc_smry$disp_dosing_days, las=2, cex=0.6,adj = 0)
  2668. mtext(side=2, at=proc_smry$y, line=0.25, text=paste0('day ',proc_smry$days_harvest), las=2, cex=0.6, adj = 1)
  2669. mtext(side=2, at=max(ylims) + 0.5, las=2, line=9, text='dose level', cex=0.5, font=2, padj=1, adj=1)
  2670. mtext(side=2, at=max(ylims) + 0.5, las=2, line=8, text='dosing days', cex=0.5, font=2, padj=1, adj=0)
  2671. mtext(side=2, at=max(ylims) + 0.5, las=2, line=0.25, text='harvest day', cex=0.5, font=2, padj=1, adj=1)
  2672. barwidth=0.8
  2673. rect(xleft=rep(0, nrow(proc_smry)), xright=proc_smry$mean, ybottom=proc_smry$y-barwidth/2, , ytop=proc_smry$y+barwidth/2, col=alpha(proc_smry$color, ci_alpha), border=NA)
  2674. arrows(x0=proc_smry$l95, x1=proc_smry$u95, y0=proc_smry$y, col=proc_smry$color, lwd=1.5, code=3, angle=90, length=0.05)
  2675. points(x=proc$rel, y=proc$y, col=proc$color, bg='#FFFFFF', pch=21)
  2676. par(xpd=T)
  2677. text(x=rep(1.5,nrow(proc_smry)), y=proc_smry$y, pos=4, col='#000000', cex=0.6, labels=paste0(' ',percent(proc_smry$mean, digits=1)))
  2678. par(xpd=F)
  2679. mtext(side=3, adj=-0.0, text=LETTERS[panel], line=0.5); panel = panel + 1
  2680. silence_is_golden = dev.off()
  2681. }
  2682. ## Figure S8 - more analyses about dose-response PD/PK ####
  2683. if ('figure-s8'=='figure-s8') {
  2684. tell_user('done.\nCreating Figure S8...')
  2685. png('display_items/figure-s08.png',width=6.5*resx,height=2.5*resx,res=resx)
  2686. par(mfrow = c(1,3))
  2687. panel = 1
  2688. par(mar=c(3,3.5,2,2))
  2689. xlims = c(0.7, 500)
  2690. xats = rep(2:9, 4) * rep(10^(0:3),each=8)
  2691. xbigs = 10^(0:3)
  2692. xlabs = nmol_to_ug(c(0.2, 1, 5))
  2693. xlablabs = xlabs
  2694. ylims = c(0, 1.25)
  2695. yats = 0:6/4
  2696. ybigs = 0:2/2
  2697. ybiglabs = percent(0:2/2)
  2698. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i', log='x')
  2699. abline(h=1, lty=3)
  2700. axis(side=1, at=xbigs, tck=-0.05, labels=NA)
  2701. axis(side=1, at=xats, tck=-0.02, labels=NA)
  2702. axis(side=1, at=pdpk_smry$pseudo_ug, lwd=0, line=-0.5, labels=pdpk_smry$dose_ug, cex.axis=0.8)
  2703. mtext(side=1, line=1.5, text='dose (µg)', cex=0.8)
  2704. mtext(side=2, line=2.25, text=expression(residual~italic(PRNP)), cex=0.7)
  2705. axis(side=2, at=ylims, lwd.ticks=0, labels=NA)
  2706. axis(side=2, at=yats, tck=-0.02, labels=NA)
  2707. axis(side=2, at=ybigs, tck=-0.05, labels=NA)
  2708. axis(side=2, at=ybigs, lwd=0, labels=ybiglabs, las=2, line=-0.25, cex.axis=0.8)
  2709. axis.break(axis=1, breakpos=1.5, style='slash')
  2710. points(pdpk$pseudo_ug, pdpk$residual, pch=19, col=alpha(pdpk$color_dose, ci_alpha))
  2711. barlogwidth = 1.3
  2712. segments(x0=pdpk_smry$pseudo_ug/barlogwidth,
  2713. x1=pdpk_smry$pseudo_ug*barlogwidth,
  2714. y0=pdpk_smry$pd_mean, col=pdpk_smry$color_dose, lwd=2)
  2715. arrows(x0=pdpk_smry$pseudo_ug, y0=pdpk_smry$pd_l95, y1=pdpk_smry$pd_u95, code=3, angle=90, length=0.05, col=pdpk_smry$color_dose)
  2716. par(xpd=T)
  2717. text(pdpk_smry$pseudo_ug, pdpk_smry$pd_mean+0.05, pos=4, col='#000000', cex=0.6, labels=paste0(' ',percent(pdpk_smry$pd_mean,digits=1)))
  2718. par(xpd=F)
  2719. m = drm(residual ~ dose_ug, data=pdpk, fct=LL.4(fixed=c(b=NA,c=0,d=1,e=NA)))
  2720. x = 2:500
  2721. y = predict(m, newdata=data.frame(dose_ug=x))
  2722. pdpk_smry %>% filter(dose_ug > 0) %>% slice(1) %>% pull(color_dose) -> active_color
  2723. points(x, y, col=active_color, type='l', lwd=0.5)
  2724. mtext(side=3, adj=-0.0, text=LETTERS[panel], line=0.5); panel = panel + 1
  2725. par(mar=c(3,3.5,2,2))
  2726. xlims = c(0.7, 500)
  2727. xats = rep(2:9, 4) * rep(10^(0:3),each=8)
  2728. xbigs = 10^(0:3)
  2729. xlabs = nmol_to_ug(c(0.2, 1, 5))
  2730. xlablabs = xlabs
  2731. ylims = c(7, 20000)
  2732. yats = rep(2:9, 6) * rep(10^(0:5),each=8)
  2733. ybigs = 10^(0:5)
  2734. ybiglabs = gsub(' ','\n',c('1 ng/g','10 ng/g','100 ng/g','1 µg/g','10 µg/g','100 µg/g'))
  2735. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i', log='xy')
  2736. abline(h=1, lty=3)
  2737. axis(side=1, at=xbigs, tck=-0.05, labels=NA)
  2738. axis(side=1, at=xats, tck=-0.02, labels=NA)
  2739. axis(side=1, at=pdpk_smry$pseudo_ug, lwd=0, line=-0.5, labels=pdpk_smry$dose_ug, cex.axis=0.8)
  2740. mtext(side=1, line=1.5, text='dose (µg)', cex=0.8)
  2741. mtext(side=2, line=2.5, text='drug accumulation', cex=0.7)
  2742. axis(side=2, at=ylims, lwd.ticks=0, labels=NA)
  2743. axis(side=2, at=yats, tck=-0.02, labels=NA)
  2744. axis(side=2, at=ybigs, tck=-0.05, labels=NA)
  2745. axis(side=2, at=ybigs, lwd=0, labels=ybiglabs, las=2, line=-0.25, cex.axis=0.8)
  2746. axis.break(axis=1, breakpos=1.5, style='slash')
  2747. abline(h=pdpk_smry$pk_llq[1], lty=3)
  2748. mtext(side=4, at=pdpk_smry$pk_llq[1], text='LLQ', cex=0.6, las=2)
  2749. points(pdpk$pseudo_ug, pdpk$plotconc_ng_g, pch=19, col=alpha(pdpk$color_dose, ci_alpha))
  2750. barlogwidth = 1.3
  2751. segments(x0=pdpk_smry$pseudo_ug/barlogwidth,
  2752. x1=pdpk_smry$pseudo_ug*barlogwidth,
  2753. y0=pdpk_smry$pk_mean, col=pdpk_smry$color_dose, lwd=2)
  2754. arrows(x0=pdpk_smry$pseudo_ug, y0=pdpk_smry$pk_l95, y1=pdpk_smry$pk_u95, code=3, angle=90, length=0.05, col=pdpk_smry$color_dose)
  2755. m = lm(log(concentration_ng_g) ~ log(dose_ug), data=pdpk %>% filter(dose_ug > 0))
  2756. x = 2:500
  2757. y = exp(predict(m, newdata=data.frame(dose_ug=x)))
  2758. pdpk_smry %>% filter(dose_ug > 0) %>% slice(1) %>% pull(color_dose) -> active_color
  2759. points(x, y, col=active_color, type='l', lwd=0.5)
  2760. mtext(side=3, adj=-0.0, text=LETTERS[panel], line=0.5); panel = panel + 1
  2761. par(mar=c(3,3.5,2,2))
  2762. xlims = c(0.7, 500)
  2763. xats = rep(2:9, 4) * rep(10^(0:3),each=8)
  2764. xbigs = 10^(0:3)
  2765. xlabs = nmol_to_ug(c(0.2, 1, 5))
  2766. xlablabs = xlabs
  2767. ylims = c(0, .08)
  2768. yats = seq(0, .1, .005)
  2769. ybigs = seq(0, .1, .01)
  2770. ybiglabs = percent(ybigs)
  2771. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i', log='x')
  2772. abline(h=1, lty=3)
  2773. axis(side=1, at=xbigs, tck=-0.05, labels=NA)
  2774. axis(side=1, at=xats, tck=-0.02, labels=NA)
  2775. axis(side=1, at=pdpk_smry$pseudo_ug, lwd=0, line=-0.5, labels=pdpk_smry$dose_ug, cex.axis=0.8)
  2776. mtext(side=1, line=1.5, text='dose (µg)', cex=0.8)
  2777. mtext(side=2, line=2.25, text='dose retained in brain (%)', cex=0.7)
  2778. axis(side=2, at=ylims, lwd.ticks=0, labels=NA)
  2779. axis(side=2, at=yats, tck=-0.02, labels=NA)
  2780. axis(side=2, at=ybigs, tck=-0.05, labels=NA)
  2781. axis(side=2, at=ybigs, lwd=0, labels=ybiglabs, las=2, line=-0.25, cex.axis=0.8)
  2782. axis.break(axis=1, breakpos=1.5, style='slash')
  2783. abline(h=pdpk_smry$pk_llq[1], lty=3)
  2784. mtext(side=4, at=pdpk_smry$pk_llq[1], text='LLQ', cex=0.6, las=2)
  2785. points(pdpk$pseudo_ug, pdpk$dose_retained, pch=19, col=alpha(pdpk$color_dose, ci_alpha))
  2786. barlogwidth = 1.3
  2787. segments(x0=pdpk_smry$pseudo_ug/barlogwidth,
  2788. x1=pdpk_smry$pseudo_ug*barlogwidth,
  2789. y0=pdpk_smry$retained_mean, col=pdpk_smry$color_dose, lwd=2)
  2790. arrows(x0=pdpk_smry$pseudo_ug, y0=pdpk_smry$retained_l95, y1=pdpk_smry$retained_u95, code=3, angle=90, length=0.05, col=pdpk_smry$color_dose)
  2791. # m = lm(dose_retained ~ dose_ug, data=pdpk %>% filter(dose_ug > 0))
  2792. # summary(m) # marginal, P=0.0379 and small effect size
  2793. mtext(side=3, adj=-0.0, text=LETTERS[panel], line=0.5); panel = panel + 1
  2794. pdpk %>%
  2795. select(study_id, animal, genotype, sex, days_harvest, dose_ug, residual, concentration_ng_g, lloq_ng_g, dose_retained) -> pdpk_out
  2796. write_supp_table(pdpk_out, 'PD/PK in humanized mouse, individual.')
  2797. pdpk_smry %>%
  2798. select(-color_tx, -color_dose) -> pdpk_smry_out
  2799. write_supp_table(pdpk_smry_out, 'PD/PK in humanized mouse, summarized.')
  2800. silence_is_golden = dev.off()
  2801. }
  2802. xes %>%
  2803. distinct(tx, dose_dio, dosing_regimen) %>%
  2804. mutate(offset = row_number()) %>%
  2805. mutate(offset = (offset - mean(offset))/(n()+1)) -> offsets
  2806. undetermined_ct = 40
  2807. max_interpretable_ct = 35
  2808. qpcr %>%
  2809. filter(study_id=='CMR-3164') %>%
  2810. inner_join(study, by=c('sample_id'='animal','study_id')) %>%
  2811. rename(animal = sample_id) %>%
  2812. filter(!grepl('noCB',sample_group)) %>%
  2813. mutate(region = gsub('.*_','',sample_group)) %>%
  2814. group_by(region) %>%
  2815. mutate(target_ct = suppressWarnings(replace_na(as.numeric(target_ct),undetermined_ct)),
  2816. control_ct = suppressWarnings(replace_na(as.numeric(control_ct),undetermined_ct))) %>%
  2817. filter(target_ct <= max_interpretable_ct,
  2818. control_ct <= max_interpretable_ct) %>%
  2819. mutate(control_delta_ct = mean(target_ct[tx=='none'] - control_ct[tx=='none'])) %>%
  2820. ungroup() %>%
  2821. mutate(twoddct = 2^(control_delta_ct-(target_ct-control_ct))) %>%
  2822. group_by(animal, region, tx, dose_dio, dosing_regimen) %>%
  2823. summarize(.groups='keep',
  2824. delta_ct = mean(target_ct - control_ct),
  2825. cv = sd(twoddct)/mean(twoddct)) %>%
  2826. ungroup() %>%
  2827. filter(cv < 1.00) %>% # require %CV < 100%
  2828. group_by(region) %>%
  2829. mutate(control_delta_ct = mean(delta_ct[tx=='none'])) %>%
  2830. mutate(twoddct = 2^(control_delta_ct - delta_ct)) %>% # now re-calculate twoddct AGAIN with the high-CV exclusions in place
  2831. mutate(residual = twoddct / mean(twoddct[tx=='none'])) %>% # and normalize to mean of control group
  2832. ungroup() %>%
  2833. mutate(region = case_when(region=='Th' ~ 'Thal', TRUE ~ region)) %>%
  2834. inner_join(region_meta, by='region') %>%
  2835. rename(region_x = x) %>%
  2836. inner_join(offsets, by=c('tx','dose_dio','dosing_regimen'), relationship='many-to-many') %>%
  2837. mutate(x = region_x + offset) %>%
  2838. inner_join(meta %>% select(tx, color, display_tx), by='tx') %>%
  2839. mutate(y = max(region_x) - region_x - offset) -> repeatdose_qpcr
  2840. repeatdose_qpcr %>%
  2841. group_by(region, y, x, region_x, offset, display_tx, color, dose_dio, dosing_regimen) %>%
  2842. summarize(.groups='keep',
  2843. n = n(),
  2844. mean = mean(residual),
  2845. l95 = lower(residual),
  2846. u95 = upper(residual)) %>%
  2847. ungroup() %>%
  2848. mutate(fulldisp = case_when(display_tx=='none' ~ 'none',
  2849. TRUE ~ paste(nmol_to_ug(dose_dio), 'µg day', dosing_regimen))) -> repeatdose_qpcr_smry
  2850. #
  2851. # par(mar=c(2,4,2,1))
  2852. # xlims = range(repeatdose_qpcr_smry$x) + c(-0.5, 0.5)
  2853. # ylims = range(0, 2.5)
  2854. # yats=0:6/4
  2855. # ybigs=0:3/2
  2856. # ybiglabs=percent(ybigs)
  2857. # plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i')
  2858. # axis(side=1, at=xlims, labels=NA, lwd.ticks=0)
  2859. # par(xpd=T)
  2860. # text(x=region_meta$x, y=rep(-0.05, nrow(region_meta)), labels=region_meta$region, srt=45, adj=1)
  2861. # par(xpd=F)
  2862. # axis(side=2, at=yats, tck = -0.02, labels=NA)
  2863. # axis(side=2, at=ybigs, tck = -0.05, labels=NA)
  2864. # axis(side=2, at=ybigs, lwd=0, labels=ybiglabs, las=2, line=-0.5)
  2865. # mtext(side=2, line=2.75, text='residual Prnp', cex=0.8)
  2866. # abline(h=1, lty=3)
  2867. # barwidth=1/6
  2868. # rect(xleft=repeatdose_qpcr_smry$x - barwidth/2, xright=repeatdose_qpcr_smry$x + barwidth/2, ybottom=rep(0, nrow(repeatdose_qpcr_smry)), ytop=repeatdose_qpcr_smry$mean, col=alpha(repeatdose_qpcr_smry$color, ci_alpha), border=NA)
  2869. # arrows(x0=repeatdose_qpcr_smry$x, y0=repeatdose_qpcr_smry$l95, y1=repeatdose_qpcr_smry$u95, code=3, angle=90, length=0.05, col=repeatdose_qpcr_smry$color)
  2870. # points(x=repeatdose_qpcr$x, y=pmin(repeatdose_qpcr$residual, max(ylims)), pch=21, col=repeatdose_qpcr$color, bg='#FFFFFF', cex=0.5)
  2871. ## Figure S10 - other miscellanea ####
  2872. if ('figure-s10'=='figure-s10') {
  2873. tell_user('done.\nCreating Figure S10...')
  2874. png('display_items/figure-s10.png',width=3.25*resx,height=6.0*resx,res=resx)
  2875. layout_matrix = matrix(c(1,1,
  2876. 1,1,
  2877. 2,2), nrow=3, byrow=T)
  2878. layout(layout_matrix)
  2879. panel =1
  2880. # transpose x & y
  2881. par(mar=c(3,11,2,3))
  2882. ylims = range(repeatdose_qpcr_smry$y) + c(-0.5, 0.5)
  2883. xlims = range(0, 1.5)
  2884. xats=0:6/4
  2885. xbigs=0:3/2
  2886. xbiglabs= c('0%','50%','100%','≥150%') # percent(xbigs)
  2887. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i')
  2888. axis(side=2, at=ylims, labels=NA, lwd.ticks=0)
  2889. region_meta$y = max(region_meta$x) - region_meta$x
  2890. mtext(side=2, at=region_meta$y, text=region_meta$region, las=2, line=8, cex=0.9)
  2891. mtext(side=2, at=repeatdose_qpcr_smry$y, text=repeatdose_qpcr_smry$fulldisp, las=2, line=0.25, cex=0.5)
  2892. axis(side=1, at=xats, tck = -0.02, labels=NA)
  2893. axis(side=1, at=xbigs, tck = -0.05, labels=NA)
  2894. axis(side=1, at=xbigs, lwd=0, labels=xbiglabs, line=-0.5)
  2895. mtext(side=1, line=1.6, text=expression(residual~italic(PRNP)), cex=0.8)
  2896. abline(v=1, lty=3)
  2897. abline(v=.25, lty=3, lwd=0.375)
  2898. barwidth=1/6
  2899. rect(ybottom=repeatdose_qpcr_smry$y - barwidth/2, ytop=repeatdose_qpcr_smry$y + barwidth/2, xleft=rep(0, nrow(repeatdose_qpcr_smry)), xright=repeatdose_qpcr_smry$mean, col=alpha(repeatdose_qpcr_smry$color, ci_alpha), border=NA)
  2900. arrows(y0=repeatdose_qpcr_smry$y, x0=repeatdose_qpcr_smry$l95, x1=repeatdose_qpcr_smry$u95, code=3, angle=90, length=0.03, col=repeatdose_qpcr_smry$color)
  2901. points(y=repeatdose_qpcr$y, x=pmin(repeatdose_qpcr$residual, max(xlims)), pch=21, col=repeatdose_qpcr$color, bg='#FFFFFF', cex=0.5)
  2902. mtext(side=3, adj=-0.0, text=LETTERS[panel], line=0.5); panel = panel + 1
  2903. write_supp_table(repeatdose_qpcr_smry, 'Regional qPCR analysis for 2439-s4 repeat dose.')
  2904. mouse_regional = c('CMR-1656')
  2905. qpcr %>%
  2906. filter(study_id %in% mouse_regional) %>%
  2907. filter(target=='PRNP') %>%
  2908. group_by(study_id, qpcr_id, region, biorep, sample_group) %>%
  2909. summarize(.groups='keep',
  2910. n_techreps = n(),
  2911. mean_twoddct = mean(twoddct)) %>%
  2912. ungroup() %>%
  2913. group_by(study_id, qpcr_id, region) %>%
  2914. mutate(residual = mean_twoddct / mean(mean_twoddct[sample_group %in% c('saline','PBS')])) %>%
  2915. ungroup() -> regional_qpcr
  2916. tx_compared_by_qpcr = tibble(tx_on_qpcr_plate=c('1682-exNA','saline'),
  2917. tx = c('1682-exNA','saline'),
  2918. display_tx = c('1682-s4','saline'),
  2919. x_offset = c(0.2, -0.2))
  2920. tx_compared_by_qpcr$color = meta$color[match(tx_compared_by_qpcr$tx, meta$tx)]
  2921. region_meta = tibble(region=c("HP", "PFC", "VC", "Str", "Thal", "CB"),
  2922. x = 1:6)
  2923. regional_qpcr %>%
  2924. inner_join(tx_compared_by_qpcr, by=c('sample_group'='tx_on_qpcr_plate')) %>%
  2925. select(tx, region, residual, x_offset, color) %>%
  2926. inner_join(region_meta, by='region') -> regional_indivs
  2927. regional_indivs %>%
  2928. group_by(tx, region, x, x_offset, color) %>%
  2929. summarize(.groups='keep',
  2930. n=n(),
  2931. mean = mean(residual),
  2932. l95 = lower(residual),
  2933. u95 = upper(residual)) %>%
  2934. ungroup() -> regional_smry
  2935. write_supp_table(regional_smry, 'Regional qPCR analysis for 1682-s4.')
  2936. par(mar=c(2,4,2,3))
  2937. xlims = range(region_meta$x) + c(-0.5, 0.5)
  2938. ylims = range(0, 1.5)
  2939. yats=0:6/4
  2940. ybigs=0:3/2
  2941. ybiglabs=percent(ybigs)
  2942. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i')
  2943. axis(side=1, at=xlims, labels=NA, lwd.ticks=0)
  2944. par(xpd=T)
  2945. text(x=region_meta$x, y=rep(-0.05, nrow(region_meta)), labels=region_meta$region, srt=45, adj=1)
  2946. par(xpd=F)
  2947. axis(side=2, at=yats, tck = -0.02, labels=NA)
  2948. axis(side=2, at=ybigs, tck = -0.05, labels=NA)
  2949. axis(side=2, at=ybigs, lwd=0, labels=ybiglabs, las=2, line=-0.5)
  2950. mtext(side=2, line=2.75, text=expression(residual~italic(Prnp)), cex=0.8)
  2951. abline(h=1, lty=3)
  2952. abline(h=.25, lty=3, lwd=0.375)
  2953. barwidth=0.4
  2954. rect(xleft=regional_smry$x + regional_smry$x_offset - barwidth/2, xright=regional_smry$x + regional_smry$x_offset + barwidth/2, ybottom=rep(0, nrow(regional_smry)), ytop=regional_smry$mean, col=alpha(regional_smry$color, ci_alpha), border=NA)
  2955. arrows(x0=regional_smry$x + regional_smry$x_offset, y0=regional_smry$l95, y1=regional_smry$u95, code=3, angle=90, length=0.05, col=regional_smry$color)
  2956. points(x=regional_indivs$x + regional_indivs$x_offset, y=pmin(regional_indivs$residual, max(ylims)), pch=21, col=regional_indivs$color, bg='#FFFFFF', cex=0.5)
  2957. par(xpd=T)
  2958. legend(x=6, y=1.5, tx_compared_by_qpcr$display_tx, col=alpha(tx_compared_by_qpcr$color,ci_alpha), pch=15, bty='n', cex=0.8)
  2959. par(xpd=F)
  2960. mtext(side=3, adj=-0.0, text=LETTERS[panel], line=0.5); panel = panel + 1
  2961. silence_is_golden = dev.off()
  2962. }
  2963. ### end Figure S9 ####
  2964. ## Figure S6 - ELISA QC ####
  2965. resx=300
  2966. png('display_items/figure-s06.png',width=5*resx,height=5*resx,res=resx)
  2967. tell_user('done.\nCreating Figure S6...')
  2968. elisa_llq = 0.05
  2969. qc_meta = tibble(qc=c('MoNeg','MoPosLo','MoPosMid','MoPosHi'),
  2970. color = c('#AA2222','#AA22AA','#2222AA','#222222'),
  2971. qcrank = 4:1,
  2972. expected = c(0, .1, .5, 1))
  2973. llq_col = '#BBBBBB'
  2974. elisa_qc = read_tsv('data/analytic/elisa_qc.tsv', col_types=cols()) %>%
  2975. mutate(platerank = dense_rank(plate)) %>%
  2976. inner_join(qc_meta, by='qc')
  2977. elisa_qc %>%
  2978. distinct(platerank, plate, study_id) %>%
  2979. mutate(disp = paste0('plate ',plate,' study ',study_id)) -> elisa_qc_xes
  2980. xlims = range(elisa_qc$platerank) + c(-1,1)
  2981. ylims = c(0, 1.25)
  2982. par(mar=c(7,4,1,8))
  2983. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i')
  2984. axis(side=1, at=range(elisa_qc$platerank), lwd.ticks=0, labels=NA)
  2985. mtext(side=1, at=elisa_qc_xes$platerank, text=elisa_qc_xes$disp, las=2, cex=0.6)
  2986. axis(side=2, at=0:6/4, labels=NA)
  2987. axis(side=2, at=0:6/4, labels=percent(0:6/4), line=-0.5, las=2, lwd=0)
  2988. mtext(side=2, line=2.5, text='PrP (% of high QC)')
  2989. elisa_qc %>%
  2990. filter(qc=='MoPosHi') %>%
  2991. distinct(platerank, plate, llqrel) -> llqs
  2992. #points(x=llqs$platerank, y=llqs$llqrel, type='l', lty=3, col=qc_meta$color[qc_meta$qc=='MoNeg'])
  2993. polygon(x=c(llqs$platerank, rev(llqs$platerank)), y=c(llqs$llqrel,rep(0,nrow(llqs))), col=llq_col, border=NA)
  2994. for (this_qc in qc_meta$qc) {
  2995. subs = elisa_qc %>% filter(qc %in% this_qc)
  2996. points(subs$platerank, subs$qcrel, pch=20, cex=0.5, col=subs$color)
  2997. subs %>%
  2998. group_by(platerank, plate, color) %>%
  2999. summarize(.groups='keep',
  3000. mean=mean(qcrel, na.rm=T)) %>%
  3001. ungroup() -> subsmry
  3002. points(subsmry$platerank, subsmry$mean, type='l', lwd=1, col=subsmry$color)
  3003. }
  3004. abline(h=.5, lty=3, col=qc_meta$color[qc_meta$qc=='MoPosMid'])
  3005. abline(h=.1, lty=3, col=qc_meta$color[qc_meta$qc=='MoPosLo'])
  3006. mtext(side=4, at=0.5, las=2, col=qc_meta$color[qc_meta$qc=='MoPosMid'], text='expected mid QC', cex=0.7)
  3007. mtext(side=4, at=0.1, las=2, col=qc_meta$color[qc_meta$qc=='MoPosLo'], text='expected low QC', cex=0.7)
  3008. mtext(side=4, at=0.06, las=2, col=qc_meta$color[qc_meta$qc=='MoNeg'], text='negative QC', cex=0.7)
  3009. mtext(side=4, at=0.02, las=2, col=llq_col, text='plate-specific LLQ', cex=0.7)
  3010. silence_is_golden = dev.off()
  3011. elisa_qc %>%
  3012. filter(!is.na(qcrel)) %>%
  3013. group_by(platerank, plate, study_id, qc) %>%
  3014. summarize(.groups='keep',
  3015. mean_rel=mean(qcrel)) %>%
  3016. ungroup() -> elisa_qc_platemeans
  3017. elisa_qc_platemeans %>%
  3018. filter(!is.na(mean_rel)) %>%
  3019. inner_join(qc_meta, by='qc') %>%
  3020. group_by(qcrank, qc, expected) %>%
  3021. summarize(.groups='keep',
  3022. n=n(),
  3023. min=min(mean_rel),
  3024. mean=mean(mean_rel),
  3025. max=max(mean_rel),
  3026. median = median(mean_rel),
  3027. q25 = quantile(mean_rel, .25),
  3028. q75 = quantile(mean_rel, .75)) %>%
  3029. ungroup() %>%
  3030. arrange(qcrank) %>%
  3031. select(-qcrank) -> elisa_qc_summary_stats
  3032. write_supp_table(elisa_qc_platemeans %>%
  3033. rename(relative_to_hi_qc = mean_rel), 'ELISA QC performance by plate.')
  3034. write_supp_table(elisa_qc_summary_stats, 'ELISA QC performance summarized across all plates.')
  3035. ## Figure S9 - durability for 2439-s2 & s5 ####
  3036. if ('figure-s9'=='figure-s9') {
  3037. tell_user('done.\nCreating Figure S9...')
  3038. png('display_items/figure-s09.png',width=6.5*resx,height=2.5*resx,res=resx)
  3039. layout_matrix = matrix(1:2, nrow=1, byrow=T)
  3040. layout(layout_matrix)
  3041. panel = 1
  3042. par(mar=c(3,4,3,1))
  3043. durability_study1 = c('CMR-2371') # 'CMR-2198',
  3044. process_elisas(durability_study1, control_group=c('none')) %>%
  3045. arrange(dose_dio, days_harvest, tx) %>%
  3046. filter(days_harvest %in% c(0,34,120)) %>%
  3047. inner_join(meta, by='tx') %>%
  3048. filter(display_tx %in% c('2439-s5','none','-')) %>%
  3049. mutate(x = days_harvest) -> proc
  3050. xlims = c(0,150)
  3051. xbiglabs = xbigs = c(34, 120)
  3052. xats = sort(c(xbigs, c(0,2,3,5)*30.44))
  3053. ylims = c(0, 1.25)
  3054. ybigs = 0:3/2
  3055. yats = 0:6/4
  3056. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i')
  3057. axis(side=1, at=xbigs, tck=-0.05, labels=NA)
  3058. axis(side=1, at=xats, tck=-0.02, labels=NA)
  3059. axis(side=1, at=xbigs, lwd=0, line=-0.75, labels=xbiglabs, cex=0.8)
  3060. axis(side=2, at=yats, labels=NA, tck=-0.02)
  3061. axis(side=2, at=ybigs, labels=NA, tck=-0.05)
  3062. axis(side=2, at=ybigs, labels=percent(ybigs), line=-0.75, lwd=0, las=2, cex=0.8)
  3063. mtext(side=2, line=2.25, text='residual PrP', cex=0.8)
  3064. abline(h=1, lty=3)
  3065. proc %>%
  3066. group_by(x, display_tx, color) %>%
  3067. summarize(.groups='keep',
  3068. n = n(),
  3069. mean = mean(rel),
  3070. l95 = lower(rel),
  3071. u95 = upper(rel),
  3072. max = max(rel)) %>%
  3073. ungroup() -> proc_smry
  3074. barwidth = 0.4
  3075. segments(x0=proc_smry$x-barwidth, x1=proc_smry$x+barwidth, y0=proc_smry$mean, col=proc_smry$color, lwd=1.5)
  3076. arrows(x0=proc_smry$x, y0=proc_smry$l95, y1=proc_smry$u95, code=3, angle=90, length=0.05, col=proc_smry$color, lwd=1.5)
  3077. points(x=proc$x, y=proc$rel, pch=20, col=alpha(proc$color,ci_alpha))
  3078. proc_smry %>%
  3079. filter(display_tx != 'none') -> subs
  3080. par(xpd=T)
  3081. text(x=subs$x, y=subs$mean, pos=4, col=subs$color, labels=paste0(' ',percent(subs$mean, digits=1)), cex=0.6)
  3082. par(xpd=F)
  3083. mtext(side=3, line=1, text=subs$display_tx[1], cex=0.8, col=subs$color[1])
  3084. mtext(side=3, line=0, text='single 348 µg dose', cex=0.8)
  3085. mtext(side=1, line=1, text='days post-dose', cex=0.8)
  3086. mtext(side=3, adj=-0.0, text=LETTERS[panel], line=0.5); panel = panel + 1
  3087. durability_study2 = c('CMR-2198')
  3088. process_elisas(durability_study2, control_group=c('-')) %>%
  3089. arrange(dose_dio, days_harvest, tx) %>%
  3090. filter(days_harvest %in% c(0, 29, 91, 180)) %>%
  3091. inner_join(meta, by='tx') %>%
  3092. mutate(display_tx = gsub(' fixed tail','',display_tx)) %>%
  3093. filter(grepl('s2|none', display_tx)) %>%
  3094. mutate(x = days_harvest) -> proc
  3095. xlims = c(0,210)
  3096. xbiglabs = xbigs = c(29, 91, 180)
  3097. xats = sort(c(xbigs, c(0,2,4,5,7)*30.44))
  3098. ylims = c(0, 1.25)
  3099. ybigs = 0:3/2
  3100. yats = 0:6/4
  3101. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i')
  3102. axis(side=1, at=xbigs, tck=-0.05, labels=NA)
  3103. axis(side=1, at=xats, tck=-0.02, labels=NA)
  3104. axis(side=1, at=xbigs, lwd=0, line=-0.75, labels=xbiglabs, cex=0.8)
  3105. axis(side=2, at=yats, labels=NA, tck=-0.02)
  3106. axis(side=2, at=ybigs, labels=NA, tck=-0.05)
  3107. axis(side=2, at=ybigs, labels=percent(ybigs), line=-0.75, lwd=0, las=2, cex=0.8)
  3108. mtext(side=2, line=2.25, text='residual PrP', cex=0.8)
  3109. abline(h=1, lty=3)
  3110. proc %>%
  3111. group_by(x, display_tx, color) %>%
  3112. summarize(.groups='keep',
  3113. n = n(),
  3114. mean = mean(rel),
  3115. l95 = lower(rel),
  3116. u95 = upper(rel),
  3117. max = max(rel)) %>%
  3118. ungroup() -> proc_smry
  3119. barwidth = 0.4
  3120. segments(x0=proc_smry$x-barwidth, x1=proc_smry$x+barwidth, y0=proc_smry$mean, col=proc_smry$color, lwd=1.5)
  3121. arrows(x0=proc_smry$x, y0=proc_smry$l95, y1=proc_smry$u95, code=3, angle=90, length=0.05, col=proc_smry$color, lwd=1.5)
  3122. points(x=proc$x, y=proc$rel, pch=20, col=alpha(proc$color,ci_alpha))
  3123. proc_smry %>%
  3124. filter(display_tx != 'none') -> subs
  3125. par(xpd=T)
  3126. text(x=subs$x, y=subs$mean, pos=4, col=subs$color, labels=paste0(' ',percent(subs$mean, digits=1)), cex=0.6)
  3127. par(xpd=F)
  3128. mtext(side=3, line=1, text=subs$display_tx[1], cex=0.8, col=subs$color[1])
  3129. mtext(side=3, line=0, text='single 174 µg dose', cex=0.8)
  3130. mtext(side=1, line=1, text='days post-dose', cex=0.8)
  3131. mtext(side=3, adj=-0.0, text=LETTERS[panel], line=0.5); panel = panel + 1
  3132. silence_is_golden = dev.off()
  3133. }
  3134. ### end Figure S8 ####
  3135. ## Figure 7 ####
  3136. if ('figure-7'=='figure-7') {
  3137. tell_user('done.\nCreating Figure 7...')
  3138. resx=300
  3139. png('display_items/figure-7.png' ,width=6.5*resx,height=4*resx,res=resx)
  3140. par(mfrow = c(1,2))
  3141. panel = 1
  3142. #### Dog 28 day BioA ####
  3143. dog_tissue_raw = read_tsv('data/ind_enabling/BioA_dog_tissue.tsv', col_types=cols()) %>%
  3144. clean_names() %>%
  3145. mutate(nominal_timepoint = nominal_timepoint_day - 1) %>%
  3146. rename(lloq = lloq_ng_g) %>%
  3147. rename(concentration = concentration_ng_g)
  3148. dog_plasma_raw = read_tsv('data/ind_enabling/BioA_dog_plasma.tsv', col_types=cols()) %>%
  3149. clean_names() %>%
  3150. mutate(nominal_timepoint = nominal_time_point_hours/24) %>%
  3151. rename(lloq = lloq_ng_m_l) %>%
  3152. rename(concentration = concentration_ng_m_l) %>%
  3153. filter(!is.na(run_id))
  3154. dog_csf_raw = read_tsv('data/ind_enabling/BioA_dog_CSF.tsv', col_types=cols()) %>%
  3155. clean_names() %>%
  3156. rename(run_id = axolabs_run_id) %>%
  3157. mutate(nominal_timepoint = case_when(core_vs_recovery == 'core' ~ 1,
  3158. core_vs_recovery == 'recovery' ~ 28)) %>%
  3159. rename(lloq = lloq_ng_m_l) %>%
  3160. rename(concentration = concentration_ng_m_l)
  3161. # colnames(dog_plasma_raw)
  3162. # colnames(dog_csf_raw)
  3163. # colnames(dog_tissue_raw)
  3164. keep_colnames = c('run_id', 'sample_no', 'animal_id',
  3165. 'group', 'dose_mg', 'matrix', 'nominal_timepoint',
  3166. 'lloq','concentration')
  3167. rbind(dog_plasma_raw[,keep_colnames],
  3168. dog_csf_raw[,keep_colnames],
  3169. dog_tissue_raw[,keep_colnames]) %>%
  3170. mutate(concentration_ug_g = case_when(concentration == 'BQL' ~ lloq/1000,
  3171. TRUE ~ suppressWarnings(as.numeric(gsub(',','',concentration))) / 1000)) %>%
  3172. mutate(lloq_ug_g = lloq / 1000) -> bioa
  3173. bioa -> dog_bioa
  3174. tiss_meta = tibble(matrix = c("Liver", "Kidney", "Spinal Cord, cervical", "Spinal Cord, lumbar",
  3175. "Brain, frontal cortex (BRFC)", "Brain, hippocampus (BRHI)", "Brain, cerebellar cortex",
  3176. "Brain, thalamus (BRTH)", "Brain, caudate (BRCA)", "Brain, putamen (BRPU)"),
  3177. tiss_disp = c("Liver", "Kidney", "Cervical cord", "Lumbar cord",
  3178. "Frontal cortex", "Hippocampus", "Cerebellar cortex",
  3179. "Thalamus", "Caudate", "Putamen"),
  3180. x = 1:10) %>%
  3181. mutate(tiss_y = max(x) - x + 1)
  3182. day_meta = tibble(nominal_timepoint = c(1,28),
  3183. x = 1:2,
  3184. disp = c('1d core','28d recovery')) %>%
  3185. mutate(day_y = 0)
  3186. dose_meta = tibble(dose_mg = c(0,20,60,200),
  3187. x = 1:4,
  3188. color = c('#fbb4b9','#f768a1','#c51b8a','#7a0177')) %>%
  3189. mutate(dose_y = max(x) - x + 1)
  3190. dose_meta -> dog_dose_meta
  3191. bioa %>%
  3192. inner_join(tiss_meta, by='matrix') %>%
  3193. select(-x) %>%
  3194. inner_join(day_meta, by='nominal_timepoint') %>%
  3195. select(-x) %>%
  3196. inner_join(dose_meta, by='dose_mg') %>%
  3197. select(-x) %>%
  3198. mutate(y = tiss_y * 5 + dose_y * 1) %>%
  3199. arrange(desc(y)) -> bioa_anno
  3200. bioa_anno %>%
  3201. group_by(y, matrix, tiss_disp, nominal_timepoint, dose_mg, lloq_ug_g, color) %>%
  3202. summarize(.groups='keep',
  3203. n = n(),
  3204. mean = mean(concentration_ug_g),
  3205. l95 = lower(concentration_ug_g),
  3206. u95 = upper(concentration_ug_g)) %>%
  3207. ungroup() %>%
  3208. mutate(xleft=1e-3) -> bioa_smry
  3209. bioa_anno %>%
  3210. select(animal_id, tiss_disp, dose_mg, nominal_timepoint, concentration_ug_g, lloq_ug_g) -> bioa_anno_out
  3211. bioa_smry %>%
  3212. select(tiss_disp, dose_mg, nominal_timepoint, n, mean_concentration_ug_g = mean, lloq_ug_g) -> bioa_smry_out
  3213. write_supp_table(bioa_anno_out, 'PK measurements in dog, individual animals.')
  3214. write_supp_table(bioa_smry_out, 'PK measurements in dog, summarized.')
  3215. dog_organs = read_csv('data/ind_enabling/dog_organ_weights.csv', col_types=cols()) %>%
  3216. clean_names()
  3217. dog_organs %>%
  3218. select(!matches('percent')) -> dog_organs_out
  3219. dog_organs_out %>%
  3220. summarize(across(matches('_g'), ~ mean(.x, na.rm=T))) %>%
  3221. pivot_longer(matches('_g')) %>%
  3222. mutate(organ = gsub('_.*','',name),
  3223. mean_mass_grams = value) %>%
  3224. select(organ, mean_mass_grams) -> dog_organ_means_out
  3225. write_supp_table(dog_organs_out, 'Body weight and organ weights, individual (dogs).')
  3226. write_supp_table(dog_organ_means_out, 'Body weight and organ weights, mean (dogs).')
  3227. dog_organs %>%
  3228. select(animal_id, brain_weight_g, liver_weight_g, kidneys_weight_g) %>%
  3229. pivot_longer(cols=-animal_id) %>%
  3230. mutate(meta_tissue = str_to_title(gsub('s?_weight_g','',name))) %>%
  3231. select(animal_id, meta_tissue, mass_grams=value) -> organs_long
  3232. bioa_anno %>%
  3233. mutate(meta_tissue = case_when(tiss_disp=='Liver' ~ 'Liver',
  3234. tiss_disp=='Kidney' ~ 'Kidney',
  3235. TRUE ~ 'Brain')) %>%
  3236. left_join(organs_long, by=c('animal_id','meta_tissue')) %>%
  3237. select(animal_id, dose_mg, nominal_timepoint, matrix, meta_tissue, mass_grams, concentration_ug_g) %>%
  3238. filter(dose_mg > 0) %>%
  3239. mutate(proportion_dose_retained = (mass_grams * concentration_ug_g / 1000)/dose_mg) -> dose_retained_indiv
  3240. dose_retained_indiv %>%
  3241. group_by(meta_tissue, nominal_timepoint) %>%
  3242. summarize(.groups='keep',
  3243. n_animals = length(unique(animal_id)),
  3244. n_regions = length(unique(matrix)),
  3245. mean_proportion_dose_retained = mean(proportion_dose_retained)) %>%
  3246. ungroup() %>%
  3247. arrange(nominal_timepoint, meta_tissue) -> retained_by_organ
  3248. write_supp_table(dose_retained_indiv, 'Proportions of dose administered retained by dose level, tissue, timepoint, and individual animal (dogs).')
  3249. write_supp_table(retained_by_organ, 'Proportions of dose administered retained, means by timepoint and tissue (dogs).')
  3250. dog_retained_by_organ = retained_by_organ
  3251. # now that we've written out supp tables, subset to 28-day for figure
  3252. bioa_anno %>% filter(nominal_timepoint==28) -> bioa_anno
  3253. bioa_smry %>% filter(nominal_timepoint==28) -> bioa_smry
  3254. ic50_col = '#009171'
  3255. xbigs = 10^(-3:3)
  3256. xbiglabs = c('1 ng/g', '10 ng/g', '100 ng/g', '1 µg/g', '10 µg/g', '100 µg/g', '1 mg/g')
  3257. xats = rep(1:9, 7) * 10^rep(-3:3, each=9)
  3258. xlims = c(1e-2, 1e3)
  3259. ylims = range(bioa_smry$y) + c(-1, 1)
  3260. par(mar=c(3,6,3,2))
  3261. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i', log='x')
  3262. axis(side=2, at=ylims, labels=NA, lwd.ticks=0)
  3263. #mtext(side=2, at=bioa_smry$y, text=bioa_smry$dose_mg, las=2, cex=0.4, line=0.2, font=2)
  3264. axis(side=1, at=xbigs, tck=-0.05, labels=NA)
  3265. axis(side=1, at=xbigs, lwd=0, labels=gsub(' ','\n',xbiglabs), cex.axis=0.6, line=-0.25)
  3266. axis(side=1, at=xats, tck=-0.02, labels=NA)
  3267. barwidth=1
  3268. rect(xleft=bioa_smry$xleft, xright=bioa_smry$mean, ybottom=bioa_smry$y-barwidth/2, ytop=bioa_smry$y+barwidth/2, col=alpha(bioa_smry$color,.75), border=NA)
  3269. suppressWarnings(arrows(x0=pmax(bioa_smry$l95, min(xlims)), x1=bioa_smry$u95, y0=bioa_smry$y, length=0.025, col=bioa_smry$color, code=3, angle=90))
  3270. points(bioa_anno$concentration_ug_g, bioa_anno$y, col=bioa_anno$color, pch=21, bg='#FFFFFF', cex=0.75)
  3271. points(x=bioa_smry$lloq_ug_g, y=bioa_smry$y, pch='|', col='#7A7A7A')
  3272. mtext(side=1, at=bioa_smry$lloq_ug_g[1], col='#7A7A7A', cex=0.3, text='LLQ', line=-0.5)
  3273. bioa_smry %>%
  3274. group_by(matrix, tiss_disp, nominal_timepoint) %>%
  3275. summarize(.groups='keep', meany = mean(y)) %>%
  3276. ungroup() -> timepoint_tranches
  3277. bioa_smry %>%
  3278. group_by(matrix, tiss_disp) %>%
  3279. summarize(.groups='keep', meany = mean(y)) %>%
  3280. ungroup() -> matrix_tranches
  3281. #mtext(side=2, line=1, las=2, at=timepoint_tranches$meany, text=paste0(timepoint_tranches$nominal_timepoint, 'd'), cex=0.8)
  3282. mtext(side=2, line=0.25, at=matrix_tranches$meany, text=matrix_tranches$tiss_disp, cex=0.7, las=2)
  3283. est_ic50 = dr_out$estimate[dr_out$parameter=='e:(Intercept)'] / 1000 # convert ng/g to ug/g
  3284. abline(v=est_ic50, col=ic50_col, lwd=1)
  3285. mtext(side=3, at=est_ic50, col=ic50_col, cex=0.8, text='est. IC50')
  3286. mtext(side=3, at=0.00005, line=0.25, text=paste0(LETTERS[panel], ' dog'), cex=1.0); panel = panel + 1
  3287. par(xpd=T)
  3288. legend(x=100,y=17, paste0(dose_meta$dose_mg, ' mg'), title='dose', bty='n', col=dose_meta$color, pch=15, cex=0.6)
  3289. par(xpd=F)
  3290. #### Rat 3 day BioA ####
  3291. rat_tissue_raw = read_tsv('data/ind_enabling/BioA_rat_tissue.tsv', col_types=cols()) %>%
  3292. clean_names() %>%
  3293. rename(run_id = axolabs_run_id) %>%
  3294. rename(dose_mg = dose_level_mg) %>%
  3295. mutate(nominal_timepoint = nominal_timepoint_day - 1) %>%
  3296. rename(lloq = lloq_ng_g) %>%
  3297. rename(concentration = concentration_ng_g)
  3298. rat_plasma_raw = read_tsv('data/ind_enabling/BioA_rat_plasma.tsv', col_types=cols()) %>%
  3299. clean_names() %>%
  3300. mutate(nominal_timepoint = nominal_time_point_hours/24) %>%
  3301. rename(lloq = lloq_ng_m_l) %>%
  3302. rename(concentration = concentration_ng_m_l) %>%
  3303. filter(!is.na(run_id))
  3304. rat_csf_raw = read_tsv('data/ind_enabling/BioA_rat_CSF.tsv', col_types=cols()) %>%
  3305. clean_names() %>%
  3306. mutate(nominal_timepoint = case_when(study_day == 'Day 2' ~ 1,
  3307. study_day == 'Day 29' ~ 28)) %>%
  3308. rename(lloq = lloq_ng_m_l) %>%
  3309. rename(concentration = concentration_ng_m_l)
  3310. # colnames(rat_plasma_raw)
  3311. # colnames(rat_csf_raw)
  3312. # colnames(rat_tissue_raw)
  3313. keep_colnames = c('run_id', 'sample_no', 'animal_id',
  3314. 'group', 'dose_mg', 'matrix', 'nominal_timepoint',
  3315. 'lloq','concentration')
  3316. rbind(rat_plasma_raw[,keep_colnames],
  3317. rat_csf_raw[,keep_colnames],
  3318. rat_tissue_raw[,keep_colnames]) %>%
  3319. mutate(concentration_ug_g = case_when(concentration == 'BQL' ~ lloq/1000,
  3320. TRUE ~ suppressWarnings(as.numeric(gsub(',','',concentration))) / 1000)) %>%
  3321. mutate(lloq_ug_g = lloq / 1000) -> bioa
  3322. bioa -> rat_bioa
  3323. tiss_meta = tibble(matrix = c("Liver", "Kidney", "Spinal Cord, cervical", "Spinal Cord, lumbar",
  3324. "Brain, frontal cortex (BRFC)", "Brain, hippocampus (BRHI)",
  3325. "Brain, cerebellar cortex (BRCE)",
  3326. "Brain, thalamus (BRTH)",
  3327. "Brain, caudate-putamen (BRCP)"),
  3328. tiss_disp = c("Liver", "Kidney", "Cervical cord", "Lumbar cord",
  3329. "Frontal cortex", "Hippocampus", "Cerebellar cortex",
  3330. "Thalamus", "Caudate/putamen"),
  3331. x = 1:9) %>%
  3332. mutate(tiss_y = max(x) - x + 1)
  3333. day_meta = tibble(nominal_timepoint = c(3),
  3334. x = 1,
  3335. disp = c('3d')) %>%
  3336. mutate(day_y = 0)
  3337. dose_meta = tibble(dose_mg = c(0,0.3,1,3),
  3338. x = 1:4,
  3339. color = c('#fbb4b9','#f768a1','#c51b8a','#7a0177')) %>%
  3340. mutate(dose_y = max(x) - x + 1)
  3341. dose_meta -> rat_dose_meta
  3342. bioa %>%
  3343. inner_join(tiss_meta, by='matrix') %>%
  3344. select(-x) %>%
  3345. inner_join(day_meta, by='nominal_timepoint') %>%
  3346. select(-x) %>%
  3347. inner_join(dose_meta, by='dose_mg') %>%
  3348. select(-x) %>%
  3349. mutate(y = tiss_y * 5 + dose_y * 1) %>%
  3350. arrange(desc(y)) -> bioa_anno
  3351. bioa_anno %>%
  3352. group_by(y, matrix, tiss_disp, nominal_timepoint, dose_mg, lloq_ug_g, color) %>%
  3353. summarize(.groups='keep',
  3354. n = n(),
  3355. mean = mean(concentration_ug_g),
  3356. l95 = lower(concentration_ug_g),
  3357. u95 = upper(concentration_ug_g)) %>%
  3358. ungroup() %>%
  3359. mutate(xleft=1e-3) -> bioa_smry
  3360. bioa_anno %>%
  3361. select(animal_id, tiss_disp, dose_mg, nominal_timepoint, concentration_ug_g, lloq_ug_g) -> bioa_anno_out
  3362. bioa_smry %>%
  3363. select(tiss_disp, dose_mg, nominal_timepoint, n, mean_concentration_ug_g = mean, lloq_ug_g) -> bioa_smry_out
  3364. write_supp_table(bioa_anno_out, 'PK measurements in rat, individual animals.')
  3365. write_supp_table(bioa_smry_out, 'PK measurements in rat, summarized.')
  3366. rat_organs = read_csv('data/ind_enabling/rat_organ_weights.csv', col_types=cols()) %>%
  3367. clean_names()
  3368. rat_organs %>%
  3369. select(!matches('percent')) %>%
  3370. mutate(across(matches('_g'), ~ suppressWarnings(as.numeric(.x)))) -> rat_organs_out
  3371. rat_organs_out %>%
  3372. summarize(across(matches('_g'), ~ mean(.x, na.rm=T))) %>%
  3373. pivot_longer(matches('_g')) %>%
  3374. mutate(organ = gsub('_.*','',name),
  3375. mean_mass_grams = value) %>%
  3376. select(organ, mean_mass_grams) -> rat_organ_means_out
  3377. write_supp_table(rat_organs_out, 'Body weight and organ weights, individual (rats).')
  3378. write_supp_table(rat_organ_means_out, 'Body weight and organ weights, mean (rats).')
  3379. rat_organs %>%
  3380. select(animal_id, brain_weight_g, liver_weight_g, kidneys_weight_g) %>%
  3381. pivot_longer(cols=-animal_id) %>%
  3382. mutate(meta_tissue = str_to_title(gsub('s?_weight_g','',name))) %>%
  3383. select(animal_id, meta_tissue, mass_grams=value) %>%
  3384. mutate(mass_grams = suppressWarnings(as.numeric(mass_grams))) -> organs_long
  3385. # for rats, unlike dogs, the BioA was done on TK animals for whom body weights were not collected.
  3386. # therefore, we'll use the mean organ weights from in-study animals
  3387. organs_long %>%
  3388. group_by(meta_tissue) %>%
  3389. summarize(.groups='keep', mass_grams = mean(mass_grams, na.rm=T)) %>%
  3390. ungroup() -> mean_rat_organ_weights
  3391. bioa_anno %>%
  3392. mutate(meta_tissue = case_when(tiss_disp=='Liver' ~ 'Liver',
  3393. tiss_disp=='Kidney' ~ 'Kidney',
  3394. TRUE ~ 'Brain')) %>%
  3395. left_join(mean_rat_organ_weights, by=c('meta_tissue')) %>%
  3396. select(animal_id, dose_mg, nominal_timepoint, matrix, meta_tissue, mass_grams, concentration_ug_g) %>%
  3397. filter(dose_mg > 0) %>%
  3398. mutate(proportion_dose_retained = (mass_grams * concentration_ug_g / 1000)/dose_mg) -> dose_retained_indiv
  3399. dose_retained_indiv %>%
  3400. group_by(meta_tissue, nominal_timepoint) %>%
  3401. summarize(.groups='keep',
  3402. n_animals = length(unique(animal_id)),
  3403. n_regions = length(unique(matrix)),
  3404. mean_proportion_dose_retained = mean(proportion_dose_retained)) %>%
  3405. ungroup() %>%
  3406. arrange(nominal_timepoint, meta_tissue) -> retained_by_organ
  3407. write_supp_table(dose_retained_indiv, 'Proportions of dose administered retained by dose level, tissue, timepoint, and individual animal (rats).')
  3408. write_supp_table(retained_by_organ, 'Proportions of dose administered retained, means by timepoint and tissue (rats).')
  3409. rat_retained_by_organ = retained_by_organ
  3410. # now that we've written out supp tables, subset to 3-day for figure
  3411. bioa_anno %>% filter(nominal_timepoint==3) -> bioa_anno
  3412. bioa_smry %>% filter(nominal_timepoint==3) -> bioa_smry
  3413. xbigs = 10^(-3:3)
  3414. xbiglabs = c('1 ng/g', '10 ng/g', '100 ng/g', '1 µg/g', '10 µg/g', '100 µg/g', '1 mg/g')
  3415. xats = rep(1:9, 7) * 10^rep(-3:3, each=9)
  3416. xlims = c(1e-2, 1e3)
  3417. ylims = range(bioa_smry$y) + c(-1, 1)
  3418. par(mar=c(3,6,3,2))
  3419. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i', log='x')
  3420. axis(side=2, at=ylims, labels=NA, lwd.ticks=0)
  3421. #mtext(side=2, at=bioa_smry$y, text=bioa_smry$dose_mg, las=2, cex=0.4, line=0.2, font=2)
  3422. axis(side=1, at=xbigs, tck=-0.05, labels=NA)
  3423. axis(side=1, at=xbigs, lwd=0, labels=gsub(' ','\n',xbiglabs), cex.axis=0.6, line=-0.25)
  3424. axis(side=1, at=xats, tck=-0.02, labels=NA)
  3425. barwidth=1
  3426. rect(xleft=bioa_smry$xleft, xright=bioa_smry$mean, ybottom=bioa_smry$y-barwidth/2, ytop=bioa_smry$y+barwidth/2, col=alpha(bioa_smry$color,.75), border=NA)
  3427. suppressWarnings(arrows(x0=pmax(bioa_smry$l95, min(xlims)), x1=bioa_smry$u95, y0=bioa_smry$y, length=0.025, col=bioa_smry$color, code=3, angle=90))
  3428. points(bioa_anno$concentration_ug_g, bioa_anno$y, col=bioa_anno$color, pch=21, bg='#FFFFFF', cex=0.75)
  3429. points(x=bioa_smry$lloq_ug_g, y=bioa_smry$y, pch='|', col='#7A7A7A')
  3430. mtext(side=1, at=bioa_smry$lloq_ug_g[1], col='#7A7A7A', cex=0.3, text='LLQ', line=-0.5)
  3431. bioa_smry %>%
  3432. group_by(matrix, tiss_disp, nominal_timepoint) %>%
  3433. summarize(.groups='keep', meany = mean(y)) %>%
  3434. ungroup() -> timepoint_tranches
  3435. bioa_smry %>%
  3436. group_by(matrix, tiss_disp) %>%
  3437. summarize(.groups='keep', meany = mean(y)) %>%
  3438. ungroup() -> matrix_tranches
  3439. #mtext(side=2, line=1, las=2, at=timepoint_tranches$meany, text=paste0(timepoint_tranches$nominal_timepoint, 'd'), cex=0.8)
  3440. mtext(side=2, line=0.25, at=matrix_tranches$meany, text=matrix_tranches$tiss_disp, cex=0.7, las=2)
  3441. abline(v=est_ic50, col=ic50_col, lwd=1)
  3442. mtext(side=3, at=est_ic50, col=ic50_col, cex=0.8, text='est. IC50')
  3443. par(xpd=T)
  3444. legend(x=100,y=18, paste0(dose_meta$dose_mg, ' mg'), title='dose', bty='n', col=dose_meta$color, pch=15, cex=0.6)
  3445. par(xpd=F)
  3446. mtext(side=3, at=0.00005, line=0.25, text=paste0(LETTERS[panel], ' rat'), cex=1.0); panel = panel + 1
  3447. silence_is_golden = dev.off()
  3448. }
  3449. ### end Figure 7 ####
  3450. rbind(cbind(dog_retained_by_organ,species='dog'),
  3451. cbind(rat_retained_by_organ,species='rat')) %>%
  3452. select(-n_animals, -n_regions) %>%
  3453. pivot_wider(names_from=c(species,nominal_timepoint), values_from=mean_proportion_dose_retained) -> table_2
  3454. ## Figure S12 - TK & CSF ####
  3455. if ('figure-s12'=='figure-s12') {
  3456. tell_user('done.\nCreating Figure S12...')
  3457. png('display_items/figure-s12.png',width=6.5*resx,height=6.0*resx,res=resx)
  3458. par(mfrow=c(2,2))
  3459. panel = 1
  3460. dog_dose_meta -> dose_meta
  3461. dog_bioa -> bioa
  3462. bioa %>%
  3463. filter(matrix=='Plasma') %>%
  3464. inner_join(dose_meta, by='dose_mg') %>%
  3465. mutate(hours = nominal_timepoint * 24) -> plasma
  3466. plasma %>%
  3467. group_by(dose_mg, color, hours) %>%
  3468. summarize(.groups='keep',
  3469. n=n(),
  3470. mean=mean(concentration_ug_g)) %>%
  3471. ungroup() -> plasma_smry
  3472. dog_organs_out %>%
  3473. summarize(mean(terminal_bw_kg, na.rm=T)) %>%
  3474. pull() -> mean_terminal_bw_kg
  3475. # https://www.merckvetmanual.com/circulatory-system/blood-groups-and-blood-transfusions-in-dogs-and-cats/blood-transfusions-in-dogs-and-cats
  3476. # says 80-90 mL/kg total blood volume, take 85 as a midpoint
  3477. blood_ml_per_kg = 85
  3478. plasma_smry %>%
  3479. filter(dose_mg > 0) %>%
  3480. mutate(proportion_dose_in_blood = blood_ml_per_kg * mean_terminal_bw_kg * mean / 1000 / dose_mg) %>%
  3481. group_by(hours) %>%
  3482. summarize(.groups='keep', estimated_proportion_dose_in_blood = mean(proportion_dose_in_blood)) %>%
  3483. ungroup() -> proportion_dose_in_blood_by_hours
  3484. write_supp_table(plasma, 'Plasma toxicokinetic analysis, dogs, individual.')
  3485. write_supp_table(plasma_smry, 'Plasma toxicokinetic analysis, dogs, summarized.')
  3486. write_supp_table(proportion_dose_in_blood_by_hours, 'Estimated proportion dose in blood, dogs, summarized.')
  3487. xlims = c(0.4, 100)
  3488. xats = unique(plasma$hours)
  3489. ylims = c(0.0008, 100)
  3490. yats = rep(1:9, times=7) * rep(10^(-4:2),each=9)
  3491. ybigs = 10^(-4:2)
  3492. ybiglabs = c('0.1 ng/mL','1 ng/mL','10 ng/mL', '100 ng/mL', '1 µg/mL', '10 µg/mL', '100 µg/mL')
  3493. par(mar=c(3,6,3,1))
  3494. plot(NA, NA, xlim=xlims, ylim=ylims, log='xy', axes=F, ann=F, xaxs='i', yaxs='i')
  3495. axis(side=1, at=xats, labels=NA,tck=-0.02)
  3496. axis(side=1, at=xats, labels=xats,lwd=0, line=-0.25, cex.axis=0.8)
  3497. mtext(side=1, line=2, text='hours post-dose')
  3498. axis(side=2, at=yats, labels=NA,tck=-0.02)
  3499. axis(side=2, at=ybigs, labels=NA,tck=-0.05)
  3500. axis(side=2, at=ybigs, line=-0.25, las=2, labels=ybiglabs, lwd=0, cex.axis=0.8)
  3501. mtext(side=2, line=5, text='plasma drug concentration')
  3502. abline(h=plasma$lloq_ug_g[1], lty=3, lwd=0.5)
  3503. points(plasma$hours, plasma$concentration_ug_g, col=plasma$color, pch=20, cex=0.5)
  3504. for (this_dose_level in unique(plasma_smry$dose_mg)) {
  3505. plasma_smry %>%
  3506. filter(dose_mg == this_dose_level) -> subs
  3507. points(subs$hours, subs$mean, col=subs$color, type='l', lwd=1)
  3508. }
  3509. leg = dose_meta %>% filter(dose_mg > 0)
  3510. legend('topright', legend=paste0(leg$dose_mg,' mg'), col=leg$color, pch=20, bty='n', cex=0.8)
  3511. mtext(side=3, text='dogs')
  3512. mtext(side=3, adj=-0.2, text=LETTERS[panel], line=0.5); panel = panel + 1
  3513. dog_dose_meta -> dose_meta
  3514. dog_bioa -> bioa
  3515. bioa %>%
  3516. filter(matrix=='CSF') %>%
  3517. inner_join(dose_meta, by='dose_mg') -> csf
  3518. csf %>%
  3519. group_by(dose_mg, color, nominal_timepoint) %>%
  3520. summarize(.groups='keep',
  3521. n=n(),
  3522. mean=mean(concentration_ug_g)) %>%
  3523. ungroup() -> csf_smry
  3524. write_supp_table(csf, 'CSF PK analysis, dogs, individual.')
  3525. write_supp_table(csf_smry, 'CSF PK analysis, dogs, summarized.')
  3526. xlims = c(0, 30)
  3527. xats = unique(csf$nominal_timepoint)
  3528. ylims = c(0.0008, 100)
  3529. yats = rep(1:9, times=7) * rep(10^(-4:2),each=9)
  3530. ybigs = 10^(-4:2)
  3531. ybiglabs = c('0.1 ng/mL','1 ng/mL','10 ng/mL', '100 ng/mL', '1 µg/mL', '10 µg/mL', '100 µg/mL')
  3532. par(mar=c(3,6,3,1))
  3533. plot(NA, NA, xlim=xlims, ylim=ylims, log='y', axes=F, ann=F, xaxs='i', yaxs='i')
  3534. axis(side=1, at=xats, labels=NA,tck=-0.02)
  3535. axis(side=1, at=xats, labels=xats,lwd=0, line=-0.25, cex.axis=0.8)
  3536. mtext(side=1, line=2, text='days post-dose')
  3537. axis(side=2, at=yats, labels=NA,tck=-0.02)
  3538. axis(side=2, at=ybigs, labels=NA,tck=-0.05)
  3539. axis(side=2, at=ybigs, line=-0.25, las=2, labels=ybiglabs, lwd=0, cex.axis=0.8)
  3540. mtext(side=2, line=5, text='CSF drug concentration')
  3541. abline(h=csf$lloq_ug_g[1], lty=3, lwd=0.5)
  3542. points(csf$nominal_timepoint, csf$concentration_ug_g, col=csf$color, pch=20, cex=0.5)
  3543. for (this_dose_level in unique(csf_smry$dose_mg)) {
  3544. csf_smry %>%
  3545. filter(dose_mg == this_dose_level) -> subs
  3546. points(subs$nominal_timepoint, subs$mean, col=subs$color, type='l', lwd=1)
  3547. }
  3548. leg = dose_meta %>% filter(dose_mg > 0)
  3549. legend('topright', legend=paste0(leg$dose_mg,' mg'), col=leg$color, pch=20, bty='n', cex=0.8)
  3550. mtext(side=3, text='dogs')
  3551. mtext(side=3, adj=-0.2, text=LETTERS[panel], line=0.5); panel = panel + 1
  3552. #
  3553. # xmin = 8e-4
  3554. # day_meta = tibble(nominal_timepoint = c(1,28),
  3555. # day_y = c(5, 0),
  3556. # disp = c('1d core','28d recovery'))
  3557. #
  3558. #
  3559. # bioa %>%
  3560. # filter(matrix=='CSF') %>%
  3561. # inner_join(day_meta, by='nominal_timepoint') %>%
  3562. # inner_join(dose_meta, by='dose_mg') %>%
  3563. # select(-x) %>%
  3564. # mutate(y = dose_y + day_y) %>%
  3565. # arrange(desc(y)) -> bioa_anno
  3566. #
  3567. # bioa_anno %>%
  3568. # group_by(y, matrix, nominal_timepoint, dose_mg, lloq_ug_g, color) %>%
  3569. # summarize(.groups='keep',
  3570. # mean = mean(concentration_ug_g),
  3571. # l95 = lower(concentration_ug_g),
  3572. # u95 = upper(concentration_ug_g)) %>%
  3573. # ungroup() %>%
  3574. # mutate(xleft=xmin) -> bioa_smry
  3575. #
  3576. #
  3577. # xbigs = 10^(-3:3)
  3578. # xbiglabs = c('1 ng/g', '10 ng/g', '100 ng/g', '1 µg/g', '10 µg/g', '100 µg/g', '1 mg/g')
  3579. # xats = rep(1:9, 7) * 10^rep(-3:3, each=9)
  3580. # xlims = c(xmin, 1e3)
  3581. # ylims = range(bioa_smry$y) + c(-1, 1)
  3582. # par(mar=c(3,6,1,2))
  3583. # plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i', log='x')
  3584. # axis(side=2, at=ylims, labels=NA, lwd.ticks=0)
  3585. # #mtext(side=2, at=bioa_smry$y, text=bioa_smry$dose_mg, las=2, cex=0.4, line=0.2, font=2)
  3586. # axis(side=1, at=xbigs, tck=-0.05, labels=NA)
  3587. # axis(side=1, at=xbigs, lwd=0, labels=gsub(' ','\n',xbiglabs), cex.axis=0.6, line=-0.25)
  3588. # axis(side=1, at=xats, tck=-0.02, labels=NA)
  3589. # barwidth=1
  3590. # rect(xleft=bioa_smry$xleft, xright=bioa_smry$mean, ybottom=bioa_smry$y-barwidth/2, ytop=bioa_smry$y+barwidth/2, col=alpha(bioa_smry$color,.75), border=NA)
  3591. # suppressWarnings(arrows(x0=pmax(bioa_smry$l95, min(xlims)), x1=bioa_smry$u95, y0=bioa_smry$y, length=0.025, col=bioa_smry$color, code=3, angle=90))
  3592. # points(bioa_anno$concentration_ug_g, bioa_anno$y, col=bioa_anno$color, pch=21, bg='#FFFFFF', cex=0.75)
  3593. # points(x=bioa_smry$lloq_ug_g, y=bioa_smry$y, pch='|', col='#7A7A7A')
  3594. # mtext(side=1, at=bioa_smry$lloq_ug_g[1], col='#7A7A7A', cex=0.3, text='LLQ', line=-0.5)
  3595. # mtext(side=2, at=day_meta$day_y + 2, text=day_meta$disp, las=2, line=0.5, cex=0.8)
  3596. # par(xpd=T)
  3597. # legend('bottomright', paste0(dose_meta$dose_mg, ' mg'), title='dose', bty='n', col=dose_meta$color, pch=15, cex=0.6)
  3598. # par(xpd=F)
  3599. #
  3600. rat_dose_meta -> dose_meta
  3601. rat_bioa -> bioa
  3602. bioa %>%
  3603. filter(matrix=='Plasma') %>%
  3604. inner_join(dose_meta, by='dose_mg') %>%
  3605. mutate(hours = nominal_timepoint * 24) -> plasma
  3606. plasma %>%
  3607. group_by(dose_mg, color, hours) %>%
  3608. summarize(.groups='keep',
  3609. n=n(),
  3610. mean=mean(concentration_ug_g)) %>%
  3611. ungroup() -> plasma_smry
  3612. write_supp_table(plasma, 'Plasma toxicokinetic analysis, rats, individual.')
  3613. write_supp_table(plasma_smry, 'Plasma toxicokinetic analysis, rats, summarized.')
  3614. rat_organs_out %>%
  3615. summarize(mean(terminal_bw_g, na.rm=T)) %>%
  3616. pull() -> mean_terminal_bw_g
  3617. # https://iacuc.ucsf.edu/sites/g/files/tkssra751/f/wysiwyg/GUIDELINE%20-%20Blood%20Collection%20-%20Rat.pdf
  3618. # says 64 mL/kg total blood volume
  3619. blood_ml_per_kg = 64
  3620. plasma_smry %>%
  3621. filter(dose_mg > 0) %>%
  3622. mutate(proportion_dose_in_blood = blood_ml_per_kg * (mean_terminal_bw_g/1000) * mean / 1000 / dose_mg) %>%
  3623. group_by(hours) %>%
  3624. summarize(.groups='keep', estimated_proportion_dose_in_blood = mean(proportion_dose_in_blood)) %>%
  3625. ungroup() -> proportion_dose_in_blood_by_hours
  3626. write_supp_table(proportion_dose_in_blood_by_hours, 'Estimated proportion dose in blood, rats, summarized.')
  3627. xlims = c(0.4, 100)
  3628. xats = unique(plasma$hours)
  3629. ylims = c(0.0008, 100)
  3630. yats = rep(1:9, times=7) * rep(10^(-4:2),each=9)
  3631. ybigs = 10^(-4:2)
  3632. ybiglabs = c('0.1 ng/mL','1 ng/mL','10 ng/mL', '100 ng/mL', '1 µg/mL', '10 µg/mL', '100 µg/mL')
  3633. par(mar=c(3,6,3,1))
  3634. plot(NA, NA, xlim=xlims, ylim=ylims, log='xy', axes=F, ann=F, xaxs='i', yaxs='i')
  3635. axis(side=1, at=xats, labels=NA,tck=-0.02)
  3636. axis(side=1, at=xats, labels=xats,lwd=0, line=-0.25, cex.axis=0.8)
  3637. mtext(side=1, line=2, text='hours post-dose')
  3638. axis(side=2, at=yats, labels=NA,tck=-0.02)
  3639. axis(side=2, at=ybigs, labels=NA,tck=-0.05)
  3640. axis(side=2, at=ybigs, line=-0.25, las=2, labels=ybiglabs, lwd=0, cex.axis=0.8)
  3641. mtext(side=2, line=5, text='plasma drug concentration')
  3642. abline(h=plasma$lloq_ug_g[1], lty=3, lwd=0.5)
  3643. points(plasma$hours, plasma$concentration_ug_g, col=plasma$color, pch=20, cex=0.5)
  3644. for (this_dose_level in unique(plasma_smry$dose_mg)) {
  3645. plasma_smry %>%
  3646. filter(dose_mg == this_dose_level) -> subs
  3647. points(subs$hours, subs$mean, col=subs$color, type='l', lwd=1)
  3648. }
  3649. leg = dose_meta %>% filter(dose_mg > 0)
  3650. legend('topright', legend=paste0(leg$dose_mg,' mg'), col=leg$color, pch=20, bty='n', cex=0.8)
  3651. mtext(side=3, text='rats')
  3652. mtext(side=3, adj=-0.2, text=LETTERS[panel], line=0.5); panel = panel + 1
  3653. rat_dose_meta -> dose_meta
  3654. rat_bioa -> bioa
  3655. bioa %>%
  3656. filter(matrix=='CSF') %>%
  3657. inner_join(dose_meta, by='dose_mg') -> csf
  3658. csf %>%
  3659. group_by(dose_mg, color, nominal_timepoint) %>%
  3660. summarize(.groups='keep',
  3661. n=n(),
  3662. mean=mean(concentration_ug_g)) %>%
  3663. ungroup() -> csf_smry
  3664. write_supp_table(csf, 'CSF PK analysis, rats, individual.')
  3665. write_supp_table(csf_smry, 'CSF PK analysis, rats, summarized.')
  3666. xlims = c(0, 30)
  3667. xats = unique(csf$nominal_timepoint)
  3668. ylims = c(0.0008, 100)
  3669. yats = rep(1:9, times=7) * rep(10^(-4:2),each=9)
  3670. ybigs = 10^(-4:2)
  3671. ybiglabs = c('0.1 ng/mL','1 ng/mL','10 ng/mL', '100 ng/mL', '1 µg/mL', '10 µg/mL', '100 µg/mL')
  3672. par(mar=c(3,6,3,1))
  3673. plot(NA, NA, xlim=xlims, ylim=ylims, log='y', axes=F, ann=F, xaxs='i', yaxs='i')
  3674. axis(side=1, at=xats, labels=NA,tck=-0.02)
  3675. axis(side=1, at=xats, labels=xats,lwd=0, line=-0.25, cex.axis=0.8)
  3676. mtext(side=1, line=2, text='days post-dose')
  3677. axis(side=2, at=yats, labels=NA,tck=-0.02)
  3678. axis(side=2, at=ybigs, labels=NA,tck=-0.05)
  3679. axis(side=2, at=ybigs, line=-0.25, las=2, labels=ybiglabs, lwd=0, cex.axis=0.8)
  3680. mtext(side=2, line=5, text='CSF drug concentration')
  3681. abline(h=csf$lloq_ug_g[1], lty=3, lwd=0.5)
  3682. points(csf$nominal_timepoint, csf$concentration_ug_g, col=csf$color, pch=20, cex=0.5)
  3683. for (this_dose_level in unique(csf_smry$dose_mg)) {
  3684. csf_smry %>%
  3685. filter(dose_mg == this_dose_level) -> subs
  3686. points(subs$nominal_timepoint, subs$mean, col=subs$color, type='l', lwd=1)
  3687. }
  3688. leg = dose_meta %>% filter(dose_mg > 0)
  3689. legend('topright', legend=paste0(leg$dose_mg,' mg'), col=leg$color, pch=20, bty='n', cex=0.8)
  3690. mtext(side=3, text='rats')
  3691. mtext(side=3, adj=-0.2, text=LETTERS[panel], line=0.5); panel = panel + 1
  3692. #
  3693. #
  3694. # day_meta = tibble(nominal_timepoint = c(1,28),
  3695. # day_y = c(5,0),
  3696. # disp = c('1d core','28d recovery'))
  3697. #
  3698. #
  3699. # bioa %>%
  3700. # filter(matrix=='CSF') %>%
  3701. # inner_join(day_meta, by='nominal_timepoint') %>%
  3702. # inner_join(dose_meta, by='dose_mg') %>%
  3703. # select(-x) %>%
  3704. # mutate(y = dose_y + day_y) %>%
  3705. # arrange(desc(y)) -> bioa_anno
  3706. #
  3707. # bioa_anno %>%
  3708. # group_by(y, matrix, nominal_timepoint, dose_mg, lloq_ug_g, color) %>%
  3709. # summarize(.groups='keep',
  3710. # mean = mean(concentration_ug_g),
  3711. # l95 = lower(concentration_ug_g),
  3712. # u95 = upper(concentration_ug_g)) %>%
  3713. # ungroup() %>%
  3714. # mutate(xleft=xmin) -> bioa_smry
  3715. #
  3716. #
  3717. # xbigs = 10^(-3:3)
  3718. # xbiglabs = c('1 ng/g', '10 ng/g', '100 ng/g', '1 µg/g', '10 µg/g', '100 µg/g', '1 mg/g')
  3719. # xats = rep(1:9, 7) * 10^rep(-3:3, each=9)
  3720. # xlims = c(xmin, 1e3)
  3721. # ylims = range(bioa_smry$y) + c(-1, 1)
  3722. # par(mar=c(3,6,1,2))
  3723. # plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i', log='x')
  3724. # axis(side=2, at=ylims, labels=NA, lwd.ticks=0)
  3725. # #mtext(side=2, at=bioa_smry$y, text=bioa_smry$dose_mg, las=2, cex=0.4, line=0.2, font=2)
  3726. # axis(side=1, at=xbigs, tck=-0.05, labels=NA)
  3727. # axis(side=1, at=xbigs, lwd=0, labels=gsub(' ','\n',xbiglabs), cex.axis=0.6, line=-0.25)
  3728. # axis(side=1, at=xats, tck=-0.02, labels=NA)
  3729. # barwidth=1
  3730. # rect(xleft=bioa_smry$xleft, xright=bioa_smry$mean, ybottom=bioa_smry$y-barwidth/2, ytop=bioa_smry$y+barwidth/2, col=alpha(bioa_smry$color,.75), border=NA)
  3731. # suppressWarnings(arrows(x0=pmax(bioa_smry$l95, min(xlims)), x1=bioa_smry$u95, y0=bioa_smry$y, length=0.025, col=bioa_smry$color, code=3, angle=90))
  3732. # points(bioa_anno$concentration_ug_g, bioa_anno$y, col=bioa_anno$color, pch=21, bg='#FFFFFF', cex=0.75)
  3733. # points(x=bioa_smry$lloq_ug_g, y=bioa_smry$y, pch='|', col='#7A7A7A')
  3734. # mtext(side=1, at=bioa_smry$lloq_ug_g[1], col='#7A7A7A', cex=0.3, text='LLQ', line=-0.5)
  3735. # mtext(side=2, at=day_meta$day_y + 2, text=day_meta$disp, las=2, line=0.5, cex=0.8)
  3736. # par(xpd=T)
  3737. # legend('bottomright', paste0(dose_meta$dose_mg, ' mg'), title='dose', bty='n', col=dose_meta$color, pch=15, cex=0.6)
  3738. # par(xpd=F)
  3739. silence_is_golden = dev.off()
  3740. } ### end Figure S11 ####
  3741. ## Figure S11 - manufacturing process ####
  3742. if ('figure-s11'=='figure-s11') {
  3743. tell_user('done.\nCreating Figure S11...')
  3744. png('display_items/figure-s11.png',width=6.5*resx,height=5.0*resx,res=resx)
  3745. par(mfrow=c(1,1))
  3746. manuf_studies = c("CMR-2752", "CMR-2812", "CMR-2833", "CMR-2941")
  3747. manuf_meta = tribble(
  3748. ~display_tx, ~order,
  3749. 'none', 1,
  3750. 'UMass BTT+DDTT', 2,
  3751. 'Hongene ETT+XH', 3,
  3752. 'UMass ETT+DDTT', 4,
  3753. 'Hongene BTT+XH', 5,
  3754. 'Hongene BTT+DDTT', 6,
  3755. 'Hongene BTT+DDTT scaled up', 7
  3756. )
  3757. qpcr %>%
  3758. filter(study_id %in% manuf_studies) %>%
  3759. filter(target=='PRNP') %>%
  3760. group_by(sample_id, study_id, qpcr_id, region, biorep, sample_group) %>%
  3761. summarize(.groups='keep',
  3762. n_techreps = n(),
  3763. mean_twoddct = mean(twoddct)) %>%
  3764. ungroup() %>%
  3765. group_by(study_id, qpcr_id, region) %>%
  3766. mutate(residual = mean_twoddct / mean(mean_twoddct[sample_group %in% c('no injection')])) %>%
  3767. ungroup() %>%
  3768. filter(!is.na(sample_group) & sample_group != 'no lysate') %>%
  3769. left_join(study, by=c('sample_id'='animal','study_id')) %>%
  3770. left_join(meta, by=c('tx')) %>%
  3771. inner_join(manuf_meta, by='display_tx') %>%
  3772. mutate(panel = dense_rank(study_id)) %>%
  3773. group_by(panel) %>%
  3774. mutate(within_study_x = dense_rank(order)) %>%
  3775. ungroup() %>%
  3776. mutate(overall_x = dense_rank(paste0(panel, order))) -> manuf_qpcr
  3777. manuf_qpcr %>%
  3778. group_by(panel, study_id, order, within_study_x, overall_x, display_tx, color) %>%
  3779. summarize(.groups='keep',
  3780. n=n(),
  3781. mean = mean(residual),
  3782. l95 = lower(residual),
  3783. u95 = upper(residual),
  3784. maxy = max(residual)) %>%
  3785. ungroup() %>%
  3786. mutate(pval = as.numeric(NA)) -> manuf_smry
  3787. for (i in 1:nrow(manuf_smry)) {
  3788. controls = manuf_qpcr$residual[manuf_qpcr$study_id==manuf_smry$study_id[i] & manuf_qpcr$display_tx=='UMass BTT+DDTT']
  3789. test_group = manuf_qpcr$residual[manuf_qpcr$study_id==manuf_smry$study_id[i] & manuf_qpcr$display_tx == manuf_smry$display_tx[i]]
  3790. manuf_smry$pval[i] = t.test(controls, test_group)$p.value
  3791. }
  3792. manuf_smry$psymb = p_to_symbol(manuf_smry$pval)
  3793. manuf_smry$psymb[manuf_smry$display_tx=='none'] = '' # don't show stars for difference from control, this is obvious
  3794. manuf_smry %>%
  3795. group_by(study_id, panel) %>%
  3796. summarize(.groups='keep', maxx = max(overall_x)) %>%
  3797. ungroup() -> tranches
  3798. par(mar=c(10,4,3,1))
  3799. xlims = range(manuf_smry$overall_x) + c(-0.5, 0.5)
  3800. ylims = c(0, 1.5)
  3801. ybigs = 0:3/2
  3802. yats = 0:6/4
  3803. plot(NA, NA, xlim=xlims, ylim=ylims, axes=F, ann=F, xaxs='i', yaxs='i')
  3804. axis(side=1, at=xlims, lwd.ticks=0, labels=NA)
  3805. mtext(side=1, line=0.25, at=manuf_smry$overall_x, text=manuf_smry$display_tx, cex=0.8, las=2)
  3806. axis(side=2, at=ybigs, labels=percent(ybigs), cex.axis=0.8, las=2, tck=-0.05)
  3807. axis(side=2, at=yats, labels=NA, cex.axis=0.8, las=2, tck=-0.02)
  3808. mtext(side=2, line=3, text=expression(residual~italic(PRNP)))
  3809. abline(h=1, lwd=0.25, lty=3)
  3810. points(manuf_qpcr$overall_x, manuf_qpcr$residual, pch=1, lwd=2, cex=0.8, col=manuf_qpcr$color)
  3811. barwidth=0.3
  3812. rect(xleft=manuf_smry$overall_x-barwidth, xright=manuf_smry$overall_x+barwidth, ybottom=rep(0,nrow(manuf_smry)), ytop=manuf_smry$mean, col=alpha(manuf_smry$color, ci_alpha), border=NA)
  3813. # segments(x0=manuf_smry$overall_x-barwidth, x1=manuf_smry$overall_x+barwidth, y0=manuf_smry$mean)
  3814. suppressWarnings(arrows(x0=manuf_smry$overall_x, y0=manuf_smry$l95, y1=manuf_smry$u95, code=3, angle=90, length=0.03))
  3815. abline(v=tranches$maxx + 0.5, lwd=0.25)
  3816. mtext(side=3, line=0, at=manuf_smry$overall_x, text=manuf_smry$psymb, cex=0.6)
  3817. mtext(side=3, line=-1, at=manuf_smry$overall_x, text=percent(manuf_smry$mean, digits=1), cex=0.6)
  3818. manuf_qpcr %>%
  3819. select(study_id, sample_id, display_tx, dose_dio, residual) -> manuf_qpcr_out
  3820. manuf_smry %>%
  3821. select(study_id, display_tx, mean, l95, u95, pval) -> manuf_smry_out
  3822. write_supp_table(manuf_qpcr_out, 'Residual PRNP in whole hemisphere 7 days post-dose, by manufacturing process, individual animals.')
  3823. write_supp_table(manuf_smry_out, 'Residual PRNP in whole hemisphere 7 days post-dose, by manufacturing process, summarized.')
  3824. silence_is_golden = dev.off()
  3825. } ### end Figure S10 ####
  3826. ## Off-targets ####
  3827. tell_user('done.\nPerforming off-target analysis...')
  3828. blast_analyses = tribble(
  3829. ~species, ~file,
  3830. 'human', 'data/off_targets/E90AWU40016-homo-sapiens.csv'
  3831. )
  3832. for (i in 1:nrow(blast_analyses)) {
  3833. blast = read_csv(blast_analyses$file[i], col_types=cols()) %>%
  3834. clean_names() %>%
  3835. mutate(gene_symbol = gsub('\\(|\\)|,','',str_extract(hit_def,'\\([A-Za-z0-9-]+\\),')))
  3836. antisense_frame = 1 # you can check this for human - blast %>% filter(gene_symbol=='PRNP') %>% pull(hsp_hit_frame)
  3837. max_length = max(nchar(blast$hsp_qseq))
  3838. blast %>%
  3839. filter(hsp_hit_frame == antisense_frame) %>%
  3840. arrange(desc(hsp_identity)) %>%
  3841. group_by(gene_symbol) %>%
  3842. slice(1) %>%
  3843. ungroup() %>%
  3844. mutate(mismatches = max_length - hsp_identity) %>%
  3845. select(gene_symbol, hit_accession, mismatches, hsp_qseq, hsp_hseq, hsp_midline) %>%
  3846. arrange(mismatches, gene_symbol) -> blast_hits
  3847. write_supp_table(blast_hits, paste0('Off-target hits for ',blast_analyses$species[i],'for 2439-exNA antisense seed region 2-17.'))
  3848. }
  3849. # SUPPLEMENT ####
  3850. tell_user('done.\nFinalizing supplementary tables...')
  3851. # write the supplement directory / table of contents
  3852. supplement_directory %>% rename(table_number = name, description=title) -> contents
  3853. addWorksheet(supplement,'contents')
  3854. bold_style = createStyle(textDecoration = "Bold")
  3855. writeData(supplement,'contents',contents,headerStyle=bold_style,withFilter=T)
  3856. freezePane(supplement,'contents',firstRow=T)
  3857. # move directory to the front
  3858. original_order = worksheetOrder(supplement)
  3859. n_sheets = length(original_order)
  3860. new_order = c(n_sheets, 1:(n_sheets-1))
  3861. worksheetOrder(supplement) = new_order
  3862. activeSheet(supplement) = 'contents'
  3863. # now save
  3864. saveWorkbook(supplement,supplement_path,overwrite = TRUE)
  3865. elapsed_time = Sys.time() - overall_start_time
  3866. cat(file=stderr(), paste0('done.\nAll tasks complete in ',round(as.numeric(elapsed_time),1),' ',units(elapsed_time),'.\n'))

divalent_manuscript_figures.R at commit 8efada0, under CC-BY-4.0 · at the source

Overview

Authors: Juliana E Gentile1, Taylor L Corridon1, Fiona E Serack1, Dimas Echeverria2, Zachary C Kennedy2, Corrie L Gallant-Behm3, Matthew R Hassler3, Garth A Kinberger3, Margaret N Kelemen1, Nikita G Kamath1, Yuan Lian1, Katherine Y Gross2, Rachael Miller2, Kendrick DeSouza-Lenz4, Michael Howard4, Kenia Guzman4, Nathan Chan4, Vanessa Laversenne1, Daniel Curtis3, Kevin Fettes5
and 8 other authorsMarc Lemaitre6, Aimee L Jackson3, Ken Yamada2, Julia F Alterman2, Alissa A Coffey1, Eric Vallabh Minikel1,7,8,9, Anastasia Khvorova2, Sonia M Vallabh1,7,8,9
  1. Program in Brain Health, Broad Institute of MIT and Harvard, Cambridge, MA 02142, United States
  2. RNA Therapeutics Institute, UMass Chan Medical School, Worcester, MA 01605, United States
  3. Atalanta Therapeutics, Boston, MA 02210, United States
  4. Comparative Medicine, Broad Institute of MIT and Harvard, Cambridge, MA 02142, United States
  5. FTS Pharma Consulting LLC, Medfield, MA 02052, United States
  6. ML Consult LLC, Cincinnati, OH 45220, United States
  7. McCance Center for Brain Health and Department of Neurology, Massachusetts General Hospital, Boston, MA 02114, United States
  8. Department of Neurology, Harvard Medical School, Boston, MA 02115, United States
  9. Prion Alliance, Cambridge, MA 02139, United States
Journal: Nucleic acids research, volume 54, issue 8, article gkag287
Dates: received 21 August 2025; accepted 6 March 2026; published online 24 April 2026; in print April 2026
Type: Research article · Language: English
License: CC BY
Identifiers: DOI 10.1093/nar/gkag287 · PMID 42033217 · PMCID PMC13107126 · OpenAlex W4405172331
Open access: gold, a free copy (OpenAlex)
Status: code verified
Categories: human (organism), mouse (organism), other condition (population)
Methods: Statistics, fMRI & imaging, Physiology & signal measures
MeSH: Prion Diseases*, Prion Proteins*, Prions*, RNA, Small Interfering*, Animals, Brain, Disease Models, Animal, Humans, Mice, Mice, Transgenic (* major topic)
Journal subjects: Nucleic Acid Therapeutics
Topic: RNA Interference and Gene Delivery (Molecular Biology, Biochemistry, Genetics and Molecular Biology), according to OpenAlex
Funding: NIH (R61/R33 NS119717); Ultra-rare Gene-based Therapy Network (URGenT U01 NS132994); Prion Alliance; Family Foundation
Citations: cited by 10 papers (Europe PMC); 73 references in the paper

Abstract

Prion protein (PrP) lowering is effective in animal models of prion disease and is being tested clinically in prion disease patients, but there remains a need for more potent PrP-lowering drug candidates. Inspired by the reported potency and duration of action of divalent short interfering RNA (siRNA), a new oligonucleotide drug modality for the central nervous system, we sought to discover and develop a new PrP-lowering drug candidate. Herein we identify a mouse Prnp-targeting divalent siRNA molecule, 1682-s4, that lowers PrP to 49% residual brain expression in wild-type mice, and, in the context of intracerebral infection with Rocky Mountain Laboratories prions, achieves a 2.7-fold increase in survival time with pre-symptomatic chronic treatment and 64% increase in survival time with a single dose after symptom onset. We describe the generation of two transgenic mouse lines, Tg25109 and Tg26372, expressing the full human PRNP gene and its noncoding sequence, and demonstrate their utility for in vivo discovery of potent human PRNP-targeting oligonucleotides. We discover siRNA sequence 2439 against human PRNP and compare its potency in different divalent siRNA chemical scaffolds. We determine that both the fixed UU tail and extended nucleic acid linkages of scaffold s4 contribute to superior potency compared to other scaffolds tested, offering 9.4 and 15.9 percentage points respectively of additional PrP knockdown. A single dose of 348 µg of 2439-s4 lowered whole brain hemisphere human PrP in transgenic mice to 17% residual after 30 days, while 52 µg lowered PrP to 49% residual. A total of 1%–2% of the dose of 2439-s4 delivered into cerebrospinal fluid is retained in the brain, and the median effective tissue concentration is estimated at 1.2 μg per gram of tissue. Good Laboratory Practices toxicology studies identified no significant liabilities, and the US FDA has cleared an Investigational New Drug application to bring 2439-s4 into clinical trials.

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

Repositories

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

ericminikel/divalent

License: CC-BY-4.0
State: the link answers, verified on 28 September 2026
Evidence: files inventoried
Commit: 8efada0acf724744d6bc86dbf43cdc1d5c140f1a, 10 March 2026
Languages: Python (1), R (1)
Size: 294 files, 2 scripts
Software Heritage: not archived
Found in: “Statistics, source code, and data availability”
Holds: README, license file
Not found: CITATION.cff, environment file, tests, continuous integration, documentation
Tools: survival (1 file), tidyverse (1 file)
Availability: 1 check, the latest on 28 September 2026: the link answers
  • 28 September 2026: the link answers
4 files

Zenodo 18960176

License: CC-BY-4.0
State: the link answers, verified on 28 September 2026
Evidence: files inventoried
Size: 1 file
Software Heritage: not checked
Found in: “Data availability”
Not found: README, license file, CITATION.cff, environment file, tests, continuous integration, documentation
Availability: 1 check, the latest on 28 September 2026: the link answers (HTTP 200)
  • 28 September 2026: the link answers (HTTP 200)

The paper's code and data availability statement is in the Data section.

Tracing map

Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.

What the map holds:

  • 2 repositories of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
  • 2 scripts, each with its path and the digest of its content;
  • 14 matches between paragraphs of the paper and lines of the code (method lexical-v1);
  • neither the text of the paper nor the code itself.

Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.

Data

No dataset and no data link were found in the paper.

Data availability

Raw individual-level animal data, source code sufficient to reproduce all analyses herein, and the text our Investigational New Drug application and regulatory interactions with US FDA are available in this study’s online git repository (https://github.com/ericminikel/divalent) and in Zenodo (https://doi.org/10.5281/zenodo.18960176).

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

Statistics, source code, and data availability

All analysis was conducted using custom scripts in R 4.2.0. Percent changes in mouse weights relative to baseline were compared using two-sided t-tests. Survival was assessed using log-rank test. Dose-response curves were fit using the drc package [50] in R, with a four-point Hill slope model fixing the infinite-dose asymptote (c) and zero-dose asymptote (d) at 0% and 100% respectively. The impact of scaffold and fixed tail was characterized using a linear model with formula residual ∼ scaffold + log(dose) + region. Inflammatory marker responses were assessed using Dunnett’s test to compare each treated group to the PBS or untreated group. Raw individual-level animal data, source code sufficient to reproduce all analyses herein, and the text our IND application and regulatory interactions with US FDA are available in this study’s online git repository: https://github.com/ericminikel/divalent

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, 28 September 2026: the first record

Recorded: type, language, journal, volume, issue, pages, dates, 28 authors, 10 MeSH terms, 4 funders, 67 references, 2 RRIDs.

Cite

This paper

Gentile, J. E., Corridon, T. L., Serack, F. E., Echeverria, D., Kennedy, Z. C., Gallant-Behm, C. L., Hassler, M. R., Kinberger, G. A., Kelemen, M. N., Kamath, N. G., Lian, Y., Gross, K. Y., Miller, R., DeSouza-Lenz, K., Howard, M., Guzman, K., Chan, N., Laversenne, V., Curtis, D., . . . Vallabh, S. M. (2026). Divalent siRNA for prion disease. Nucleic acids research, 54(8), gkag287. https://doi.org/10.1093/nar/gkag287

BibTeX

@article{gentile2026divalent,
author = {Gentile, Juliana E and Corridon, Taylor L and Serack, Fiona E and Echeverria, Dimas and Kennedy, Zachary C and Gallant-Behm, Corrie L and Hassler, Matthew R and Kinberger, Garth A and Kelemen, Margaret N and Kamath, Nikita G and Lian, Yuan and Gross, Katherine Y and Miller, Rachael and DeSouza-Lenz, Kendrick and Howard, Michael and Guzman, Kenia and Chan, Nathan and Laversenne, Vanessa and Curtis, Daniel and Fettes, Kevin and Lemaitre, Marc and Jackson, Aimee L and Yamada, Ken and Alterman, Julia F and Coffey, Alissa A and Minikel, Eric Vallabh and Khvorova, Anastasia and Vallabh, Sonia M},
title = {{Divalent siRNA for prion disease}},
journal = {Nucleic acids research},
year = {2026},
month = apr,
volume = {54},
number = {8},
pages = {gkag287},
publisher = {Oxford University Press},
issn = {0305-1048},
doi = {10.1093/nar/gkag287},
url = {https://doi.org/10.1093/nar/gkag287},
pmid = {42033217},
pmcid = {PMC13107126}
}

RIS

TY - JOUR
AU - Gentile, Juliana E
AU - Corridon, Taylor L
AU - Serack, Fiona E
AU - Echeverria, Dimas
AU - Kennedy, Zachary C
AU - Gallant-Behm, Corrie L
AU - Hassler, Matthew R
AU - Kinberger, Garth A
AU - Kelemen, Margaret N
AU - Kamath, Nikita G
AU - Lian, Yuan
AU - Gross, Katherine Y
AU - Miller, Rachael
AU - DeSouza-Lenz, Kendrick
AU - Howard, Michael
AU - Guzman, Kenia
AU - Chan, Nathan
AU - Laversenne, Vanessa
AU - Curtis, Daniel
AU - Fettes, Kevin
AU - Lemaitre, Marc
AU - Jackson, Aimee L
AU - Yamada, Ken
AU - Alterman, Julia F
AU - Coffey, Alissa A
AU - Minikel, Eric Vallabh
AU - Khvorova, Anastasia
AU - Vallabh, Sonia M
TI - Divalent siRNA for prion disease
T2 - Nucleic acids research
J2 - Nucleic Acids Res
PY - 2026
DA - 2026/04/01
VL - 54
IS - 8
SP - gkag287
SN - 0305-1048
PB - Oxford University Press
DO - 10.1093/nar/gkag287
UR - https://doi.org/10.1093/nar/gkag287
LA - en
ER -

CSL-JSON

{
"id": "10.1093/nar/gkag287",
"type": "article-journal",
"title": "Divalent siRNA for prion disease",
"container-title": "Nucleic acids research",
"author": [
{
"family": "Gentile",
"given": "Juliana E"
},
{
"family": "Corridon",
"given": "Taylor L"
},
{
"family": "Serack",
"given": "Fiona E"
},
{
"family": "Echeverria",
"given": "Dimas"
},
{
"family": "Kennedy",
"given": "Zachary C"
},
{
"family": "Gallant-Behm",
"given": "Corrie L"
},
{
"family": "Hassler",
"given": "Matthew R"
},
{
"family": "Kinberger",
"given": "Garth A"
},
{
"family": "Kelemen",
"given": "Margaret N"
},
{
"family": "Kamath",
"given": "Nikita G"
},
{
"family": "Lian",
"given": "Yuan"
},
{
"family": "Gross",
"given": "Katherine Y"
},
{
"family": "Miller",
"given": "Rachael"
},
{
"family": "DeSouza-Lenz",
"given": "Kendrick"
},
{
"family": "Howard",
"given": "Michael"
},
{
"family": "Guzman",
"given": "Kenia"
},
{
"family": "Chan",
"given": "Nathan"
},
{
"family": "Laversenne",
"given": "Vanessa"
},
{
"family": "Curtis",
"given": "Daniel"
},
{
"family": "Fettes",
"given": "Kevin"
},
{
"family": "Lemaitre",
"given": "Marc"
},
{
"family": "Jackson",
"given": "Aimee L"
},
{
"family": "Yamada",
"given": "Ken"
},
{
"family": "Alterman",
"given": "Julia F"
},
{
"family": "Coffey",
"given": "Alissa A"
},
{
"family": "Minikel",
"given": "Eric Vallabh"
},
{
"family": "Khvorova",
"given": "Anastasia"
},
{
"family": "Vallabh",
"given": "Sonia M"
}
],
"container-title-short": "Nucleic Acids Res",
"volume": "54",
"issue": "8",
"page": "gkag287",
"DOI": "10.1093/nar/gkag287",
"PMID": "42033217",
"PMCID": "PMC13107126",
"ISSN": "0305-1048",
"publisher": "Oxford University Press",
"URL": "https://doi.org/10.1093/nar/gkag287",
"language": "en",
"issued": {
"date-parts": [
[
2026,
4,
1
]
]
}
}

The tracing map gets a citation of its own once an author has validated it and it has a DOI.

Similar papers

The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.

[1] doi:10.1371/journal.ppat.1014263 [code]
PrP turnover in vivo and the time to effect of prion disease therapeutics.
Journal: PLoS pathogens
In common: tidyverse, other condition, mouse, 16 references, 4 authors
[2] doi:10.1016/j.stemcr.2026.102924
PrP&lt;sup&gt;C&lt;/sup&gt;-facilitated cell signaling activates phospholipase Cɣ1 and triggers an Arc/Arg3.1 response in mouse and iPSC-derived human neurons.
Journal: Stem cell reports
In common: other condition, mouse, 3 references
[3] doi:10.1371/journal.ppat.1014314
Chemo-omic pipeline enables discovery of prion synaptotoxic pathways and inhibitory drugs.
Journal: PLoS pathogens
In common: other condition, mouse, 3 references
[4] doi:10.1038/s42003-026-10252-6 [code]
RET signaling as a mediator of estrogen receptor positive breast cancer brain metastasis.
Journal: Communications biology
In common: survival, tidyverse, other condition, mouse
[5] doi:10.1186/s13073-026-01664-4 [code]
Integrative multi-omics profiling reveals distinct evolutionary and immunogenic features of brain oligometastasis in lung adenocarcinoma.
Journal: Genome medicine
In common: survival, tidyverse, other condition, mouse
[6] doi:10.1038/s41467-026-70375-6 [code]
Ribosomal modifications are associated with mesenchymal fate selection in the neural crest lineage.
Journal: Nature communications
In common: survival, tidyverse, other condition, mouse
[7] doi:10.1016/j.omta.2026.201818
Antisense oligonucleotide treatment following viral delivery of artificial SOD1-targeting miRNA shows improved efficacy in SOD1-G93A mice.
Journal: Molecular therapy. Advances
In common: other condition, mouse, 2 references
[8] doi:10.1016/j.xcrm.2026.102929
Fatty-acid-based antimiR-23b delivery in the DMSXL model: A potential therapeutic strategy for brain dysfunction in myotonic dystrophy type 1.
Journal: Cell reports. Medicine
In common: mouse, 2 references
[9] doi:10.1002/glia.70142
The Ubiquitin Ligase Zinc Finger SWIM Domain-Containing Protein 8 Regulates Oligodendrocyte Development Through the Argonaute2/MicroRNA-7 Axis.
Journal: Glia
In common: mouse, 2 references
[10] doi:10.1093/neuonc/noag128 [code]
Spatially-resolved single-cell imaging of melanoma brain metastases identifies localized immune patterns predictive of immune checkpoint blockade response.
Journal: Neuro-oncology
In common: survival, tidyverse, other condition

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.