Skip to content

Commit

Permalink
update documentation with examples
Browse files Browse the repository at this point in the history
  • Loading branch information
nicola-calonaci committed May 24, 2024
1 parent d887123 commit a292951
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 25 deletions.
5 changes: 5 additions & 0 deletions R/met_propensity.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
#' @param gene The gene on which patient's stratification is based.
#' @return An object of class \code{'INCOMMON'} containing an additional object `survival`.
#' @export
#' @examples
#' # First load example classified data
#' data(MSK_classified)
#' # Estimate the metastatic propensity associated with mutant TP53 with vs without CNA in BRCA.
#' MSK_classified = met_propensity(x = MSK_classified, tumor_type = 'BRCA', gene = 'TP53')
#' @importFrom dplyr filter mutate rename select %>% as_tibble
#' @importFrom survival Surv survfit
#' @importFrom stats glm binomial confint
Expand Down
6 changes: 6 additions & 0 deletions R/met_tropism.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
#' @param gene The gene on which patient's stratification is based.
#' @param metastatic_site The target organ of metastatic diffusion.
#' @export
#' @examples
#' # First load example classified data
#' data(MSK_classified)
#' # Estimate the metastatic propensity associated with mutant TP53 with vs without CNA in BRCA,
#' with respect to the Liver.
#' MSK_classified = met_tropism(x = MSK_classified, tumor_type = 'BRCA', gene = 'TP53', metastatic_site = 'Liver')
#' @importFrom dplyr filter mutate rename select %>%
#' @importFrom survival Surv survfit

Expand Down
15 changes: 4 additions & 11 deletions R/plot_class_fraction.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,10 @@
#' @return An object or a list of class \code{'ggplot2'}.
#' @export
#' @examples
#' # First load example data
#' data(MSK_genomic_data)
#' data(MSK_clinical_data)
#' # Initialize the INCOMMON object (note the outputs to screen)
#' x = init(genomic_data = MSK_genomic_data, clinical_data = MSK_clinical_data)
#' # Run INCOMMON classification
#' x = classify(x = x, priors = pcawg_priors, entropy_cutoff = NULL, rho = 0.01)
#' # Use the genome interpreter to get intepreted classifications
#' x = genome_interpreter(x = x)
#' # Plot the fraction of class
#' x = genome_interpreter(x = x)
#' # First load example classified data
#' data(MSK_classified)
#' # Plot class fraction for a specific gene and tumour type
#' plot_class_fraction(x = MSK_classified, tumor_type = 'LUAD', gene = 'KRAS')
#' @importFrom dplyr filter mutate rename select %>%
#' @importFrom patchwork wrap_plots
plot_class_fraction = function(x, tumor_type, gene, ...){
Expand Down
14 changes: 4 additions & 10 deletions R/plot_classification.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,10 @@
#' @return An object or a list of objects of class \code{'ggplot2'}.
#' @export
#' @examples
#' # First load example data
#' data(MSK_genomic_data)
#' data(MSK_clinical_data)
#' # Initialize the INCOMMON object with a specific sample
#' sample = 'P-0002081'
#' x = init(genomic_data = MSK_genomic_data %>% filter(sample == !!sample), clinical_data = MSK_clinical_data %>% filter(sample == !!sample))
#' # Run INCOMMON classification
#' x = classify(x = x, priors = pcawg_priors, entropy_cutoff = NULL, rho = 0.01)
#' # An S3 method can be used to report to screen what is in the object
#' plot_classification(x = x, sample = sample)
#' # First load example classified data
#' data(MSK_classified)
#' # Plot classification results for a specific sample
#' plot_classification(x = MSK_classified, sample = 'P-0002081')
#' @importFrom dplyr filter mutate rename select %>%
plot_classification = function(x, sample, assembly = F){

Expand Down
7 changes: 7 additions & 0 deletions R/plot_met_volcano.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
#' it pools from multiple tumour types into a pan-cancer visualisation.
#' @return An object or a list of objects of class \code{'ggplot2'}.
#' @export
#' @examples
#' # First load example classified data
#' data(MSK_classified)
#' # Estimate the metastatic propensity associated with mutant TP53, PIK3CA and CDH1 with vs without CNA in BRCA.
#' for(g in c('TP53', 'PIK3CA', 'CDH1')){MSK_classified = met_propensity(x = MSK_classified, tumor_type = 'BRCA', gene = g)}
#' # Plot results in a volcano plot
#' plot_met_volcano(x = MSK_classified, tumor_type = 'BRCA')
#' @importFrom dplyr filter mutate rename select %>%
#' @importFrom ggrepel geom_label_repel

Expand Down
5 changes: 5 additions & 0 deletions R/plot_prior.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
#' @param gene Gene for gene-specific prior.
#' @return An object or a list of objects of class \code{'ggplot2'}.
#' @export
#' @examples
#' # First load example classified data
#' data(MSK_classified)
#' # Plot classification results for a specific sample
#' plot_prior(x = MSK_classified, gene = 'TP53', tumor_type = 'PAAD')
#' @importFrom dplyr filter mutate rename select %>%
plot_prior = function(x, gene, tumor_type){

Expand Down
16 changes: 12 additions & 4 deletions R/plot_tropism.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,26 @@
#' @param tumor_type The tumour type for which classified data is available.
#' @return An object or a list of objects of class \code{'ggplot2'}.
#' @export
#' @examples
#' # First load example classified data
#' data(MSK_classified)
#' # Estimate the metastatic tropism associated with mutant TP53, PIK3CA and CDH1 with vs without CNA,
#' # in BRCA, with respect to Liver and Lymph
#' for(g in c('TP53', 'PIK3CA', 'CDH1')){for(m in c('Liver', 'Lymph')){MSK_classified = met_tropism(x = MSK_classified, gene = g, tumor_type = 'BRCA', metastatic_site = m) }
#' # Plot results in a volcano plot
#' plot_tropism(x = MSK_classified, tumor_type = 'BRCA')
#' @importFrom dplyr filter mutate rename select %>%
#' @importFrom ggrepel geom_label_repel

plot_tropism = function(x, tumor_type){
stopifnot(inherits(x, 'INCOMMON'))
stopifnot('metastatic_tropism' %in% names(x))

stopifnot(tumor_type %in% names(x$metastatic_tropism))
toplot = x$metastatic_tropism[[tumor_type]] %>%
unlist(recursive = F) %>%
do.call(rbind, .)

toplot = toplot %>%
dplyr::mutate(
prevalent = dplyr::case_when(
Expand All @@ -27,10 +35,10 @@ plot_tropism = function(x, tumor_type){
TRUE ~ 'ns'
)
)

toplot %>%
dplyr::filter(!is.na(low),
!is.na(up)) %>%
!is.na(up)) %>%
ggplot2::ggplot(ggplot2::aes(
y = gene, x = log2(OR))) +
ggplot2::geom_vline(xintercept = 0, linetype = 'longdash', color = 'indianred')+
Expand Down

0 comments on commit a292951

Please sign in to comment.