# Global options
options(max.print="75")
knitr::opts_chunk$set(
    eval = TRUE,
    message = FALSE,
    warning = FALSE,
    cache = TRUE,
    comment = NA,
    include = TRUE,
    prompt = FALSE,
    tidy = TRUE
)
knitr::opts_knit$set(width=75)

r runname

STRINGdb

Network

if (!is.null(stringdbRes) & length(stringdbRes) != 0) {
  link <- stringdbRes[['link']]
} else {
  link <- NULL
  print('No link available.')
}

View mapped genes on string-db website

GO

if (!is.null(stringdbRes$GO) & length(stringdbRes$GO) != 0) {
  table <- stringdbRes$GO %>%
    dplyr::rename(
      'Term Description' = term_description,
      'Term ID' = term_id,
      'Proteins' = proteins,
      'Hits' = hits,
      'p-Value' = pvalue,
      'p-Value (adj.)' = pvalue_fdr,
      'Genes in Term' = hit_term_genes
    )

  table <- makeTermsTable(
    table = table,
    genesDelim = ',',
    datasetURL = "https://www.ebi.ac.uk/QuickGO/term/",
    caption = NULL,
    includeColumns = c(
      'Term Description',
      'Proteins',
      'Hits',
      'p-Value (adj.)',
      'p-Value',
      'Genes in Term'
    )
  )
  table
} else {
  print('No significant enrichment found.')
}

KEGG

if (!is.null(stringdbRes$KEGG) & length(stringdbRes$KEGG) != 0) {
  table <- stringdbRes$KEGG %>%
    dplyr::rename(
      'Term Description' = term_description,
      'Term ID' = term_id,
      'Proteins' = proteins,
      'Hits' = hits,
      'p-Value' = pvalue,
      'p-Value (adj.)' = pvalue_fdr,
      'Genes in Term' = hit_term_genes
    )

  table <- makeTermsTable(
    table = table,
    genesDelim = ',',
    datasetURL = "https://www.genome.jp/dbget-bin/www_bget?map",
    caption = NULL,
    includeColumns = c(
      'Term Description',
      'Proteins',
      'Hits',
      'p-Value (adj.)',
      'p-Value',
      'Genes in Term'
    )
  )
  table
} else {
  print('No significant enrichment found.')
}

MSigDB

Enricher

Dotplot {.tabset .tabset-fade .tabset-pills}

if (!is.null(msigdbRes$enricher_result) &
    !is.null(nrow(msigdbRes$enricher_result))) {
  plotly::ggplotly(
    enrichplot::dotplot(msigdbRes$enricher_result) +
      ggplot2::theme(
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()
      )
  )
} else {
  print('No significant enrichment found.')
}
#### Cnetplot

if (!is.null(msigdbRes$enricher_result) &
    !is.null(nrow(msigdbRes$enricher_result))) {
    enrichplot::cnetplot(msigdbRes$enricher_result, categorySize = "p-Value (adj.)", foldChange = namedGeneList, circular = TRUE, colorEdge = TRUE )
} else {
  print('No significant enrichment found.')
}
#### Upsetplot

if (!is.null(msigdbRes$enricher_result) &
    !is.null(nrow(msigdbRes$enricher_result))) {
  enrichplot::upsetplot(msigdbRes$enricher_result)
} else {
  print('No significant enrichment found.')
}
#### Heatplot

if (!is.null(msigdbRes$enricher_result) &
    !is.null(nrow(msigdbRes$enricher_result))) {
  enrichplot::heatplot(msigdbRes$enricher_result, foldChange = namedGeneList)
} else {
  print('No significant enrichment found.')
}

{-}

if (!is.null(msigdbRes$enricher_result) &
    !is.null(nrow(msigdbRes$enricher_result))) {
  table <- msigdbRes$enricher_result %>% as.data.frame() %>%
    dplyr::rename(
      'Term Description' = Description,
      'Term ID' = ID,
      'geneID' = geneID,
      'Hits' = Count,
      'p-Value (adj.)' = pvalue,
      'p-Value' = p.adjust,
      'Genes in Term' = geneID
    )

  table <- makeTermsTable(
    table = table,
    genesDelim = '/',
    datasetURL = 'https://www.gsea-msigdb.org/gsea/msigdb/geneset_page.jsp?geneSetName=',
    caption = "Integrating MSigDB gene-sets with clusterProfiler's Enricher Pathway Analysis",
    includeColumns = c(
      'Term Description',
      'Hits',
      'p-Value (adj.)',
      'p-Value',
      'Genes in Term'
    )
  )
  table
} else {
  print('No significant enrichment found.')
}

FGSEA

Dotplot {.tabset .tabset-fade .tabset-pills}

if (!is.null(msigdbRes$fgsea_result_asenrich) &
    !is.null(nrow(msigdbRes$fgsea_result_asenrich))) {
  plotly::ggplotly(
    enrichplot::dotplot(msigdbRes$fgsea_result_asenrich) +
      ggplot2::theme(
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()
      )
  )
} else {
  print('No significant enrichment found.')
}
#### Cnetplot

if (!is.null(msigdbRes$fgsea_result_asenrich) &
    !is.null(nrow(msigdbRes$fgsea_result_asenrich))) {
    enrichplot::cnetplot(msigdbRes$fgsea_result_asenrich, categorySize = "p-Value (adj.)", foldChange = namedGeneList, circular = TRUE, colorEdge = TRUE)
} else {
  print('No significant enrichment found.')
}
#### Upsetplot

if (!is.null(msigdbRes$fgsea_result_asenrich) &
    !is.null(nrow(msigdbRes$fgsea_result_asenrich))) {
  enrichplot::upsetplot(msigdbRes$fgsea_result_asenrich)
} else {
  print('No significant enrichment found.')
}
#### Heatplot

if (!is.null(msigdbRes$fgsea_result_asenrich) &
    !is.null(nrow(msigdbRes$fgsea_result_asenrich))) {
  enrichplot::heatplot(msigdbRes$fgsea_result_asenrich, foldChange = namedGeneList)
} else {
  print('No significant enrichment found.')
}

{-}

if (!is.null(msigdbRes$fgsea_result_asenrich) &
    !is.null(nrow(msigdbRes$fgsea_result_asenrich))) {
  table <- msigdbRes$fgsea_result_asenrich %>% as.data.frame() %>%
    dplyr::rename(
      'Term Description' = Description,
      'Term ID' = ID,
      'geneID' = geneID,
      'Hits' = Count,
      'p-Value (adj.)' = pvalue,
      'p-Value' = p.adjust,
      'Genes in Term' = geneID
    )

  table <- makeTermsTable(
    table = table,
    genesDelim = '/',
    datasetURL = 'https://www.gsea-msigdb.org/gsea/msigdb/geneset_page.jsp?geneSetName=',
    caption = "Integrating MSigDB gene-sets with FGSEA",
    includeColumns = c(
      'Term Description',
      'Hits',
      'p-Value (adj.)',
      'p-Value',
      'Genes in Term'
    )
  )
  table
} else {
  print('No significant enrichment found.')
}

Reactome {.tabset .tabset-fade .tabset-pills}

Dotplot

if (!is.null(reactomeRes) &
    !is.null(nrow(reactomeRes))) {
  plotly::ggplotly(
    enrichplot::dotplot(reactomeRes) +
      ggplot2::theme(
        axis.title.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()
      )
  )
} else {
  print('No significant enrichment found.')
}
### Cnetplot

if (!is.null(reactomeRes) &
    !is.null(nrow(reactomeRes))) {
    enrichplot::cnetplot(reactomeRes, categorySize = "p-Value (adj.)", foldChange = namedGeneList, circular = TRUE, colorEdge = TRUE)
} else {
  print('No significant enrichment found.')
}
### Upsetplot

if (!is.null(reactomeRes) &
    !is.null(nrow(reactomeRes))) {
  enrichplot::upsetplot(reactomeRes)
} else {
  print('No significant enrichment found.')
}
### Heatplot

if (!is.null(reactomeRes) &
    !is.null(nrow(reactomeRes))) {
  enrichplot::heatplot(reactomeRes, foldChange = namedGeneList)
} else {
  print('No significant enrichment found.')
}

{-}

if (!is.null(reactomeRes) &
    !is.null(nrow(reactomeRes))) {
  table <- reactomeRes %>% as.data.frame() %>%
    dplyr::rename(
      'Term Description' = Description,
      'Term ID' = ID,
      'geneID' = geneID,
      'Hits' = Count,
      'p-Value (adj.)' = pvalue,
      'p-Value' = p.adjust,
      'Genes in Term' = geneID
    )

  table <- makeTermsTable(
    table = table,
    genesDelim = '/',
    datasetURL = "https://reactome.org/PathwayBrowser/#/",
    caption = NULL,
    includeColumns = c(
      'Term Description',
      'Hits',
      'p-Value (adj.)',
      'p-Value',
      'Genes in Term'
    )
  )
  table
} else {
  print('No significant enrichment found.')
}
### DAVID
enrichplot::dotplot(davidRes) + 
      scale_y_discrete(labels = function(x) stringr::str_wrap(stringr::str_replace_all(x, "pattern_" , "_"), width = 40))
table <- davidRes %>% as.data.frame() %>%
  dplyr::rename(
    'Term Description' = Description,
    'Term ID' = ID,
    'geneID' = geneID,
    'Hits' = Count,
    'p-Value (adj.)' = pvalue,
    'p-Value' = p.adjust,
    'Genes in Term' = geneID
  )

table <- makeTermsTable(
  table = table,
  genesDelim = '/',
  datasetURL = '',
  caption = NULL,
  includeColumns = c(
    'Term Description',
    'Hits',
    'p-Value (adj.)',
    'p-Value',
    'Genes in Term'
  )
)  
table
### DOSE

enrichplot::dotplot(doseRes) + 
      scale_y_discrete(labels = function(x) stringr::str_wrap(stringr::str_replace_all(x, "pattern_" , "_"), width = 40))
doseRes
doseRes@result$ID <- gsub(pattern = 'DOID:', replacement = '', doseRes@result$ID)
rownames(doseRes@result) <- doseRes@result$ID

table <- doseRes %>% as.data.frame() %>%
  dplyr::rename(
    'Term Description' = Description,
    'Term ID' = ID,
    'geneID' = geneID,
    'Hits' = Count,
    'p-Value (adj.)' = pvalue,
    'p-Value' = p.adjust,
    'Genes in Term' = geneID
  )

table <- makeTermsTable(
  table = table,
  genesDelim = '/',
  datasetURL = "https://www.ebi.ac.uk/ols/ontologies/doid/terms?iri=http%3A%2F%2Fpurl.obolibrary.org%2Fobo%2FDOID_",
  caption = NULL,
  includeColumns = c(
    'Term Description',
    'Hits',
    'p-Value (adj.)',
    'p-Value',
    'Genes in Term'
  )
) 
table
### NCG
enrichplot::dotplot(ncgRes) + 
      scale_y_discrete(labels = function(x) stringr::str_wrap(stringr::str_replace_all(x, "pattern_" , "_"), width = 40))
table <- ncgRes %>% as.data.frame() %>%
  dplyr::rename(
    'Term Description' = Description,
    'Term ID' = ID,
    'geneID' = geneID,
    'Hits' = Count,
    'p-Value (adj.)' = pvalue,
    'p-Value' = p.adjust,
    'Genes in Term' = geneID
  )

makeTermsTable(
  table = table,
  genesDelim = '/',
  datasetURL = '',
  caption = NULL,
  includeColumns = c(
    'Term Description',
    'Hits',
    'p-Value (adj.)',
    'p-Value',
    'Genes in Term'
  )
) 
### DGN

enrichplot::dotplot(dgnRes) + 
      scale_y_discrete(labels = function(x) stringr::str_wrap(stringr::str_replace_all(x, "pattern_" , "_"), width = 40))
table <- dgnRes %>% as.data.frame() %>%
  dplyr::rename(
    'Term Description' = Description,
    'Term ID' = ID,
    'geneID' = geneID,
    'Hits' = Count,
    'p-Value (adj.)' = pvalue,
    'p-Value' = p.adjust,
    'Genes in Term' = geneID
  )

makeTermsTable(
  table = table,
  genesDelim = '/',
  datasetURL = "https://www.disgenet.org/browser/0/1/0/",
  caption = NULL,
  includeColumns = c(
    'Term Description',
    'Hits',
    'p-Value (adj.)',
    'p-Value',
    'Genes in Term'
  )
) 
### enrichR

table <- enrichrRes %>% as.data.frame() %>%
  dplyr::rename(
    'Term Description' = Description,
    'Term ID' = ID,
    'geneID' = geneID,
    'Hits' = Count,
    'p-Value (adj.)' = pvalue,
    'p-Value' = p.adjust,
    'Genes in Term' = geneID
  )

makeTermsTable(
  table = table,
  genesDelim = '/',
  datasetURL = "https://www.disgenet.org/browser/0/1/0/",
  caption = NULL,
  includeColumns = c(
    'Term Description',
    'Hits',
    'p-Value (adj.)',
    'p-Value',
    'Genes in Term'
  )
) 

R sessionInfo

options('max.print' = 500)
sessionInfo()


BimberLab/geneSetVis documentation built on Feb. 21, 2022, 4:21 p.m.