Skip to content

Commit

Permalink
Add response to JACI review and update figures
Browse files Browse the repository at this point in the history
  • Loading branch information
kdillmcfarland committed Mar 18, 2022
1 parent 864abf8 commit 1958aff
Show file tree
Hide file tree
Showing 43 changed files with 25,351 additions and 23,861 deletions.
360 changes: 360 additions & 0 deletions 3.P259.pDC_response.to.review.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,360 @@
---
title: 'P259: Response to reviews'
subtitle: "Dendritic cells (pDC)"
author: "Kim Dill-McFarland, [email protected]"
date: "version `r format(Sys.time(), '%B %d, %Y')`"
output:
pdf_document:
toc: yes
toc_depth: '3'
html_document:
toc: yes
toc_depth: 3
toc_float:
collapsed: no
editor_options:
chunk_output_type: console
---
# Background

Analyses performed in response to reviews for publication in JACI.

# Setup
Load packages

```{r message=FALSE, warning=FALSE}
# Data manipulation and figures
library(tidyverse)
library(ggpubr)
library(readxl)
library(patchwork)
#Print pretty tables to Rmd
library(knitr)
library(kableExtra)
```

Set seed

```{r}
set.seed(589)
```

Custom functions

```{r}
#To extract and format p-value from lmFit
source("https://raw.githubusercontent.com/kdillmcfarland/R_bioinformatic_scripts/master/limma.extract.pval.R")
```

# Low-quality libraries

Determine if low-quality libraries removed from analysis are associated with low input RNA. All filtered libraries with low raw sequences and high CV coverage also had low input RNA.

```{r echo=FALSE, message=FALSE, fig.width=8.5}
#### Data ####
attach("data_clean/P259_pDC_clean.RData")
meta <- read_csv("data_clean/P259_pDC_metadata.csv")
anno <- read_excel("data_raw/P259-2 Final Annotation.xlsx")
dat <- meta %>%
select(libID, total_sequences, median_cv_coverage) %>%
inner_join(select(anno, "library sampleId", "RNA conc (ng/ul)"),
by=c("libID"="library sampleId")) %>%
mutate(`Quality filter` = ifelse(libID %in% dat.pDC.voom$targets$libID, "Pass", "Fail"))
#### Plot ####
plot1 <- dat %>%
ggplot(aes(y=`RNA conc (ng/ul)`, x=total_sequences)) +
geom_point(aes(color=`Quality filter`), size=2) +
theme_classic() +
labs(x = "Raw sequences", y="RNA concentration (ng/ul)")
plot2 <- dat %>%
ggplot(aes(y=`RNA conc (ng/ul)`, x=median_cv_coverage)) +
geom_point(aes(color=`Quality filter`), size=2) +
theme_classic() +
labs(x = "Raw sequences", y="RNA concentration (ng/ul)")
plot1+plot2
```

# Viral load
### Data

RV sequences were extracted from RNA-seq libraries and quantified using methods similar to human data. Normalized RV counts were calculated as total RV sequences / total non-human sequences * 1E6

```{r echo=FALSE, message=FALSE}
dat2 <- read_csv("data_raw/211102_P259-1_P259-2_RhinoViruses_normlized_read_counts.csv") %>%
rename(libID=libid) %>%
#filter libraries in final analysis
filter(libID %in% dat.pDC.voom$targets$libID) %>%
#add metadata
left_join(select(meta, libID, experiment, donorID, IL5, virus, virus.detail)) %>%
mutate(contrast=paste(IL5,virus, sep="_")) %>%
mutate(contrast=factor(contrast,
levels = c("none_none","none_HRV",
"AntiIL5_none","AntiIL5_HRV",
"EOS.supp_none","EOS.supp_HRV")))
```

```{r echo=FALSE, message=FALSE}
# Format for limma
count1 <- dat2 %>%
filter(experiment == "P259_1") %>%
select(libID, RhinoVirusA_normCount) %>%
pivot_longer(-libID) %>%
arrange(libID) %>%
pivot_wider(names_from = libID) %>%
column_to_rownames("name")
meta1 <- dat2 %>%
filter(experiment == "P259_1") %>%
arrange(libID) %>%
droplevels()
count2 <- dat2 %>%
filter(experiment == "P259_2") %>%
select(libID, RhinoVirusA_normCount) %>%
pivot_longer(-libID) %>%
arrange(libID) %>%
pivot_wider(names_from = libID) %>%
column_to_rownames("name")
meta2 <- dat2 %>%
filter(experiment == "P259_2") %>%
arrange(libID) %>%
droplevels()
```

### Run limma contrasts model

In both experiments, viral loads were significantly higher in virus-infected samples and there were no differences between EOS supernatant or AntiIL5 treatment groups.

```{r echo=FALSE}
# Define model
model_1.contrast<- model.matrix(~ 0 + contrast, data=meta1)
colnames(model_1.contrast) <- c(
"none_none","none_HRV",
"EOS.supp_none","EOS.supp_HRV")
#Block by donor
consensus.corr1 <- duplicateCorrelation(
count1,
model_1.contrast,
block=meta1$donorID)$consensus.correlation
#Fit model
fitQW_1.contrast <- lmFit(count1,
model_1.contrast,
block=meta1$donorID,
correlation=consensus.corr1)
#Get contrasts
contrast.matrix1 <- makeContrasts(
none_HRV-none_none,
EOS.supp_HRV-EOS.supp_none,
EOS.supp_none-none_none,
EOS.supp_HRV-none_HRV,
levels=model_1.contrast)
efitQW_1.contrast <- eBayes(contrasts.fit(fitQW_1.contrast,
contrast.matrix1))
extract.pval(model=model_1.contrast,
voom.dat=count1,
eFit=efitQW_1.contrast,
name="pval_1.contrast",
summary=FALSE,
contrasts=TRUE,
contrast.mat=contrast.matrix1)
```

```{r echo=FALSE}
# Define model
model_2.contrast<- model.matrix(~ 0 + contrast, data=meta2)
colnames(model_2.contrast) <- c(
"none_none","none_HRV",
"AntiIL5_none","AntiIL5_HRV")
#Block by donor
consensus.corr2 <- duplicateCorrelation(
count2,
model_2.contrast,
block=meta2$donorID)$consensus.correlation
#Fit model
fitQW_2.contrast <- lmFit(count2,
model_2.contrast,
block=meta2$donorID,
correlation=consensus.corr2)
#Get contrasts
contrast.matrix2 <- makeContrasts(
none_HRV-none_none,
AntiIL5_HRV-AntiIL5_none,
AntiIL5_none-none_none,
AntiIL5_HRV-none_HRV,
levels=model_2.contrast)
efitQW_2.contrast <- eBayes(contrasts.fit(fitQW_2.contrast,
contrast.matrix2))
extract.pval(model=model_2.contrast,
voom.dat=count2,
eFit=efitQW_2.contrast,
name="pval_2.contrast",
summary=FALSE,
contrasts=TRUE,
contrast.mat=contrast.matrix2)
```

```{r echo=FALSE}
pval_1.contrast %>%
select(group, logFC, adj.P.Val) %>%
kable(align=c("l","c","c"), digits=4, caption="P259_1",
col.names = c("Variable","Fold change", "FDR")) %>%
kable_styling(latex_options="HOLD_position", full_width = FALSE)
pval_2.contrast %>%
select(group, logFC, adj.P.Val) %>%
kable(align=c("l","c","c"), digits=4, caption="P259_2",
col.names = c("Variable","Fold change", "FDR")) %>%
kable_styling(latex_options="HOLD_position", full_width = FALSE)
```

```{r echo=FALSE}
#save
write_csv(pval_1.contrast, file="review_response/RV.EOS.model.csv")
write_csv(pval_2.contrast, file="review_response/RV.antiIL5.model.csv")
```

### Plot

```{r echo=FALSE, fig.width=8.5, message=FALSE, warning=FALSE}
#### Format pval data ####
#Pvals for eos experiment
GOI.p1 <- pval_1.contrast %>%
mutate(dataset="P259.1")
#Pvals for aniti-IL5 experiment
GOI.p <- pval_2.contrast%>%
mutate(dataset="P259.2") %>%
#Combine with eos data
bind_rows(GOI.p1) %>%
#Make symbols for plots
mutate(symbol = ifelse(P.Value <= 0.001,"***",
ifelse(P.Value <= 0.01, "**",
ifelse(P.Value <= 0.05, "*", NA)))) %>%
filter(!is.na(symbol)) %>%
#Match group labels to those in plots
mutate(group.long = paste(dataset, group, sep="_"),
group1 = recode_factor(factor(group.long),
"P259.2_none_HRV - none_none"='"-\n-"',
"P259.2_AntiIL5_HRV - AntiIL5_none"='"-\n+"',
"P259.2_AntiIL5_none - none_none"='"-\n-"',
"P259.2_AntiIL5_HRV - none_HRV"='"+\n-"',
"P259.1_none_HRV - none_none"='"RV -\nEOS sup -"',
"P259.1_EOS.supp_HRV - EOS.supp_none"='"-\n+"',
"P259.1_EOS.supp_none - none_none"='"RV -\nEOS sup -"',
"P259.1_EOS.supp_HRV - none_HRV"='"+\n-"'),
group2 = recode_factor(factor(group.long),
"P259.2_none_HRV - none_none"='"+\n-"',
"P259.2_AntiIL5_HRV - AntiIL5_none"='"+ RV\n+ Anti-IL-5/5R"*alpha',
"P259.2_AntiIL5_none - none_none"='"-\n+"',
"P259.2_AntiIL5_HRV - none_HRV"='"+ RV\n+ Anti-IL-5/5R"*alpha',
"P259.1_none_HRV - none_none"='"+\n-"',
"P259.1_EOS.supp_HRV - EOS.supp_none"='"+\n+"',
"P259.1_EOS.supp_none - none_none"='"-\n+"',
"P259.1_EOS.supp_HRV - none_HRV"='"+\n+"'),
facet.lab = recode_factor(factor(dataset),
"P259.1" = '"EOS sup"',
"P259.2" = '"Anti-IL-5/5R"*alpha')) %>%
dplyr::select(facet.lab, group1, group2, symbol)
#Add y location for pval based on max expression in plot
GOI.pe <- dat2 %>%
#Max expression per gene and experiment
group_by(experiment) %>%
summarise(max.e = max(RhinoVirusA_normCount, na.rm=TRUE)) %>%
ungroup() %>%
mutate(facet.lab = experiment,
facet.lab = recode_factor(factor(facet.lab),
"P259_1" = '"EOS sup"',
"P259_2" = '"Anti-IL-5/5R"*alpha')) %>%
#Add to pval data
right_join(GOI.p) %>%
arrange(experiment, group1, group2)
#first entry per gene
#Set y position to 1
first <- GOI.pe %>%
group_by(experiment) %>%
slice(1) %>%
mutate(y.position1 = 1)
#Add first position data back and fill in remaining
GOI.pey <- GOI.pe %>%
full_join(first) %>%
#Fill in positions 2 - N
group_by(experiment, facet.lab) %>%
mutate(y.position2 = lag(y.position1)+1,
y.position3 = lag(y.position2)+1,
y.position4 = lag(y.position3)+1) %>%
#Collapse positions into 1 column
mutate(y.position = ifelse(!is.na(y.position1),y.position1,
ifelse(!is.na(y.position2),y.position2,
ifelse(!is.na(y.position3),y.position3,
ifelse(!is.na(y.position4),y.position4,NA))))) %>%
#Scale to max expression
mutate(y.position = max.e+y.position*5E3) %>%
ungroup()
#plot
plot3 <- dat2 %>%
mutate(x.lab=paste(experiment, virus.detail, IL5, sep="_"),
x.lab=gsub("oldH|newH", "", x.lab),
x.lab=recode_factor(factor(x.lab),
"P259_1_none_none"='"RV -\nEOS sup -"',
"P259_2_none_none"='"-\n-"',
"P259_1_none_EOS.supp"='"-\n+"',
"P259_2_none_AntiIL5"='"-\n+"',
"P259_1_RV_none"='"+\n-"',
"P259_2_RV_none"='"+\n-"',
"P259_1_RV_EOS.supp"='"+\n+"',
"P259_2_RV_AntiIL5"='"+ RV\n+ Anti-IL-5/5R"*alpha')) %>%
mutate(facet.lab = experiment,
facet.lab = recode_factor(factor(facet.lab),
"P259_1" = '"EOS sup"',
"P259_2" = '"Anti-IL-5/5R"*alpha')) %>%
arrange(facet.lab) %>%
ggplot(aes(x=x.lab, y=RhinoVirusA_normCount, color=donorID)) +
geom_jitter(width=0.1, height=0) +
stat_summary(fun.data=mean_sdl,
fun.args = list(mult=1),
geom="errorbar", color="black", width=0.25) +
stat_summary(fun=mean, geom="errorbar",
aes(ymax=..y.., ymin=..y..),
color="black", width=0.5) +
facet_grid(~facet.lab, scales="free",
labeller = labeller(facet.lab=label_parsed)) +
#Add pval
stat_pvalue_manual(data=GOI.pey,
label="symbol", xmin="group1", xmax="group2") +
# #Beautify
theme_bw() +
labs(x="", y="Normalized RV expression") +
theme(legend.position = "none",
panel.grid.major.y = element_blank(),
panel.grid.minor.y = element_blank(),
strip.background =element_rect(fill="white"),
axis.text.x=element_text(hjust=0.95,vjust=-0.5),
plot.margin = margin(0.2,0.2,0.2,0.2,"cm")) +
scale_x_discrete(labels = ggplot2:::parse_safe)
plot3
```

# R session

```{r}
sessionInfo()
```

***
565 changes: 565 additions & 0 deletions 3.P259.pDC_response.to.review.html

Large diffs are not rendered by default.

Binary file added 3.P259.pDC_response.to.review.pdf
Binary file not shown.
Binary file modified publication/fig/Fig5.GSEA.pdf
Binary file not shown.
Binary file added publication/fig/Fig5.GSEA.tif
Binary file not shown.
Binary file removed publication/fig/Fig6.GSEA.fold.change.pdf
Binary file not shown.
Binary file added publication/fig/Fig6.genes.of.interest_nudge.pdf
Binary file not shown.
Binary file added publication/fig/Fig6.genes.of.interest_nudge.tif
Binary file not shown.
Binary file removed publication/fig/Fig7.genes.of.interest.pdf
Binary file not shown.
Binary file removed publication/fig/Fig7.genes.of.interest_nudge.pdf
Binary file not shown.
Binary file removed publication/fig/FigE1.PCA.pdf
Binary file not shown.
Binary file added publication/fig/FigE2.PCA.pdf
Binary file not shown.
Binary file added publication/fig/FigE2.PCA.tif
Binary file not shown.
Binary file added publication/fig/FigE3.RV.seqs.nudge.pdf
Binary file not shown.
Binary file added publication/fig/FigE3.RV.seqs.nudge.tif
Binary file not shown.
Binary file added publication/fig/FigE3.RV.seqs.pdf
Binary file not shown.
Binary file removed publication/fig/FigE3.STRING.network.pdf
Binary file not shown.
Binary file not shown.
Binary file added publication/fig/FigE4.GSEA.term.venn.tif
Binary file not shown.
Binary file added publication/fig/FigE5.GSEA.fold.change.pdf
Binary file not shown.
Binary file added publication/fig/FigE5.GSEA.fold.change.tif
Binary file not shown.
Binary file added publication/fig/FigE6.STRING.network.nudge.pdf
Binary file not shown.
Binary file added publication/fig/FigE6.STRING.network.nudge.tif
Binary file not shown.
Binary file modified publication/fig/to.label.DEG.RData
Binary file not shown.
Binary file modified publication/fig/to.label.LE.RData
Binary file not shown.
Loading

0 comments on commit 1958aff

Please sign in to comment.