Skip to content

Commit

Permalink
Merge pull request #25 from allaway/fix-lv
Browse files Browse the repository at this point in the history
fixed a couple of bugs and cleaned ui
  • Loading branch information
jaybee84 authored Mar 3, 2020
2 parents daa8522 + 675c43f commit 76b20b0
Show file tree
Hide file tree
Showing 10 changed files with 122 additions and 10 deletions.
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export(mod_cohort_page_server)
export(mod_cohort_page_ui)
export(mod_docs_page_server)
export(mod_docs_page_ui)
export(mod_drug_screening_server)
export(mod_drug_screening_ui)
export(mod_explore_page_server)
export(mod_explore_page_ui)
export(mod_gene_variant_server)
Expand Down
10 changes: 8 additions & 2 deletions R/mod_cohort_page.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,21 @@ mod_cohort_page_ui <- function(id){
dashboardHeader(disable = T),
dashboardSidebar(
p("Globally remove or add groups with these selectors:"),
checkboxGroupInput(ns('isCellLine'), label = "Is Cell Line", choices = unique(cohort$isCellLine),
selected = unique(cohort$isCellLine)),
checkboxGroupInput(ns("tumorType"), label = "Tumor Type", choices = unique(cohort$tumorType),
selected = unique(cohort$tumorType)),
checkboxGroupInput(ns('isCellLine'), label = "Is Cell Line", choices = unique(cohort$isCellLine),
selected = unique(cohort$isCellLine)),
checkboxGroupInput(ns("species"), label = "Species", choices = unique(cohort$species),
selected = unique(cohort$species)),
selectizeInput(ns("studyName"), label = "Study Name", choices = unique(cohort$studyName),
selected = unique(cohort$studyName), multiple = T)),
dashboardBody(
h2("Select a Cohort"),
box(p("The first step to any kairos analysis is building a cohort. The selector on the left allows you
to add or remove biological specimens based on metadata such as tumor type, species, and the study it comes from.
A graphical summary (below) indicates the analyses that are available for the cohort you've selected, and below that,
a downloadable table shows which specimens you've selected."),
width = 12),
box(width = 12,
solidHeader = T,
status = "primary",
Expand Down
41 changes: 41 additions & 0 deletions R/mod_drug_screening.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Module UI

#' @title mod_drug_screening_ui and mod_drug_screening_server
#' @description A shiny Module.
#'
#' @param id shiny id
#' @param input internal
#' @param output internal
#' @param session internal
#'
#' @rdname mod_drug_screening
#'
#' @keywords internal
#' @export
#' @importFrom shiny NS tagList
mod_drug_screening_ui <- function(id){
ns <- NS(id)
tagList(
h2("Drug Screening Analysis"),
box(h4('Module Summary'),
p("Altera inimicus sed no. Congue consul eripuit est in. Ut blandit interesset mea, hinc congue quo ex, qui ad laudem volumus. Ius at everti torquatos. Eum aeque verear ei, postea sensibus te his. Quo viderer epicuri postulant cu, essent appareat efficiantur nec eu. Libris lobortis vix no. Vim at elit quas ullum. Elaboraret dissentiet ius ei, vix verterem scriptorem intellegebat in, vix case inimicus ne. Ea mea tale clita. Ne oblique invenire ius, ubique laboramus est an, usu ad oblique tractatos maluisset. Vide facilisis definitiones ei vim, in viris salutatus philosophia sit."),
width = 12)
)
}

# Module Server

#' @rdname mod_drug_screening
#' @export
#' @keywords internal

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

## To be copied in the UI
# mod_drug_screening_ui("drug_screening_ui_1")

## To be copied in the server
# callModule(mod_drug_screening_server, "drug_screening_ui_1")

12 changes: 11 additions & 1 deletion R/mod_explore_page.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ mod_explore_page_ui <- function(id){
menuSubItem(
"Latent Variables",
tabName = "latent_variables",
icon = icon("cog"))))),
icon = icon("cog")),
menuSubItem(
"in vitro Drug Screening",
tabName = "drug_screening",
icon = icon("cog")
)))),
dashboardBody(
tagList(
tabItems(
Expand All @@ -57,6 +62,10 @@ mod_explore_page_ui <- function(id){
tabItem(
tabName = "latent_variables",
mod_latent_variables_ui(ns("latent_variables_ui_1"))
),
tabItem(
tabName = "drug_screening",
mod_drug_screening_ui(ns("drug_screening_ui_1"))
)
))
)
Expand All @@ -76,6 +85,7 @@ mod_explore_page_server <- function(input, output, session, specimens){
callModule(mod_gene_variant_server, "gene_variant_ui", specimens)
callModule(mod_latent_variables_server, "latent_variables_ui_1", specimens)
callModule(mod_immune_signatures_server, "immune_signatures_ui_1", specimens)
callModule(mod_drug_screening_server, "drug_screening_ui_1", specimens)
}

## To be copied in the UI
Expand Down
5 changes: 5 additions & 0 deletions R/mod_gene_var.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ mod_gene_variant_ui <- function(id){

tagList(

h2("Gene Mutation Profiles"),
box(h4('Module Summary'),
p("Altera inimicus sed no. Congue consul eripuit est in. Ut blandit interesset mea, hinc congue quo ex, qui ad laudem volumus. Ius at everti torquatos. Eum aeque verear ei, postea sensibus te his. Quo viderer epicuri postulant cu, essent appareat efficiantur nec eu. Libris lobortis vix no. Vim at elit quas ullum. Elaboraret dissentiet ius ei, vix verterem scriptorem intellegebat in, vix case inimicus ne. Ea mea tale clita. Ne oblique invenire ius, ubique laboramus est an, usu ad oblique tractatos maluisset. Vide facilisis definitiones ei vim, in viris salutatus philosophia sit."),
width = 12),

# selectizeInput(ns("studyName"), label = "Study Name", choices = unique(kairos::exome_data$study),
# selected = unique(kairos::exome_data$study), multiple = T),
#
Expand Down
19 changes: 16 additions & 3 deletions R/mod_immune_signatures.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,28 @@ mod_immune_signatures_server <- function(input, output, session, specimens){

foo <- kairos::immune_predictions %>%
dplyr::filter(specimenID %in% specimens() &
method == 'mcp_counter')
method == 'mcp_counter') %>%
mutate(score = log10(score+0.01)) #this is a temporary fix but not efficient...data should be transformed

ggplot(foo) +
ggridges::geom_density_ridges(aes(x = log10(0.01+score), y=cell_type, fill = cell_type)) +
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 = "Score (log10)", y = 'Cell Type')
labs(x = "log10(Score)", y = 'Cell Type')
#
# foo <- kairos::immune_predictions %>%
# dplyr::filter(specimenID %in% specimens() &
# method == 'mcp_counter')
#
# ggplot(foo) +
# ggridges::geom_density_ridges(aes(x = log10(0.01+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 = "Score (log10)", y = 'Cell Type')

})

Expand Down
13 changes: 9 additions & 4 deletions R/mod_latent_variables.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ mod_latent_variables_ui <- function(id){
ns <- NS(id)

tagList(
box(title="placeholder box for latent variable explanation",
width = 12,
solidHeader = T,
status = "primary"),
h2("Latent Variable (LV) Analysis"),
box(h4('Module Summary'),
p("Transfer learning techniques can leverage large, well-curated datasets such as recount2 to identify patterns of gene expression (latent variables, LVs) in large datasets and assess the expression of those genes in other, smaller datasets.
Many of these LVs are composed of genes that map to known signatures such as Kyoto Encyclopedia of Genes and Genomes (KEGG) or Gene Ontology (GO) terms,
while others are uncharacterized and may allow the detection of novel and meaningful transcriptomic patterns in NF data.
Here, we have used this approach to reduce gene-based expression data to individual latent variables. This can provide multiple benefits—LVs can highlight differences in known biology in sets of samples,
they can uncover previously unknown biology, and they can reduce the impact of technical and experimental differences across multiple datasets. Specifically, we transferred a machine learning model trained on recount2 to assess LV expression in the NF1 nerve sheath tumor dataset."),
width = 12),
box(title = "Most Variable LVs",
plotly::plotlyOutput(ns('top_lv')
# %>% shinycssloaders::withSpinner(custom.css=T) ##throws an error that looks to be css related
Expand Down Expand Up @@ -95,6 +99,7 @@ mod_latent_variables_server <- function(input, output, session, specimens){
validate(need(length(lv)==1, "Click a box on the left plot to examine individual latent variables."))

foo <- kairos::latent_var %>%
dplyr::filter(specimenID %in% specimens()) %>%
dplyr::mutate(latent_var = stringr::str_trunc(latent_var, 15)) %>%
dplyr::filter(latent_var == lv) %>%
dplyr::mutate(x = modelOf, y = value)
Expand Down
6 changes: 6 additions & 0 deletions data-raw/analyses.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ latent_var <- kairos::latent_var %>%
dplyr::distinct() %>%
dplyr::mutate(latent_var = 1)

immune_pred <- kairos::immune_predictions %>%
dplyr::select(specimenID) %>%
dplyr::distinct() %>%
dplyr::mutate(immune_pred = 1)

analyses <- dplyr::full_join(jhu_tumor_file, latent_var) %>%
dplyr::full_join(immune_pred) %>%
dplyr::mutate_at(vars(-specimenID), funs(dplyr::case_when(. == 1 ~ 1,
is.na(.) ~ 0)))

Expand Down
Binary file modified data/analyses.rda
Binary file not shown.
24 changes: 24 additions & 0 deletions man/mod_drug_screening.Rd

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

0 comments on commit 76b20b0

Please sign in to comment.