Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cibersort & mcpcounter #16

Merged
merged 2 commits into from
Jan 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ Imports:
readr,
shinycssloaders,
wrapr,
forcats
forcats,
ggridges
RoxygenNote: 7.0.2
Suggests:
testthat (>= 2.1.0),
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export(mod_explore_page_server)
export(mod_explore_page_ui)
export(mod_gene_variant_server)
export(mod_gene_variant_ui)
export(mod_immune_signatures_server)
export(mod_immune_signatures_ui)
export(mod_latent_variables_server)
export(mod_latent_variables_ui)
export(mod_resources_page_server)
Expand Down
10 changes: 6 additions & 4 deletions R/mod_explore_page.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ mod_explore_page_ui <- function(id){
tagList(
dashboardPage(
dashboardHeader(disable = T),
dashboardSidebar(
dashboardSidebar(sidebarMenu(
id = "explorertabs",
menuItem("Explore Home",
tabName = "dashboard",
Expand All @@ -27,7 +27,7 @@ mod_explore_page_ui <- function(id){
menuItem("Analysis Modules",
icon = icon("chart-area"), startExpanded = TRUE,
menuSubItem(
"Immune Infiltration",
"Immune Cell Deconvolution",
tabName = "immune_infiltration",
icon = icon("cog")
),
Expand All @@ -39,15 +39,16 @@ mod_explore_page_ui <- function(id){
menuSubItem(
"Latent Variables",
tabName = "latent_variables",
icon = icon("cog")))),
icon = icon("cog"))))),
dashboardBody(
tagList(
tabItems(
tabItem(
tabName = "dashboard"
),
tabItem(
tabName = 'immune_infiltration'
tabName = 'immune_infiltration',
mod_immune_signatures_ui(ns("immune_signatures_ui_1"))
),
tabItem(
tabName = "gene_var",
Expand All @@ -74,6 +75,7 @@ mod_explore_page_server <- function(input, output, session, specimens){

callModule(mod_gene_variant_server, "gene_variant_ui")
callModule(mod_latent_variables_server, "latent_variables_ui_1", specimens)
callModule(mod_immune_signatures_server, "immune_signatures_ui_1", specimens)
}

## To be copied in the UI
Expand Down
93 changes: 93 additions & 0 deletions R/mod_immune_signatures.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Module UI

#' @title mod_immune_signatures_ui and mod_immune_signatures_server
#' @description A shiny Module.
#'
#' @param id shiny id
#' @param input internal
#' @param output internal
#' @param session internal
#'
#' @rdname mod_immune_signatures
#'
#' @keywords internal
#' @export
#' @importFrom shiny NS tagList
mod_immune_signatures_ui <- function(id){
ns <- NS(id)

tagList(
h2("Immune Cell Deconvolution"),
box(h4('Module Summary'),
p('This immune cell deconvolution module can be used to estimate the presence of different types of immune cells from RNA-Seq tumor data. Two algorithms, ',
a(href='https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5895181/', 'CIBERSORT', .noWS = "outside"), ' and ',
a(href='https://genomebiology.biomedcentral.com/articles/10.1186/s13059-016-1070-5', 'MCPcounter', .noWS = "outside"),
', were used to estimate immune cell abundance in NF tumor samples. A rightward shift of the peak indicates that the group of samples is predicted to have more of a given cell type. Please note that cell lines and non-human models are not available; only patient samples and PDX models of human tumors are available for analysis.',
.noWS = c("after-begin", "before-end")),
width = 12),
box(title = "CIBERSORT",
status = "primary", solidHeader = TRUE,
width = 12,
collapsible = FALSE,
plotOutput(ns('cibersort_ridgeplot'))
# %>% shinycssloaders::withSpinner(custom.css=T) ##throws an error that looks to be css related
),
box(title = "MCPcounter",
status = "primary", solidHeader = TRUE,
width = 12,
collapsible = FALSE,
plotOutput(ns('mcpcounter_ridgeplot')
# %>% shinycssloaders::withSpinner(custom.css=T) ##throws an error that looks to be css related
))
)

}

# Module Server

#' @rdname mod_immune_signatures
#' @export
#' @keywords internal

mod_immune_signatures_server <- function(input, output, session, specimens){
ns <- session$ns

output$cibersort_ridgeplot <- renderPlot({

foo <- kairos::immune_predictions %>%
dplyr::filter(specimenID %in% specimens() &
method == 'cibersort')
ggplot(foo) +
ggridges::geom_density_ridges(aes(x = score, y=cell_type, fill = cell_type)) +
facet_grid(cols = vars(tumorType)) +
theme_minimal() +
theme(legend.position = 'none',
text = element_text(size = 12)) +
labs(x = 'Cell Type', y = "Density")

})

output$mcpcounter_ridgeplot <- renderPlot({

foo <- kairos::immune_predictions %>%
dplyr::filter(specimenID %in% specimens() &
method == 'mcp_counter')

ggplot(foo) +
ggridges::geom_density_ridges(aes(x = score, y=cell_type, fill = cell_type)) +
facet_grid(cols = vars(tumorType)) +
theme_minimal() +
theme(legend.position = 'none',
text = element_text(size = 12)) +
labs(x = 'Cell Type', y = "Density")

})

}

## To be copied in the UI
# mod_immune_signatures_ui("immune_signatures_ui_1")

## To be copied in the server
# callModule(mod_immune_signatures_server, "immune_signatures_ui_1")

2 changes: 2 additions & 0 deletions R/mod_latent_variables.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ mod_latent_variables_server <- function(input, output, session, specimens){
dplyr::summarize(sdev = sd(value)) %>%
dplyr::top_n(10, sdev)

validate(need(nrow(foo)>0, "No latent variable data found. Please modify your cohort."))

foo2 <- dplyr::filter(kairos::latent_var,
latent_var %in% foo$latent_var) %>%
dplyr::mutate(latent_var = stringr::str_trunc(latent_var, 15)) %>%
Expand Down
9 changes: 9 additions & 0 deletions data-raw/immune_predictions.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## code to prepare `immune_predictions` dataset goes here
library(synapser)
library(dplyr)
synLogin()
immune_predictions <- synTableQuery("SELECT * FROM syn21177277")$filepath %>%
readr::read_csv() %>%
select(method, cell_type, score, specimenID, tumorType, sex, diagnosis)

usethis::use_data(immune_predictions)
Binary file added data/immune_predictions.rda
Binary file not shown.
24 changes: 24 additions & 0 deletions man/mod_immune_signatures.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.