Tissue and cell type enrichment



Target set - tissue specificity {.tabset}



oe_tissue_category_df <- 
  onc_enrich_report[['data']][['cell_tissue']][['tissue_overview']][['category_df']]
oe_tissue_category_plot <-
    ggplot2::ggplot(oe_tissue_category_df, ggplot2::aes(x = category, y = pct)) +
    ggplot2::geom_col(ggplot2::aes(color = group, fill = group),
                      position = ggplot2::position_dodge(0.8), width = 0.7) +
    ggsci::scale_color_locuszoom() +
    ggsci::scale_fill_locuszoom() +
    ggplot2::ylab("Percent") +
    ggplot2::xlab("") +
    ggplot2::ylim(0,100) +
    ggplot2::theme_classic() +
    ggplot2::theme(
      legend.position = "top",
      legend.title = ggplot2::element_blank(),
      axis.text.x = ggplot2::element_text(angle = 30, size = 11, vjust = 0.5),
      legend.text = ggplot2::element_text(face="bold", family = "Helvetica", size = 12),
      axis.text.y = ggplot2::element_text(family = "Helvetica", size = 12),
      axis.title.x = ggplot2::element_text(family = "Helvetica", size = 12),
      axis.title.y = ggplot2::element_text(family = "Helvetica", size = 12)


    )

rm(oe_tissue_category_df)
plotly::ggplotly(oe_tissue_category_plot, height = 500, width = 900) |>  
  plotly::layout(legend = list(orientation = "h", x = 0.2, y = -0.45))
rm(oe_tissue_category_plot)



Tissue specificities per target gene
tissue_specs_per_gene <- 
  crosstalk::SharedData$new(
    onc_enrich_report[['data']][['cell_tissue']][['tissue_enrichment']][['per_gene']] |> dplyr::select(-cancer_max_rank))

crosstalk::bscols(
  list(
    crosstalk::filter_select("category", "Category", tissue_specs_per_gene, ~category)
  ),
  list(
    crosstalk::filter_select("tissue", "Tissues", tissue_specs_per_gene, ~tissue)
  )
)

htmltools::br()

DT::datatable(
  tissue_specs_per_gene, 
  escape = F, 
  extensions=c("Buttons","Responsive"), 
  width = "100%",
  style = 'bootstrap',
  rownames = F,
  options=list(buttons = c('csv','excel'),
               pageLength = 10,
               bPaginate = T,
               dom = 'Bfrtip')
  ) |>
  DT::formatStyle(
    'category', 
    color = "white",
    backgroundColor = DT::styleEqual(
      onc_enrich_report[["config"]][["cell_tissue"]][["tissue_enrichment_levels"]],
      onc_enrich_report[["config"]][["cell_tissue"]][["enrichment_colors"]]
    )
  )



Tissue enrichment - query set
num_significant_tissues <- 
  onc_enrich_report[['data']][['cell_tissue']][['tissue_enrichment']]$per_type |>
  dplyr::filter(log10_pvalue >= 1.3) |>
  nrow()
htmltools::br()

cat("<ul><li>")
cat('<i><font style="font-size: 100%">Considering the tissue specificities of members of the query set, <b>NO TISSUES</b> are enriched (adjusted p-value < 0.05) compared to the background set.</i></font>', sep='\n')
cat('</ul></li>')

htmltools::br()
htmltools::br()
htmltools::br()
htmltools::br()
enriched_tissues_df <- 
  onc_enrich_report[['data']][['cell_tissue']][['tissue_enrichment']]$per_type |>
  dplyr::filter(log10_pvalue >= 1.3)

DT::datatable(
  enriched_tissues_df, 
  escape = F, 
  extensions=c("Buttons","Responsive"), 
  width = "100%",
  style = 'bootstrap',
  rownames = F,
  options=list(buttons = c('csv','excel'),
               pageLength = 10,
               bPaginate = T,
               dom = 'Bfrtip')
  )
htmltools::br()

Target set - cell type specificity {.tabset}



oe_ctype_category_df <- 
  onc_enrich_report[['data']][['cell_tissue']][['scRNA_overview']][['category_df']]
oe_ctype_category_plot <-
    ggplot2::ggplot(oe_ctype_category_df, ggplot2::aes(x = category, y = pct)) +
    ggplot2::geom_col(ggplot2::aes(color = group, fill = group),
                      position = ggplot2::position_dodge(0.8), width = 0.7) +
    ggsci::scale_color_locuszoom() +
    ggsci::scale_fill_locuszoom() +
    ggplot2::ylab("Percent") +
    ggplot2::xlab("") +
    ggplot2::ylim(0,100) +
    ggplot2::theme_classic() +
    ggplot2::theme(
      legend.position = "top",
      legend.title = ggplot2::element_blank(),
      axis.text.x = ggplot2::element_text(angle = 30, size = 11, vjust = 0.5),
      legend.text = ggplot2::element_text(face="bold", family = "Helvetica", size = 12),
      axis.text.y = ggplot2::element_text(family = "Helvetica", size = 12),
      axis.title.x = ggplot2::element_text(family = "Helvetica", size = 12),
      axis.title.y = ggplot2::element_text(family = "Helvetica", size = 12)
    )

rm(oe_ctype_category_df)
plotly::ggplotly(oe_ctype_category_plot, height = 500, width = 900) |>  
  plotly::layout(legend = list(orientation = "h", x = 0.2, y = -0.45))
rm(oe_ctype_category_plot)



Cell type specififies per target gene
celltype_specs_per_gene <- 
  crosstalk::SharedData$new(
    onc_enrich_report[['data']][['cell_tissue']][['scRNA_enrichment']][['per_gene']] |> dplyr::select(-cancer_max_rank))

crosstalk::bscols(
  list(
    crosstalk::filter_select("category", "Category", celltype_specs_per_gene, ~category)
  ),
  list(
    crosstalk::filter_select("cell_type", "Cell type", celltype_specs_per_gene, ~cell_type)
  )
)

htmltools::br()
DT::datatable(
  celltype_specs_per_gene, 
  escape = F, 
  extensions=c("Buttons","Responsive"), 
  width = "100%",
  style = 'bootstrap',
  rownames = F,
  options=list(buttons = c('csv','excel'),
               pageLength = 10,
               bPaginate = T,
               dom = 'Bfrtip')
  ) |>
  DT::formatStyle(
    'category', 
    color = "white",
    backgroundColor = DT::styleEqual(
      onc_enrich_report[["config"]][["cell_tissue"]][["ctype_enrichment_levels"]],
      onc_enrich_report[["config"]][["cell_tissue"]][["enrichment_colors"]]
    )
  )



Cell type enrichment - query set


num_significant_celltypes <- 
  onc_enrich_report[['data']][['cell_tissue']][['scRNA_enrichment']]$per_type |>
  dplyr::filter(log10_pvalue >= 1.3) |>
  nrow()
htmltools::br()

cat("<ul><li>")
cat('<i><font style="font-size: 100%">Considering the cell-type specificities of members of the query set, <b>NO CELL TYPES</b> are enriched (adjusted p-value < 0.05) compared to the background set.</i></font>', sep='\n')
cat('</ul></li>')

htmltools::br()
htmltools::br()
htmltools::br()
htmltools::br()
enriched_celltypes_df <- 
  onc_enrich_report[['data']][['cell_tissue']][['scRNA_enrichment']]$per_type |>
  dplyr::filter(log10_pvalue >= 1.3)

DT::datatable(
  enriched_celltypes_df, 
  escape = F, 
  extensions=c("Buttons","Responsive"), 
  width = "100%",
  style = 'bootstrap',
  rownames = F,
  options=list(buttons = c('csv','excel'),
               pageLength = 10,
               bPaginate = T,
               dom = 'Bfrtip')
  )

htmltools::br()

# p <- ggplot2::ggplot(expression_dist, ggplot2::aes(cell_type, symbol)) +
#   ggplot2::geom_tile(aes(fill = exp),
#             colour = "white") +
#   ggplot2::scale_fill_gradient(low = "white",
#                       high = "steelblue") +
#   ggplot2::labs(x='', y = '') +
#   ggplot2::theme_bw()+
#   ggplot2::guides(fill = ggplot2::guide_legend(title = "Log2(TPM)"))+
#   #theme(legend.position="none")+
#   ggplot2::theme(plot.title = ggplot2::element_text(
#     hjust = 0.5,size = 20),
#     axis.title = ggplot2::element_text(size=15)) +
#   ggplot2::theme(axis.text.x = ggplot2::element_text(angle = 45,
#                                    vjust = 1, hjust = 1),
#         panel.grid.major= ggplot2::element_blank(),
#         panel.grid.minor = ggplot2::element_blank())



{.unlisted .unnumbered .toc-ignore}

  Citation Note   : If you use the output of the Tissue and cell type enrichment module of oncoEnrichR in your research, please cite the following resources and tools:





sigven/oncoEnrichR documentation built on Aug. 31, 2023, 8:05 a.m.