Last updated: 2021-03-15
Checks: 6 1
Knit directory: CLLproteomics_batch13/analysis/
This reproducible R Markdown analysis was created with workflowr (version 1.6.2). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.
The R Markdown is untracked by Git. To know which version of the R Markdown file created these results, you’ll want to first commit it to the Git repo. If you’re still working on the analysis, you can ignore this warning. When you’re finished, you can run wflow_publish
to commit the R Markdown file and build the HTML.
Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.
The command set.seed(20200227)
was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.
Great job! Recording the operating system, R version, and package versions is critical for reproducibility.
Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.
Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.
Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.
The results in this page were generated with repository version 3fb50c5. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.
Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish
or wflow_git_commit
). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:
Ignored files:
Ignored: .DS_Store
Ignored: .Rhistory
Ignored: .Rproj.user/
Ignored: analysis/.DS_Store
Ignored: analysis/.Rhistory
Ignored: analysis/manuscript_S1_Overview_cache/
Ignored: analysis/manuscript_S3_trisomy12_cache/
Ignored: analysis/manuscript_S8_drugResponse_Outcomes_cache/
Ignored: analysis/manuscript_S9_STAT2_cache/
Ignored: code/.DS_Store
Ignored: code/.Rhistory
Ignored: data/.DS_Store
Ignored: output/.DS_Store
Untracked files:
Untracked: analysis/.trisomy12_norm.pdf
Untracked: analysis/STAT2splicing.Rmd
Untracked: analysis/analysisBatch2.Rmd
Untracked: analysis/bufferAnalysis.Rmd
Untracked: analysis/cohortComposition.pdf
Untracked: analysis/cohortComposition_batch2.pdf
Untracked: analysis/compareBatchClinics.Rmd
Untracked: analysis/compareBatchGenomics.Rmd
Untracked: analysis/compareTreatment.Rmd
Untracked: analysis/complexAnalysis_overall.Rmd
Untracked: analysis/corumPairs.csv
Untracked: analysis/manuscript_S1_Overview.Rmd
Untracked: analysis/manuscript_S2_genomicAssociation.Rmd
Untracked: analysis/manuscript_S3_trisomy12.Rmd
Untracked: analysis/manuscript_S4_trisomy19.Rmd
Untracked: analysis/manuscript_S5_IGHV.Rmd
Untracked: analysis/manuscript_S6_del11q.Rmd
Untracked: analysis/manuscript_S7_SF3B1.Rmd
Untracked: analysis/manuscript_S8_drugResponse_Outcomes.Rmd
Untracked: analysis/manuscript_S9_STAT2.Rmd
Untracked: analysis/patInfoTab.csv
Untracked: analysis/patInfoTab.tex
Untracked: analysis/protRNACor_eachPat.pdf
Untracked: analysis/test.pdf
Untracked: code/utils.R
Untracked: data/CNV_onChrom.RData
Untracked: data/ComplexParticipantsPubMedIdentifiers_human.txt
Untracked: data/Fig1A.png
Untracked: data/Western_blot_results_20210309_short.csv
Untracked: data/allComplexes.txt
Untracked: data/ddsrna_enc.RData
Untracked: data/exprCNV_enc.RData
Untracked: data/geneAnno.RData
Untracked: data/gmts/
Untracked: data/ic50.RData
Untracked: data/patMeta_enc.RData
Untracked: data/pepCLL_lumos_enc.RData
Untracked: data/proteins_in_complexes
Untracked: data/proteomic_explore_enc.RData
Untracked: data/proteomic_independent_enc.RData
Untracked: data/proteomic_timsTOF_enc.RData
Untracked: data/screenData_enc.RData
Untracked: data/survival_enc.RData
Untracked: output/MSH6_splicing.svg
Untracked: output/SUGP1_splicing.svg
Untracked: output/deResList.RData
Untracked: output/deResListBatch2.RData
Untracked: output/deResListRNA.RData
Untracked: output/deResList_WBC.RData
Untracked: output/deResList_batch1.RData
Untracked: output/deResList_batch3.RData
Untracked: output/deResList_timsTOF.RData
Untracked: output/dxdCLL.RData
Untracked: output/dxdCLL2.RData
Untracked: output/exprCNV.RData
Untracked: output/geneAnno.RData
Untracked: output/int_pairs.csv
Untracked: output/resOutcome_batch1.RData
Untracked: output/resOutcome_batch13.RData
Untracked: output/resOutcome_batch2.RData
Untracked: output/resOutcome_batch3.RData
Unstaged changes:
Modified: analysis/_site.yml
Deleted: analysis/analysisSF3B1.Rmd
Deleted: analysis/comparePlatforms.Rmd
Deleted: analysis/compareProteomicsRNAseq.Rmd
Deleted: analysis/correlateCLLPD.Rmd
Deleted: analysis/correlateGenomic.Rmd
Deleted: analysis/correlateGenomic_removePC.Rmd
Deleted: analysis/correlateMIR.Rmd
Deleted: analysis/correlateMethylationCluster.Rmd
Modified: analysis/index.Rmd
Deleted: analysis/predictOutcome.Rmd
Deleted: analysis/processProteomics_LUMOS.Rmd
Deleted: analysis/processProteomics_timsTOF.Rmd
Deleted: analysis/qualityControl_LUMOS.Rmd
Deleted: analysis/qualityControl_timsTOF.Rmd
Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.
There are no past versions. Publish this analysis with wflow_publish()
to start tracking its development.
library(limma)
library(DESeq2)
library(proDA)
library(IHW)
library(SummarizedExperiment)
library(tidyverse)
#load datasets
load("../data/patMeta_enc.RData")
load("../data/ddsrna_enc.RData")
load("../data/proteomic_explore_enc.RData")
source("../code/utils.R")
knitr::opts_chunk$set(echo = TRUE, warning = FALSE, message = FALSE,dev = c("png","pdf"))
#protCLL <- protCLL[,colnames(protCLL) %in% patMeta$Patient.ID]
#protCLL <- protCLL[rowData(protCLL)$uniqueMap,]
protMat <- assays(protCLL)[["count"]] #without imputation
protMatLog <- assays(protCLL)[["log2Norm"]]
geneMat <- patMeta[match(colnames(protMat), patMeta$Patient.ID),] %>%
select(Patient.ID, IGHV.status, del11q:U1) %>%
mutate_if(is.factor, as.character) %>% mutate(IGHV.status = ifelse(IGHV.status == "M", 1,0)) %>%
mutate_at(vars(-Patient.ID), as.numeric) %>% #assign a few unknown mutated cases to wildtype
data.frame() %>% column_to_rownames("Patient.ID")
geneMat <- geneMat[,apply(geneMat,2, function(x) sum(x %in% 1, na.rm = TRUE))>=5]
Mutations that will be tested
colnames(geneMat)
[1] "IGHV.status" "del11q" "del13q" "del17p" "trisomy12"
[6] "trisomy19" "ATM" "BRAF" "DDX3X" "EGR2"
[11] "MED12" "NOTCH1" "SF3B1" "TP53"
Fit the probailistic dropout model
designMat <- geneMat[ ,c("IGHV.status","trisomy12")]
designMat[,"batch"] <- factor(protCLL[,rownames(designMat)]$batch)
fit <- proDA(protMat, design = ~ . ,
col_data = designMat)
Limma for calculating log2 fold change
lmDesign <- model.matrix(~., designMat)
lmFit <- lmFit(protMatLog, design = lmDesign)
fit2 <- eBayes(lmFit)
Test for differentially expressed proteins
resList.ighvTri12 <- lapply(c("IGHV.status","trisomy12"), function(n) {
contra <- n
resTab <- test_diff(fit, contra) %>%
dplyr::rename(id = name, logFC = diff, t=t_statistic,
P.Value = pval, adj.P.Val = adj_pval) %>%
mutate(name = rowData(protCLL[id,])$hgnc_symbol) %>%
select(name, id, logFC, t, P.Value, adj.P.Val, n_obs) %>%
arrange(P.Value) %>% mutate(Gene = n) %>%
as_tibble()
foldTab <- topTable(fit2, coef = n, number = "all") %>%
as_tibble(rownames = "id") %>% select(id, logFC) %>%
dplyr::rename(log2FC = logFC)
resTab <- left_join(resTab, foldTab, by = "id")
resTab
}) %>% bind_rows()
Fit the probailistic dropout model and test for differentially expressed proteins
otherGenes <- colnames(geneMat)[!colnames(geneMat)%in% c("IGHV.status","trisomy12")]
resList <- lapply(otherGenes, function(n) {
designMat <- geneMat[,c("IGHV.status","trisomy12",n)]
designMat[,"batch"] <- factor(protCLL[,rownames(designMat)]$batch)
designMat <- designMat[!is.na(designMat[[n]]),]
testMat <- protMat[,rownames(designMat)]
fit <- proDA(testMat, design = ~ .,
col_data = designMat)
contra <- n
resTab <- test_diff(fit, contra) %>%
dplyr::rename(id = name, logFC = diff, t=t_statistic,
P.Value = pval, adj.P.Val = adj_pval) %>%
mutate(name = rowData(protCLL[id,])$hgnc_symbol) %>%
select(name, id, logFC, t, P.Value, adj.P.Val, n_obs) %>%
arrange(P.Value) %>% mutate(Gene = n) %>%
as_tibble()
#calculte log2 fold change
lmDesign <- model.matrix(~., designMat)
protMatTest <- protMatLog[,rownames(lmDesign)]
lmFit <- lmFit(protMatTest, design = lmDesign)
fit2 <- eBayes(lmFit)
foldTab <- topTable(fit2, coef = n, number = "all") %>%
as_tibble(rownames = "id") %>% select(id, logFC) %>%
dplyr::rename(log2FC = logFC)
resTab <- left_join(resTab, foldTab, by = "id")
resTab
}) %>% bind_rows()
Combine the results
resList <- bind_rows(resList.ighvTri12, resList)
#Adjusting p values
#using BH
resList <- mutate(resList, adj.P.global = p.adjust(P.Value, method = "BH"))
#using IHW
ihwRes <- ihw(P.Value ~ factor(Gene), data= resList, alpha=0.1)
resList <- mutate(resList, adj.P.IHW = adj_pvalues(ihwRes))
Calculate Q value for all tests
qobj <- qvalue(resList$P.Value)
resList$Q.Value.global <- qobj$qvalues
Calcualte Q values for test in individual genes
resListNew <- lapply(unique(resList$Gene), function(gn) {
eachTab <- filter(resList, Gene == gn)
qobj <- qvalue(eachTab$P.Value)
eachTab$Q.Value.local <- qobj$qvalues
eachTab
}) %>% bind_rows()
resList <- resListNew
Save the results for re-using
save(resList, file = "../output/deResList.RData")
Load the pre-calculated results (differential expression tests take long time.)
load("../output/deResList.RData")
fdrCut = 0.1
plotTab <- resList %>% group_by(Gene) %>%
summarise(nFDR.local = sum(adj.P.Val <= fdrCut),
nFDR.global = sum(adj.P.global <= fdrCut),
nFDR.IHW = sum(adj.P.IHW <= fdrCut),
nFDR.Q.global = sum(Q.Value.global <=fdrCut),
nFDR.Q.local = sum(Q.Value.local < fdrCut),
nP = sum(P.Value < 0.05))
P values adjusted for each variant
#local adjusted P-values
plotTab <- arrange(plotTab, desc(nFDR.local)) %>% mutate(Gene = factor(Gene, levels = Gene))
ggplot(plotTab, aes(x=Gene, y = nFDR.local)) + geom_bar(stat="identity",fill=colList[2]) +
geom_text(aes(label = paste0("n=", nFDR.local)),vjust=-1,col=colList[1]) +
theme_half + theme(axis.text.x = element_text(angle = 90, hjust=1, vjust=0.5)) +
ylab("Number of associations\n(10% FDR)") + xlab("")
P-values adjusted for all tests together
#Global adjusted P-values
plotTab <- arrange(plotTab, desc(nFDR.global)) %>% mutate(Gene = factor(Gene, levels = Gene))
ggplot(plotTab, aes(x=Gene, y = nFDR.global)) + geom_bar(stat="identity",fill=colList[2]) +
geom_text(aes(label = paste0("n=", nFDR.global)),vjust=-1,col=colList[1]) +
theme_half + theme(axis.text.x = element_text(angle = 90, hjust=1, vjust=0.5)) +
ylab("Number of associations\n(10% FDR)") + xlab("")
Q values for all test
#IHW adjusted p-values
plotTab <- arrange(plotTab, desc(nFDR.Q.global)) %>% mutate(Gene = factor(Gene, levels = Gene))
ggplot(plotTab, aes(x=Gene, y = nFDR.Q.global)) + geom_bar(stat="identity",fill=colList[2]) +
geom_text(aes(label = paste0("n=", nFDR.Q.global)),vjust=-1,col=colList[1]) +
theme_half + theme(axis.text.x = element_text(angle = 90, hjust=1, vjust=0.5)) +
ylab("Number of associations\n(10% FDR)") + xlab("")
Q values for individual genes
#IHW adjusted p-values
plotTab <- arrange(plotTab, desc(nFDR.Q.local)) %>% mutate(Gene = factor(Gene, levels = Gene))
ggplot(plotTab, aes(x=Gene, y = nFDR.Q.local)) + geom_bar(stat="identity",fill=colList[2]) +
geom_text(aes(label = paste0("n=", nFDR.Q.local)),vjust=-1,col=colList[1]) +
theme_half + theme(axis.text.x = element_text(angle = 90, hjust=1, vjust=0.5)) +
ylab("Number of associations\n(10% FDR)") + xlab("")
IHW adjusted p-values
#IHW adjusted p-values
plotTab <- arrange(plotTab, desc(nFDR.IHW)) %>% mutate(Gene = factor(Gene, levels = Gene))
ggplot(plotTab, aes(x=Gene, y = nFDR.IHW)) + geom_bar(stat="identity",fill=colList[2]) +
geom_text(aes(label = paste0("n=", nFDR.IHW)),vjust=-1,col=colList[1]) +
theme_half + theme(axis.text.x = element_text(angle = 90, hjust=1, vjust=0.5)) +
ylab("Number of associations\n(10% FDR)") + xlab("")
fdrCut = 0.05
plotTab <- resList %>% group_by(Gene) %>%
summarise(nFDR.local = sum(adj.P.Val <= fdrCut),
nFDR.global = sum(adj.P.global <= fdrCut),
nFDR.IHW = sum(adj.P.IHW <= fdrCut),
nFDR.Q.global = sum(Q.Value.global <=fdrCut),
nFDR.Q.local = sum(Q.Value.local < fdrCut),
nP = sum(P.Value < 0.05))
P values adjusted for each variant
#local adjusted P-values
plotTab <- arrange(plotTab, desc(nFDR.local)) %>% mutate(Gene = factor(Gene, levels = Gene))
ggplot(plotTab, aes(x=Gene, y = nFDR.local)) + geom_bar(stat="identity",fill=colList[2]) +
geom_text(aes(label = paste0("n=", nFDR.local)),vjust=-1,col=colList[1]) +
theme_half + theme(axis.text.x = element_text(angle = 90, hjust=1, vjust=0.5)) +
ylab("Number of associations\n(5% FDR)") + xlab("")
P-values adjusted for all tests together
#Global adjusted P-values
plotTab <- arrange(plotTab, desc(nFDR.global)) %>% mutate(Gene = factor(Gene, levels = Gene))
ggplot(plotTab, aes(x=Gene, y = nFDR.global)) + geom_bar(stat="identity",fill=colList[2]) +
geom_text(aes(label = paste0("n=", nFDR.global)),vjust=-1,col=colList[1]) +
theme_half + theme(axis.text.x = element_text(angle = 90, hjust=1, vjust=0.5)) +
ylab("Number of associations\n(5% FDR)") + xlab("")
Q values for all test
#IHW adjusted p-values
plotTab <- arrange(plotTab, desc(nFDR.Q.global)) %>% mutate(Gene = factor(Gene, levels = Gene))
ggplot(plotTab, aes(x=Gene, y = nFDR.Q.global)) + geom_bar(stat="identity",fill=colList[2]) +
geom_text(aes(label = paste0("n=", nFDR.Q.global)),vjust=-1,col=colList[1]) +
theme_half + theme(axis.text.x = element_text(angle = 90, hjust=1, vjust=0.5)) +
ylab("Number of associations\n(5% FDR)") + xlab("")
Q values for individual genes
#IHW adjusted p-values
plotTab <- arrange(plotTab, desc(nFDR.Q.local)) %>% mutate(Gene = factor(Gene, levels = Gene))
ggplot(plotTab, aes(x=Gene, y = nFDR.Q.local)) + geom_bar(stat="identity",fill=colList[2]) +
geom_text(aes(label = paste0("n=", nFDR.Q.local)),vjust=-1,col=colList[1]) +
theme_half + theme(axis.text.x = element_text(angle = 90, hjust=1, vjust=0.5)) +
ylab("Number of associations\n(5% FDR)") + xlab("")
IHW adjusted p-values
#IHW adjusted p-values
plotTab <- arrange(plotTab, desc(nFDR.IHW)) %>% mutate(Gene = factor(Gene, levels = Gene))
ggplot(plotTab, aes(x=Gene, y = nFDR.IHW)) + geom_bar(stat="identity",fill=colList[2]) +
geom_text(aes(label = paste0("n=", nFDR.IHW)),vjust=-1,col=colList[1]) +
theme_half + theme(axis.text.x = element_text(angle = 90, hjust=1, vjust=0.5)) +
ylab("Number of associations\n(5% FDR)") + xlab("")
plotTab <- arrange(plotTab, desc(nP)) %>% mutate(Gene = factor(Gene, levels = Gene))
ggplot(plotTab, aes(x=Gene, y = nP)) + geom_bar(stat="identity",fill=colList[2]) +
geom_text(aes(label = paste0("n=", nP)),vjust=-1,col=colList[1]) + ylim(0,1500) +
theme_half + theme(axis.text.x = element_text(angle = 90, hjust=1, vjust=0.5)) +
ylab("Number of associations\n(nominal P-value < 0.05)") + xlab("")
ggplot(resList, aes(x=P.Value)) + geom_histogram() +
facet_wrap(~Gene)
Fit the probailistic dropout model
designMat <- geneMat[ ,c("IGHV.status","trisomy12")]
designMat[,"batch"] <- factor(protCLL[,rownames(designMat)]$batch)
designMat[,"LeukCount"] <- log10(sampleTab[match(rownames(designMat), sampleTab$encID),]$leukCount)
fit <- proDA(protMat, design = ~ . ,
col_data = designMat)
Limma for calculating log2 fold change
lmDesign <- model.matrix(~., designMat)
lmFit <- lmFit(protMatLog, design = lmDesign)
fit2 <- eBayes(lmFit)
Test for differentially expressed proteins
resList.ighvTri12 <- lapply(c("IGHV.status","trisomy12"), function(n) {
contra <- n
resTab <- test_diff(fit, contra) %>%
dplyr::rename(id = name, logFC = diff, t=t_statistic,
P.Value = pval, adj.P.Val = adj_pval) %>%
mutate(name = rowData(protCLL[id,])$hgnc_symbol) %>%
select(name, id, logFC, t, P.Value, adj.P.Val, n_obs) %>%
arrange(P.Value) %>% mutate(Gene = n) %>%
as_tibble()
foldTab <- topTable(fit2, coef = n, number = "all") %>%
as_tibble(rownames = "id") %>% select(id, logFC) %>%
dplyr::rename(log2FC = logFC)
resTab <- left_join(resTab, foldTab, by = "id")
resTab
}) %>% bind_rows()
Fit the probailistic dropout model and test for differentially expressed proteins
otherGenes <- colnames(geneMat)[!colnames(geneMat)%in% c("IGHV.status","trisomy12")]
resList <- lapply(otherGenes, function(n) {
designMat <- geneMat[,c("IGHV.status","trisomy12",n)]
designMat[,"batch"] <- factor(protCLL[,rownames(designMat)]$batch)
designMat[,"LeukCount"] <- log10(sampleTab[match(rownames(designMat), sampleTab$encID),]$leukCount)
designMat <- designMat[!is.na(designMat[[n]]),]
testMat <- protMat[,rownames(designMat)]
fit <- proDA(testMat, design = ~ .,
col_data = designMat)
contra <- n
resTab <- test_diff(fit, contra) %>%
dplyr::rename(id = name, logFC = diff, t=t_statistic,
P.Value = pval, adj.P.Val = adj_pval) %>%
mutate(name = rowData(protCLL[id,])$hgnc_symbol) %>%
select(name, id, logFC, t, P.Value, adj.P.Val, n_obs) %>%
arrange(P.Value) %>% mutate(Gene = n) %>%
as_tibble()
#calculte log2 fold change
lmDesign <- model.matrix(~., designMat)
protMatTest <- protMatLog[,rownames(lmDesign)]
lmFit <- lmFit(protMatTest, design = lmDesign)
fit2 <- eBayes(lmFit)
foldTab <- topTable(fit2, coef = n, number = "all") %>%
as_tibble(rownames = "id") %>% select(id, logFC) %>%
dplyr::rename(log2FC = logFC)
resTab <- left_join(resTab, foldTab, by = "id")
resTab
}) %>% bind_rows()
Combine the results
resList_WBC <- bind_rows(resList.ighvTri12, resList)
Save the results for re-using
save(resList_WBC, file = "../output/deResList_WBC.RData")
Load the pre-calculated results (differential expression tests take long time.)
load("../output/deResList_WBC.RData")
load("../output/deResList.RData")
tabNoBlock <- resList %>% mutate(ifSig = adj.P.Val <= 0.05) %>%
select(id, Gene, P.Value, ifSig)
tabBlock <- resList_WBC %>% mutate(ifSig.block = adj.P.Val < 0.05, P.Value.block = P.Value) %>%
select(id, Gene, P.Value.block, ifSig.block)
compareTab <- left_join(tabNoBlock, tabBlock, by = c("id","Gene")) %>%
mutate(group = case_when(
ifSig & ifSig.block ~ "significant in both",
ifSig & !ifSig.block ~ "significant only without blocking",
!ifSig & ifSig.block ~ "significant only with blocking",
TRUE ~ "not significant in both"
))
ggplot(compareTab, aes(x=-log10(P.Value), y=-log10(P.Value.block), col = group)) +
geom_point(alpha=0.5) +
xlab("-log10(P value) without blocking") + ylab("-log10 (P value) with blocking for WBC counts") +
scale_color_manual(values = c("grey80", colList[2], colList[1], colList[3]), name = "") +
geom_abline(slope = 1, linetype ="dashed") +
ggtitle("Associations with genomics") +
theme_full +
theme(legend.position = c(0.7,0.2))
Number of associations in each catagory
tt <- table(compareTab$group)
tt
not significant in both significant in both
49616 3106
significant only with blocking significant only without blocking
58 244
A percentage of consistent results
(tt[1] + tt[2])/sum(tt)*100
not significant in both
99.43045
Subset for samples with proteomics
ddsSub <- dds[,dds$PatID %in% colnames(protCLL)]
#how many samples?
ncol(ddsSub)
[1] 82
Subset for genes detected at protein level
ddsSub <- ddsSub[rownames(ddsSub) %in% rowData(protCLL)$ensembl_gene_id,]
#how many genes without any RNA expression detected?
table(rowSums(counts(ddsSub)) > 0)
FALSE TRUE
12 3291
ddsSub <- ddsSub[rowSums(counts(ddsSub)) > 0, ]
12 genes were not detected at RNA level, they are removed from anaysis
How many gene and samples left?
dim(ddsSub)
[1] 3291 82
colData(ddsSub) <- cbind(colData(ddsSub), geneMat[colnames(ddsSub),])
design(ddsSub) <- ~ IGHV.status + trisomy12
deRes <- DESeq(ddsSub)
Test for differentially expressed proteins
resList.ighvTri12 <- lapply(c("IGHV.status","trisomy12"), function(n) {
resTab <- results(deRes, name = n, tidy = TRUE) %>%
dplyr::rename(id = row, log2FC = log2FoldChange, t=stat,
P.Value = pvalue, adj.P.Val = padj) %>%
mutate(name = rowData(ddsSub[id,])$symbol) %>%
select(name, id, log2FC, t, P.Value, adj.P.Val) %>%
arrange(P.Value) %>% mutate(Gene = n) %>%
as_tibble()
}) %>% bind_rows()
otherGenes <- colnames(geneMat)[!colnames(geneMat)%in% c("IGHV.status","trisomy12")]
resList <- lapply(otherGenes, function(n) {
ddsTest <- ddsSub[,!is.na(ddsSub[[n]])]
design(ddsTest) <- as.formula(paste0("~ IGHV.status + trisomy12 + ",n))
deRes <- DESeq(ddsTest)
resTab <- results(deRes, name = n, tidy = TRUE) %>%
dplyr::rename(id = row, log2FC = log2FoldChange, t=stat,
P.Value = pvalue, adj.P.Val = padj) %>%
mutate(name = rowData(ddsSub[id,])$symbol) %>%
select(name, id, log2FC, t, P.Value, adj.P.Val) %>%
arrange(P.Value) %>% mutate(Gene = n) %>%
as_tibble()
resTab
}) %>% bind_rows()
Combine the results
resListRNA <- bind_rows(resList.ighvTri12, resList)
Save the results for re-using
save(resListRNA, file = "../output/deResListRNA.RData")
Load the pre-calculated results (differential expression tests take long time.)
load("../output/deResListRNA.RData")
fdrCut = 0.05
plotTab <- resListRNA %>% group_by(Gene) %>%
summarise(nFDR.local = sum(adj.P.Val <= fdrCut, na.rm=TRUE),
nP = sum(P.Value < 0.05))
P values adjusted for each variant
#local adjusted P-values
plotTab <- arrange(plotTab, desc(nFDR.local)) %>% mutate(Gene = factor(Gene, levels = Gene))
ggplot(plotTab, aes(x=Gene, y = nFDR.local)) + geom_bar(stat="identity",fill=colList[2]) +
geom_text(aes(label = paste0("n=", nFDR.local)),vjust=-1,col=colList[1]) +
theme_half + theme(axis.text.x = element_text(angle = 90, hjust=1, vjust=0.5)) +
ylab("Number of associations\n(5% FDR)") + xlab("")
sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS 10.16
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] parallel stats4 stats graphics grDevices utils datasets
[8] methods base
other attached packages:
[1] latex2exp_0.4.0 forcats_0.5.1
[3] stringr_1.4.0 dplyr_1.0.5
[5] purrr_0.3.4 readr_1.4.0
[7] tidyr_1.1.3 tibble_3.1.0
[9] ggplot2_3.3.3 tidyverse_1.3.0
[11] IHW_1.16.0 proDA_1.2.0
[13] DESeq2_1.28.1 SummarizedExperiment_1.18.2
[15] DelayedArray_0.14.1 matrixStats_0.58.0
[17] Biobase_2.48.0 GenomicRanges_1.40.0
[19] GenomeInfoDb_1.24.2 IRanges_2.22.2
[21] S4Vectors_0.26.1 BiocGenerics_0.34.0
[23] limma_3.44.3
loaded via a namespace (and not attached):
[1] colorspace_2.0-0 ellipsis_0.3.1 rprojroot_2.0.2
[4] XVector_0.28.0 fs_1.5.0 rstudioapi_0.13
[7] farver_2.1.0 bit64_4.0.5 AnnotationDbi_1.50.3
[10] fansi_0.4.2 lubridate_1.7.10 xml2_1.3.2
[13] splines_4.0.2 cachem_1.0.4 geneplotter_1.66.0
[16] knitr_1.31 jsonlite_1.7.2 workflowr_1.6.2
[19] broom_0.7.5 annotate_1.66.0 dbplyr_2.1.0
[22] compiler_4.0.2 httr_1.4.2 backports_1.2.1
[25] assertthat_0.2.1 Matrix_1.3-2 fastmap_1.1.0
[28] cli_2.3.1 later_1.1.0.1 htmltools_0.5.1.1
[31] tools_4.0.2 gtable_0.3.0 glue_1.4.2
[34] GenomeInfoDbData_1.2.3 Rcpp_1.0.6 slam_0.1-48
[37] cellranger_1.1.0 jquerylib_0.1.3 vctrs_0.3.6
[40] xfun_0.21 rvest_1.0.0 lifecycle_1.0.0
[43] XML_3.99-0.5 zlibbioc_1.34.0 scales_1.1.1
[46] hms_1.0.0 promises_1.2.0.1 RColorBrewer_1.1-2
[49] yaml_2.2.1 memoise_2.0.0 sass_0.3.1
[52] stringi_1.5.3 RSQLite_2.2.3 highr_0.8
[55] genefilter_1.70.0 BiocParallel_1.22.0 rlang_0.4.10
[58] pkgconfig_2.0.3 bitops_1.0-6 evaluate_0.14
[61] lattice_0.20-41 lpsymphony_1.16.0 labeling_0.4.2
[64] bit_4.0.4 tidyselect_1.1.0 magrittr_2.0.1
[67] R6_2.5.0 generics_0.1.0 DBI_1.1.1
[70] pillar_1.5.1 haven_2.3.1 withr_2.4.1
[73] survival_3.2-7 RCurl_1.98-1.2 modelr_0.1.8
[76] crayon_1.4.1 fdrtool_1.2.16 utf8_1.1.4
[79] rmarkdown_2.7 locfit_1.5-9.4 grid_4.0.2
[82] readxl_1.3.1 blob_1.2.1 git2r_0.28.0
[85] reprex_1.0.0 digest_0.6.27 xtable_1.8-4
[88] httpuv_1.5.5 munsell_0.5.0 bslib_0.2.4