### Install scProportionTest R Library Source: https://github.com/rpolicastro/scproportiontest/blob/master/README.md Installs the scProportionTest R library from GitHub using the devtools package. Ensure devtools is installed prior to running this command. ```R devtools::install_github("rpolicastro/scProportionTest") ``` -------------------------------- ### Initialize scProportionTest Analysis Object Source: https://github.com/rpolicastro/scproportiontest/blob/master/README.md Loads the scProportionTest library, reads example Seurat data, and creates an analysis object using the sc_utils function. This function requires a pre-processed Seurat object as input. ```R library("scProportionTest") seurat_data <- system.file("extdata", "example_data.RDS", package = "scProportionTest") seurat_data <- readRDS(seurat_data) prop_test <- sc_utils(seurat_data) ``` -------------------------------- ### Create sc_utils Object from Seurat Source: https://context7.com/rpolicastro/scproportiontest/llms.txt Constructs an sc_utils object by extracting cell metadata from a Seurat object. This object is essential for subsequent analyses within the scProportionTest workflow. It requires the Seurat package and a processed Seurat object as input. ```r library("scProportionTest") library("Seurat") # Load example Seurat object with processed scRNA-seq data seurat_data <- system.file("extdata", "example_data.RDS", package = "scProportionTest") seurat_obj <- readRDS(seurat_data) # Create sc_utils object from Seurat metadata # Extracts all metadata columns including cluster assignments and sample identities prop_test <- sc_utils(seurat_obj) # The object now contains: # - meta_data slot: data.table with cell_id and all metadata columns # - results slot: empty list ready to store analysis results ``` -------------------------------- ### Generate Point-Range Plot for Proportion Test Results Source: https://github.com/rpolicastro/scproportiontest/blob/master/README.md Creates a point-range plot to visualize the results of the permutation test. This function takes the analysis object containing the test results as input. ```R permutation_plot(prop_test) ``` -------------------------------- ### Visualize Proportion Test Results Source: https://context7.com/rpolicastro/scproportiontest/llms.txt Generates a ggplot2-based point-range plot to visualize the results of the proportion test. It displays observed log2 fold differences with bootstrap confidence intervals, color-coded by statistical significance based on FDR and log2 fold change thresholds. The plot can be customized with additional ggplot2 layers. ```r # Create publication-ready plot of proportion test results # FDR_threshold: significance cutoff for false discovery rate (default: 0.05) # log2FD_threshold: effect size cutoff for biological significance (default: log2(1.5)) # order_clusters: sort clusters by observed log2 fold difference (default: TRUE) p <- permutation_plot( prop_test, FDR_threshold = 0.05, log2FD_threshold = log2(1.5), order_clusters = TRUE ) # The plot displays: # - X-axis: clusters ordered by effect size # - Y-axis: observed log2 fold difference # - Points: observed log2FD values # - Error bars: 95% bootstrap confidence intervals # - Horizontal lines: zero reference (solid) and significance thresholds (dashed) # - Colors: salmon for significant results, grey for non-significant # Save or display the plot ggsave("proportion_test_results.pdf", p, width = 8, height = 6) print(p) # Customize plot with ggplot2 layers library(ggplot2) p + labs( title = "Cluster Proportion Changes", x = "Cell Clusters", y = "Log2 Fold Difference (Treatment vs Control)" ) + theme(legend.position = "bottom") ``` -------------------------------- ### Perform Permutation Test for Cluster Proportions Source: https://context7.com/rpolicastro/scproportiontest/llms.txt Conducts a permutation test to compare cell cluster proportions between two samples, also generating bootstrap confidence intervals for the log2 fold differences. It requires a sc_utils object, cluster and sample identity column names, and reference/comparison sample labels. The number of permutations influences the accuracy of p-values and confidence intervals. ```r # Run permutation test comparing two experimental conditions # cluster_identity: column name containing cluster assignments # sample_1: reference sample (e.g., control) # sample_2: comparison sample (e.g., treatment) # sample_identity: column name containing sample labels # n_permutations: number of permutations for both permutation test and bootstrap (default: 1000) prop_test <- permutation_test( prop_test, cluster_identity = "custom_clusters", sample_1 = "HT29_EV", sample_2 = "HT29_LSD1_KD", sample_identity = "orig.ident", n_permutations = 1000 ) # Access results stored in prop_test@results$permutation # Returns data.table with columns: # - clusters: cluster names # - HT29_EV: fraction of cells in control # - HT29_LSD1_KD: fraction of cells in treatment # - obs_log2FD: observed log2 fold difference # - pval: permutation test p-value # - FDR: false discovery rate (Benjamini-Hochberg correction) # - boot_mean_log2FD: bootstrap mean of log2 fold difference # - boot_CI_2.5, boot_CI_97.5: 95% confidence interval bounds results <- prop_test@results$permutation print(results) # Example output: # clusters HT29_EV HT29_LSD1_KD obs_log2FD pval FDR boot_mean_log2FD boot_CI_2.5 boot_CI_97.5 # 1: cluster1 0.150 0.220 0.552 0.023 0.069 0.548 0.251 0.842 # 2: cluster2 0.100 0.080 -0.322 0.456 0.608 -0.318 -0.721 0.089 ``` -------------------------------- ### Perform Permutation Test for Cell Proportions Source: https://github.com/rpolicastro/scproportiontest/blob/master/README.md Conducts a permutation test to compare cell proportions between specified samples within a Seurat object. Requires the analysis object, cluster identity column, sample identifiers, and the sample identity column. ```R prop_test <- permutation_test( prop_test, cluster_identity = "custom_clusters", sample_1 = "HT29_EV", sample_2 = "HT29_LSD1_KD", sample_identity = "orig.ident" ) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.