Pull protein mods

protMods <- PWBAnalysis::grabProteinMods()
protMods

Get targetScan database

tsDf <- PWBAnalysis::grabTargetScanTargets()

Filter down to two targets of interest

tsDfReduced <- PWBAnalysis::getTargetScanTargets(miRs = c('miR-484/3155','miR-197-3p'))
tsDfReduced

Turn both protein mods and targets into lists for mutual enrichment analyses

tsDfReducedR <- dplyr::select(tsDfReduced,`miR Family`,`Gene Symbol`)
tsDfReducedR <- tsDfReducedR[!duplicated(tsDfReducedR),]
tsDfReducedR$`miR Family`[tsDfReducedR$`miR Family` == 'miR-484/3155'] <- 'miR-484'
mrnaList <- lapply(unique(tsDfReducedR$`miR Family`),utilityFunctions::listify,tsDfReducedR$`Gene Symbol`,tsDfReducedR$`miR Family`)
names(mrnaList) <- unique(tsDfReducedR$`miR Family`)

actDf <- dplyr::filter(protMods,Study=='ACT')
actList <- lapply(unique(actDf$Module),utilityFunctions::listify,actDf$Gene,actDf$Module)
names(actList) <- unique(actDf$Module)

blsaDf <- dplyr::filter(protMods,Study=='BLSA')
blsaList <- lapply(unique(blsaDf$Module),utilityFunctions::listify,blsaDf$Gene,blsaDf$Module)
names(blsaList) <- unique(blsaDf$Module)

Run mutual enrichment analysis

library(dplyr)
actPval <- utilityFunctions::outerSapply(utilityFunctions::fisherWrapperPval,
                                         actList,
                                         mrnaList,
                                         allGenes = actDf$Gene)

blsaPval <- utilityFunctions::outerSapply(utilityFunctions::fisherWrapperPval,
                                          blsaList,
                                          mrnaList,
                                          allGenes = blsaDf$Gene)

actPval2 <- data.frame(t(actPval),stringsAsFactors=F)
actPval2$module <- row.names(actPval2)
actPval3 <- tidyr::gather(actPval2,key='key',value='value',1:2)
actPval3$pAdj <- p.adjust(actPval3$value,method='fdr')

blsaPval2 <- data.frame(t(blsaPval),stringsAsFactors=F)
blsaPval2$module <- row.names(blsaPval2)
blsaPval3 <- tidyr::gather(blsaPval2,key='key',value='value',1:2)
blsaPval3$pAdj <- p.adjust(blsaPval3$value,method='fdr')

Make a nice tidy figure for BLSA

g <- ggplot2::ggplot(blsaPval3,ggplot2::aes(x=module,
                                            y= -log10(pAdj),
                                            fill = key))

g <- g + ggplot2::geom_col(position = 'dodge')
g <- g + ggplot2::theme(axis.text.x = ggplot2::element_text(angle = 90, hjust = 1))
g <- g + ggplot2::geom_hline(ggplot2::aes(colour = 'red'),yintercept = -log10(0.05))
g <- g + ggplot2::ggtitle('BLSA miRNA target Gene Set enrichments')
g

Make a nice tidy figure for ACT

g <- ggplot2::ggplot(actPval3,ggplot2::aes(x=module,
                                            y= -log10(pAdj),
                                            fill = key))

g <- g + ggplot2::geom_col(position = 'dodge')
g <- g + ggplot2::theme(axis.text.x = ggplot2::element_text(angle = 90, hjust = 1))
g <- g + ggplot2::geom_hline(ggplot2::aes(colour = 'red'),yintercept = -log10(0.05))
g <- g + ggplot2::ggtitle('ACT miRNA target Gene Set enrichments')
g

Table of targets

n1 <- intersect(blsaList$`B-M1`,mrnaList$`miR-484`)
n2 <- intersect(blsaList$`B-M4`,mrnaList$`miR-484`)
n3 <- intersect(blsaList$`B-M1`,mrnaList$`miR-197-3p`)
n4 <- intersect(blsaList$`B-M4`,mrnaList$`miR-197-3p`)
targetTable <- data.frame(Gene = c(n1,n2,n3,n4),
                          Module = c(rep('B-M1',length(n1)),
                                                           rep('B-M4',length(n2)),
                                                           rep('B-M1',length(n3)),
                                                           rep('B-M4',length(n4))),
                          miRNA = c(rep('miR-484',length(n1)+length(n2)),
                                    rep('miR-197-3p',length(n3)+length(n4))),
                          stringsAsFactors = F)
targetTable
write.csv(targetTable,file='BLSAmiRNATargetTable.csv',quote=F,row.names=F)


blogsdon/PWBAnalysis documentation built on May 20, 2019, 8:30 a.m.