R Under development (unstable) (2024-10-19 r87247 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > # Load necessary libraries > library(diceplot) > library(dplyr) Attaching package: 'dplyr' The following objects are masked from 'package:stats': filter, lag The following objects are masked from 'package:base': intersect, setdiff, setequal, union > library(ggplot2) > library(tidyr) > > # Define genes > gene_list <- c("GeneA", "GeneB", "GeneC") > > # Define cell types > cell_types <- c("Neuron", "Astrocyte", "Microglia") > > # Define Contrasts > contrasts <- c("Type1", "Type2") # Changed for demonstration > > # Define vars for each Contrast > vars_type1 <- c("MCI-NCI", "AD-MCI", "AD-NCI") > vars_type2 <- c("Amyloid", "Plaq N", "Tangles", "NFT") > > # Create a data frame with all combinations > data <- expand.grid( + gene = gene_list, + Cell_Type = cell_types, # Renamed column + Group = contrasts, # Renamed column + stringsAsFactors = FALSE + ) > > # Add the appropriate vars to each Contrast > set.seed(123) # Ensure reproducibility > data_type1 <- data %>% + filter(Group == "Type1") %>% + mutate(var = sample(vars_type1, n(), replace = TRUE)) > > data_type2 <- data %>% + filter(Group == "Type2") %>% + mutate(var = sample(vars_type2, n(), replace = TRUE)) > > # Combine the data > data <- bind_rows(data_type1, data_type2) > > # Assign random values for logFC and adjusted p-values > data <- data %>% + mutate( + logFC = runif(n(), min = -2, max = 2), # Renamed column + adj_p_value = runif(n(), min = 0.0001, max = 0.05) + ) > > # Use the modified function with custom parameters > p <- domino_plot( + data = data, + gene_list = gene_list, + feature_col = "gene", + celltype_col = "Cell_Type", + contrast_col = "Group", + contrast_levels = c("Type1", "Type2"), + contrast_labels = c("Type 1", "Type 2"), + logfc_col = "logFC", + pval_col = "adj_p_value", + switch_axis = FALSE, + min_dot_size = 1, + max_dot_size = 5, + output_file = "domino_plot_example.png" + ) Warning messages: 1: Removed 90 rows containing missing values or values outside the scale range (`geom_point()`). 2: Removed 90 rows containing missing values or values outside the scale range (`geom_point()`). > > # Display the plot > print(p) Warning messages: 1: Removed 90 rows containing missing values or values outside the scale range (`geom_point()`). 2: Removed 90 rows containing missing values or values outside the scale range (`geom_point()`). > > proc.time() user system elapsed 2.20 0.21 2.40