Skip to content

Commit

Permalink
making all examples run-able for biocCheck
Browse files Browse the repository at this point in the history
  • Loading branch information
ytakemon committed Apr 4, 2023
1 parent f467258 commit 5691082
Show file tree
Hide file tree
Showing 35 changed files with 35,387 additions and 37,347 deletions.
14 changes: 7 additions & 7 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

export("%>%")
export(GI_screen)
export(annotate_coessential_df)
export(annotate_coess)
export(coessential_map)
export(extract_protein_expr)
export(extract_rna_expr)
export(extract_prot)
export(extract_rna)
export(get_DepMapID)
export(get_GeneNameID)
export(get_inflection_points)
export(list_available_cancer_subtypes)
export(list_available_cancer_types)
export(list_available_mutations)
export(plot_coessential_genes)
export(list_cancer_subtypes)
export(list_cancer_types)
export(list_mutations)
export(plot_coess)
export(plot_screen)
export(select_cell_lines)
import(dplyr)
Expand Down
10 changes: 4 additions & 6 deletions R/GI_screen.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,16 @@
#' @md
#'
#' @examples
#' \dontrun{
#' gretta_data_dir <- "/projects/marralab/ytakemon_prj/DepMap/GRETTA_data/22Q2/data"
#' gretta_output_dir <- "/projects/marralab/ytakemon_prj/DepMap/GRETTA_troubleshooting/"
#'
#' Screen_results <- GI_screen(
#' control_id = c('ACH-001354', 'ACH-000274', 'ACH-001799'),
#' mutant_id = c('ACH-000911', 'ACH-001957', 'ACH-000075'),
#' gene_list = c("ARID1A", "ARID1B", "SMARCA2"),
#' core_num = 2,
#' output_dir = '~/Desktop/GRETTA_test_dir/',
#' data_dir = '/path/to/DepMap_data/',
#' test = TRUE) # turn on for shorter test runs
#'
#' }
#' output_dir = gretta_output_dir,
#' data_dir = gretta_data_dir)
#'
#' @rdname GI_screen
#' @export
Expand Down
18 changes: 11 additions & 7 deletions R/annotate_coessential_df.R → R/annotate_coess.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,24 @@
#' @md
#'
#' @examples
#' \dontrun{
#' gretta_data_dir <- "/projects/marralab/ytakemon_prj/DepMap/GRETTA_data/22Q2/data"
#' gretta_output_dir <- "/projects/marralab/ytakemon_prj/DepMap/GRETTA_troubleshooting/"
#'
#' annotated_coessential_df <- annotate_coessential_df(
#' input_ess = co_ess_res,
#' input_inflec = inflection_points)
#' load(paste0(
#' gretta_data_dir,"/sample_22Q2_ARID1A_coessential_result.rda"),
#' envir = environment())
#' load(paste0(
#' gretta_data_dir,"/sample_22Q2_ARID1A_coessential_inflection.rda"),
#' envir = environment())
#'
#' }
#' annotated_df <- annotate_coess(coess_df, coess_inflection_df)
#'
#' @rdname annotate_coessential_df
#' @rdname annotate_coess
#' @export
#' @importFrom dplyr mutate filter pull rename arrange case_when
#' @importFrom tibble tibble

annotate_coessential_df <- function(input_ess = NULL, input_inflec = NULL) {
annotate_coess <- function(input_ess = NULL, input_inflec = NULL) {
# Checkpoint
if (is.null(input_ess)) {
stop("No coessential dataframe found!")
Expand Down
17 changes: 9 additions & 8 deletions R/coessential_map.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,16 @@
#' @md
#'
#' @examples
#' \dontrun{
#' gretta_data_dir <- "/projects/marralab/ytakemon_prj/DepMap/GRETTA_data/22Q2/data"
#' gretta_output_dir <- "/projects/marralab/ytakemon_prj/DepMap/GRETTA_troubleshooting/"
#'
#' Screen_results <- GINI_screen(
#' input_gene = 'ARID1A',
#' output_dir = '~/Desktop/GINI_test_dir/',
#' data_dir = '/path/to/DepMap_data/',
#' test = TRUE) # turn on for shorter test runs
#'
#' }
#' coess_df <- coessential_map(
#' input_gene = "ARID1A",
#' input_disease = "Pancreatic Cancer",
#' core_num = 2,
#' data_dir = gretta_data_dir,
#' output_dir = gretta_output_dir,
#' test = TRUE)
#'
#' @rdname coessential_map
#' @export
Expand Down
16 changes: 9 additions & 7 deletions R/extract_protein_expr.R → R/extract_prot.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,20 @@
#' @details See also `extract_protein_rna` to extract proteomics profile data
#'
#' @examples
#' \dontrun{
#' extract_protein_expr(
#' gretta_data_dir <- "/projects/marralab/ytakemon_prj/DepMap/GRETTA_data/22Q2/data"
#' gretta_output_dir <- "/projects/marralab/ytakemon_prj/DepMap/GRETTA_troubleshooting/"
#'
#' extract_prot(
#' input_samples = c('ACH-000004', 'ACH-000146'),
#' input_genes = c('ATM','TOP1'),
#' data_dir = '/path/to/DepMap_data/')
#' }
#' @rdname extract_protein_expr
#' input_genes = c('ATM'),
#' data_dir = gretta_data_dir)
#'
#' @rdname extract_prot
#' @export
#' @importFrom dplyr select contains left_join filter
#' @importFrom tidyr pivot_longer

extract_protein_expr <- function(input_samples = NULL, input_genes = NULL, data_dir = NULL) {
extract_prot <- function(input_samples = NULL, input_genes = NULL, data_dir = NULL) {

# Print and check to see input was provided
if (is.null(input_samples)) {
Expand Down
18 changes: 10 additions & 8 deletions R/extract_rna_expr.R → R/extract_rna.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,22 @@
#' @return Data frame containing RNA expression (TPM) for sample provided in the input.
#' If no genes were specified, the function will return a data frame of all genes profiled in DepMap
#'
#' @details See also `extract_protein_expr` to extract proteomics profile data
#' @details See also `extract_prot` to extract proteomics profile data
#'
#' @examples
#' \dontrun{
#' extract_rna_expr(
#' gretta_data_dir <- "/projects/marralab/ytakemon_prj/DepMap/GRETTA_data/22Q2/data"
#' gretta_output_dir <- "/projects/marralab/ytakemon_prj/DepMap/GRETTA_troubleshooting/"
#'
#' extract_rna(
#' input_samples = c('ACH-001642','ACH-000688'),
#' input_genes = c('TP53','ARID1A'),
#' data_dir = '/path/to/DepMap_data/')
#' }
#' @rdname extract_rna_expr
#' input_genes = c('ARID1A'),
#' data_dir = gretta_data_dir)
#'
#' @rdname extract_rna
#' @export
#' @importFrom dplyr filter select

extract_rna_expr <- function(input_samples = NULL, input_genes = NULL, data_dir = NULL) {
extract_rna <- function(input_samples = NULL, input_genes = NULL, data_dir = NULL) {

# Print and check to see input was provided
if (is.null(input_samples)) {
Expand Down
15 changes: 9 additions & 6 deletions R/get_names.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
#'
#' @export
#' @examples
#' \dontrun{
#' get_GeneNameID('A1CF', data_dir = '/path/to/DepMap_data/')
#' }
#' gretta_data_dir <- "/projects/marralab/ytakemon_prj/DepMap/GRETTA_data/22Q2/data"
#'
#' get_GeneNameID('A1CF', data_dir = gretta_data_dir)
#'
get_GeneNameID <- function(gene_name, data_dir) {
if (is.null(data_dir)) {
stop(
Expand Down Expand Up @@ -74,9 +75,11 @@ get_GeneNameID <- function(gene_name, data_dir) {
#'
#' @export
#' @examples
#' \dontrun{
#' get_DepMapID('JURKAT', data_dir = '/path/')
#' }
#' gretta_data_dir <- "/projects/marralab/ytakemon_prj/DepMap/GRETTA_data/22Q2/data"
#' gretta_output_dir <- "/projects/marralab/ytakemon_prj/DepMap/GRETTA_troubleshooting/"
#'
#' get_DepMapID('JURKAT', data_dir = gretta_data_dir)
#'
get_DepMapID <- function(sample_name, data_dir) {
# Load necessary data
protein_annot <- sample_annot <- NULL # see: https://support.bioconductor.org/p/24756/
Expand Down
24 changes: 13 additions & 11 deletions R/list_available_cancer_type.R → R/list_cancer_type.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' List cancer types that are available
#'
#' @description
#' `list_available_cancer_types()` and `list_available_cancer_subtypes()` provide tools for identifying cancer (sub)types that are available in DepMap.
#' `list_cancer_types()` and `list_cancer_subtypes()` provide tools for identifying cancer (sub)types that are available in DepMap.
#'
#' @return string A vector containing unique cancer types available

Expand All @@ -12,11 +12,12 @@
#'
#' @export
#' @examples
#' \dontrun{
#' list_available_cancer_types(data_dir = '/path/to/data')
#' }
#' gretta_data_dir <- "/projects/marralab/ytakemon_prj/DepMap/GRETTA_data/22Q2/data"
#' gretta_output_dir <- "/projects/marralab/ytakemon_prj/DepMap/GRETTA_troubleshooting/"
#'
list_available_cancer_types <- function(data_dir) {
#' list_cancer_types(data_dir = gretta_data_dir)
#'
list_cancer_types <- function(data_dir) {
# Load necessary data
sample_annot <- NULL # see: https://support.bioconductor.org/p/24756/
load(
Expand All @@ -30,17 +31,18 @@ list_available_cancer_types <- function(data_dir) {
unique
}

#' @describeIn list_available_cancer_types List cancer subtypes that are available
#' @describeIn list_cancer_types List cancer subtypes that are available
#'
#' @param input_disease string A vector of unique with one or more cancer types listed in `list_available_cancer_types()`
#' @param input_disease string A vector of unique with one or more cancer types listed in `list_cancer_types()`
#' @param data_dir string Path to GINIR_data
#' @importFrom rlang .data
#' @export
#' @examples
#' \dontrun{
#' list_available_cancer_subtypes('Lung Cancer', data_dir = '/path/to/DepMap_data/')
#' }
list_available_cancer_subtypes <- function(input_disease, data_dir) {
#' gretta_data_dir <- "/projects/marralab/ytakemon_prj/DepMap/GRETTA_data/22Q2/data"
#'
#' list_cancer_subtypes('Lung Cancer', data_dir = gretta_data_dir)
#'
list_cancer_subtypes <- function(input_disease, data_dir) {
if (is.null(data_dir)) {
stop(
paste0("No directory to data was specified. Please provide path to DepMap data.")
Expand Down
16 changes: 10 additions & 6 deletions R/list_available_mutations.R → R/list_mutations.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,19 @@
#' @return A data frame containing mutations matching criteria of input arguments
#'
#' @examples
#' \dontrun{
#' list_available_mutations(gene = 'TP53', data_dir = '/path/to/DepMap_data/')
#' list_available_mutations(chr = 12, data_dir = '/path/to/DepMap_data/')
#' }
#' gretta_data_dir <- "/projects/marralab/ytakemon_prj/DepMap/GRETTA_data/22Q2/data"
#' gretta_output_dir <- "/projects/marralab/ytakemon_prj/DepMap/GRETTA_troubleshooting/"
#'
#' @rdname list_available_mutations
#' list_mutations(
#' gene = 'TP53',
#' is_damaging = TRUE,
#' data_dir = gretta_data_dir)
#'
#' @rdname list_mutations
#' @export
#' @importFrom dplyr filter select arrange distinct
list_available_mutations <- function(
#'
list_mutations <- function(
gene = NULL, chr = NULL, start_bp = NULL, end_bp = NULL, is_hotspot = NULL, is_damaging = NULL,
variant_classification = NULL, data_dir = NULL
) {
Expand Down
41 changes: 26 additions & 15 deletions R/plot_coessential_genes.R → R/plot_coess.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,29 @@
#' @md
#'
#' @examples
#' \dontrun{
#' plot_coessential_genes(
#' gretta_data_dir <- "/projects/marralab/ytakemon_prj/DepMap/GRETTA_data/22Q2/data"
#' gretta_output_dir <- "/projects/marralab/ytakemon_prj/DepMap/GRETTA_troubleshooting/"
#'
#' load(paste0(
#' gretta_data_dir,"/sample_22Q2_ARID1A_coessential_result.rda"),
#' envir = environment())
#' load(paste0(
#' gretta_data_dir,"/sample_22Q2_ARID1A_coessential_inflection.rda"),
#' envir = environment())
#'
#' plot_coess(
#' result_df = coess_df,
#' inflection_df = inflection_points_df,
#' label_genes = TRUE,
#' label_n = 3)
#' }
#' inflection_df = coess_inflection_df,
#' label_genes = FALSE)
#'
#' @rdname plot_coessential_genes
#' @rdname plot_coess
#' @export
#' @importFrom dplyr mutate filter arrange case_when
#' @importFrom ggplot2 ggplot aes geom_hline geom_point scale_colour_identity scale_x_reverse scale_y_continuous theme theme_light
#' @importFrom stringr str_split_fixed
#' @importFrom ggrepel geom_label_repel

plot_coessential_genes <- function(result_df = NULL, inflection_df = NULL, label_genes = FALSE, label_n = NULL) {
plot_coess <- function(result_df = NULL, inflection_df = NULL, label_genes = FALSE, label_n = NULL) {
# Check data is provided
if (is.null(result_df)) {
stop("No result data frame provided")
Expand Down Expand Up @@ -58,15 +65,10 @@ plot_coessential_genes <- function(result_df = NULL, inflection_df = NULL, label
dplyr::slice(1:label_n) %>%
dplyr::pull(.data$GeneName_B)
Label_on_plot <- c(pos_gene, neg_gene)
} else {
Label_on_plot <- c("")
}


plot_df <- plot_df %>%
dplyr::mutate(
Label_on_plot = dplyr::case_when(.data$GeneName_B %in% Label_on_plot ~ TRUE, TRUE ~ FALSE),
point_colour = dplyr::case_when(.data$Candidate_gene == TRUE ~ "red", TRUE ~ "grey")
)

# get cor. coef of threshold
pos_inflection_cor <- plot_df %>%
dplyr::filter(.data$Rank <= inflection_df$Inflection_point_pos_byRank) %>%
Expand All @@ -77,6 +79,15 @@ plot_coessential_genes <- function(result_df = NULL, inflection_df = NULL, label
dplyr::pull(.data$estimate) %>%
max

plot_df <- plot_df %>%
dplyr::mutate(
Label_on_plot = ifelse(.data$GeneName_B %in% Label_on_plot, TRUE, FALSE),
Candidate_gene = ifelse(
.data$Padj_BH < 0.05 & (.data$estimate > pos_inflection_cor | .data$estimate < neg_inflection_cor),
TRUE, FALSE),
point_colour = ifelse(.data$Candidate_gene == TRUE, "red", "grey")
)

plot <- ggplot2::ggplot(
plot_df, ggplot2::aes(
x = .data$Rank, y = .data$estimate, colour = .data$point_colour, label = ifelse(.data$Label_on_plot, .data$GeneName_B, "")
Expand Down
8 changes: 5 additions & 3 deletions R/plot_screen.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
#' @md
#'
#' @examples
#' \dontrun{
#' plot_screen(sample_ARID1A_KO_screen, label_genes = TRUE, label_n = 3)
#' }
#' gretta_data_dir <- "/projects/marralab/ytakemon_prj/DepMap/GRETTA_data/22Q2/data"
#'
#' load(paste0(gretta_data_dir,"/sample_22Q2_ARID1A_KO_screen.rda"), envir = environment())
#'
#' plot_screen(screen_results, label_genes = FALSE)
#'
#' @rdname plot_screen
#' @export
Expand Down
23 changes: 2 additions & 21 deletions R/select_cell_lines.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,12 @@
#' * `Others` cell lines that do not meet above criteria.
#'
#' @examples
#' \dontrun{
#' # Looking for TP53 mutants in all cancer cell lines (pan-cancer search)
#' select_cell_lines(input_gene = "TP53", data_dir = "/path/to/DepMap_data/")
#' gretta_data_dir <- "/projects/marralab/ytakemon_prj/DepMap/GRETTA_data/22Q2/data"
#'
#' select_cell_lines(
#' input_gene = "TP53",
#' input_aa_change = "R175H",
#' data_dir = "/path/to/DepMap_data/")
#'
#' # TP53 mutants only in SCLC subtypes
#' select_cell_lines(input_gene = "TP53",
#' input_disease = "Lung Cancer",
#' input_disease_subtype = "Small Cell Lung Cancer (SCLC)",
#' data_dir = "/path/to/DepMap_data/")
#'
#' select_cell_lines(input_gene = "TP53",
#' input_aa_change = "R175H",
#' input_disease = "Lung Cancer",
#' input_disease_subtype = "Small Cell Lung Cancer (SCLC)",
#' data_dir = "/path/to/DepMap_data/")
#'
#' # All cancer cell lines that are from Lung Cancers
#' select_cell_lines(input_disease = "Lung Cancer", data_dir = "/path/to/DepMap_data/")
#' data_dir = gretta_data_dir)
#'
#' }

select_cell_lines <- function(input_gene = NULL, input_aa_change = NULL, input_disease = NULL, input_disease_subtype = NULL, data_dir = NULL){

Expand Down
Loading

0 comments on commit 5691082

Please sign in to comment.