### weights_from_pst usage example Source: https://github.com/hectorrdb/condiments/blob/master/man/weights_from_pst.Rd Re-creates a weight matrix from pseudotime matrices. Uses the slingshot example data and requires the slingshot package. ```R data(list = 'slingshotExample', package = "slingshot") if (!"cl" %in% ls()) { rd <- slingshotExample$rd cl <- slingshotExample$cl } sds <- slingshot::slingshot(rd, cl) weights_from_pst(slingshot::slingPseudotime(sds)) ``` -------------------------------- ### topologyTest_multipleSamples usage example Source: https://github.com/hectorrdb/condiments/blob/master/man/topologyTest_multipleSamples.Rd Example from the documentation showing how to run topologyTest_multipleSamples on a slingshot object with conditions and sample assignments. It loads the slingshot example data, creates a condition factor, fits a slingshot object, and assigns cells to samples before calling the function with rep=10. ```r data('slingshotExample', package = "slingshot") rd <- slingshotExample$rd cl <- slingshotExample$cl condition <- factor(rep(c('A','B'), length.out = nrow(rd))) condition[110:139] <- 'A' sds <- slingshot::slingshot(rd, cl) samples <- sample(1:2, 140, replace = TRUE) topologyTest_multipleSamples(sds = sds, conditions = condition, Samples = samples, rep = 10) ``` -------------------------------- ### Reproduce toy_dataset with create_differential_topology Source: https://github.com/hectorrdb/condiments/blob/master/man/toy_dataset.Rd Generates the toy_dataset object used in the vignette and examples. Requires the condiments package and sets a random seed for reproducibility. The code creates a differential topology with 1000 cells, scales the second dimension, and assigns cluster labels via k-means. ```R set.seed(21) library(condiments) data <- create_differential_topology(n_cells = 1000, shift = 0) data$sd$Dim2 <- data$sd$Dim2 * 5 data$mst$Dim2 <- data$mst$Dim2 * 5 data$sd$cl <- kmeans(as.matrix(data$sd[, 1:2]), 8)$cluster data$sd$cl <- as.character(data$sd$cl) ``` -------------------------------- ### nLineages usage example Source: https://github.com/hectorrdb/condiments/blob/master/man/nLineages.Rd Loads the slingshot example data, creates a slingshot object, and calls nLineages to return the number of lineages. The example checks if 'cl' is not in the environment before assigning the data. ```R data(list = 'slingshotExample', package = "slingshot") if (!"cl" %in% ls()) { rd <- slingshotExample$rd cl <- slingshotExample$cl } sds <- slingshot::slingshot(rd, cl) nLineages(sds) ``` -------------------------------- ### Install development version of condiments from GitHub Source: https://github.com/hectorrdb/condiments/blob/master/README.md Installs the development version of condiments from GitHub using devtools. Requires devtools; if it is not installed, the snippet installs it first. ```R if(!requireNamespace("devtools", quietly = TRUE)) { install.packages("devtools") } devtools::install_github("HectorRDB/condiments") ``` -------------------------------- ### topologyTest example with slingshotExample Source: https://github.com/hectorrdb/condiments/blob/master/man/topologyTest.Rd Runs topologyTest on a slingshot example dataset with two conditions and 10 permutations. The condition vector is modified so that cells 110-139 are assigned to condition 'A'. ```r data('slingshotExample', package = "slingshot") rd <- slingshotExample$rd cl <- slingshotExample$cl condition <- factor(rep(c('A','B'), length.out = nrow(rd))) condition[110:139] <- 'A' sds <- slingshot::getLineages(rd, cl) topologyTest(sds, condition, rep = 10) ``` -------------------------------- ### merge_sds example with slingshotExample data Source: https://github.com/hectorrdb/condiments/blob/master/man/merge_sds.Rd Loads the slingshot example data, runs slingshot trajectory inference, and merges two identical slingshot datasets using a lineage mapping matrix. The mapping matrix has one column per dataset and each row maps lineages; here both datasets map lineage 1 to 1 and lineage 2 to 2. ```R data(list = 'slingshotExample', package = "slingshot") if (!"cl" %in% ls()) { rd <- slingshotExample$rd cl <- slingshotExample$cl } sds <- slingshot::slingshot(rd, cl) merge_sds(sds, sds, mapping = matrix(c(1, 2, 1, 2), nrow = 2)) ``` -------------------------------- ### progressionTest_multipleSamples usage example Source: https://github.com/hectorrdb/condiments/blob/master/man/progressionTest_multipleSamples.Rd Example from the documentation showing how to run the differential progression test with multiple samples using a SlingshotDataSet. It creates a synthetic dataset, defines conditions, fits a slingshot object, and calls progressionTest_multipleSamples with the Samples argument. ```r data('slingshotExample', package = "slingshot") rd <- slingshotExample$rd cl <- slingshotExample$cl condition <- factor(rep(c('A','B'), length.out = nrow(rd))) condition[110:139] <- 'A' sds <- slingshot::slingshot(rd, cl) samples <- sample(1:2, 140, replace = TRUE) progressionTest_multipleSamples(pseudotime = sds, conditions = condition, Samples = samples) ``` -------------------------------- ### Install condiments from Bioconductor Source: https://github.com/hectorrdb/condiments/blob/master/README.md Installs the stable release of the condiments package from Bioconductor. Requires BiocManager; if it is not installed, the snippet installs it first. ```R if(!requireNamespace("BiocManager", quietly = TRUE)) { install.packages("BiocManager") } BiocManager::install("condiments") ``` -------------------------------- ### Example: Running fateSelectionTest_multipleSamples on slingshot data Source: https://github.com/hectorrdb/condiments/blob/master/man/fateSelectionTest_multipleSamples.Rd Shows how to run the differential fate selection test with multiple samples using the slingshot example dataset. It creates a condition vector, fits a slingshot trajectory, assigns samples, and calls fateSelectionTest_multipleSamples with the SlingshotDataSet method. ```r data('slingshotExample', package = "slingshot") rd <- slingshotExample$rd cl <- slingshotExample$cl condition <- factor(rep(c('A','B'), length.out = nrow(rd))) condition[110:139] <- 'A' sds <- slingshot::slingshot(rd, cl) samples <- sample(1:2, 140, replace = TRUE) fateSelectionTest_multipleSamples(cellWeights = sds, conditions = condition, Samples = samples) ``` -------------------------------- ### progressionTest example with slingshot data Source: https://github.com/hectorrdb/condiments/blob/master/man/progressionTest.Rd Example from the progressionTest Rd file. It loads the slingshot example data, creates a condition factor, runs slingshot to get a SlingshotDataSet, and then calls progressionTest with the condition. The condition vector is modified so that cells 110 to 139 are assigned to condition 'A'. ```r data('slingshotExample', package = "slingshot") rd <- slingshotExample$rd cl <- slingshotExample$cl condition <- factor(rep(c('A','B'), length.out = nrow(rd))) condition[110:139] <- 'A' sds <- slingshot::slingshot(rd, cl) progressionTest(sds, condition) ``` -------------------------------- ### Refit slingshot per condition with slingshot_conditions Source: https://github.com/hectorrdb/condiments/blob/master/man/slingshot_conditions.Rd Run slingshot_conditions on a SlingshotDataSet with a condition vector. The example loads the slingshot example data, creates a condition factor, runs slingshot, then refits per condition. The result is a list of SlingshotDataSet objects, one per condition. ```R data('slingshotExample', package = "slingshot") rd <- slingshotExample$rd cl <- slingshotExample$cl condition <- factor(rep(c('A','B'), length.out = nrow(rd))) condition[110:139] <- 'A' sds <- slingshot::slingshot(rd, cl) sdss <- slingshot_conditions(sds, condition) ``` -------------------------------- ### Run differentiationTest with slingshot example data Source: https://github.com/hectorrdb/condiments/blob/master/man/differentiationTest.Rd Tests whether cell repartition between lineages is independent of conditions. Uses the slingshot example dataset and a condition factor with two levels ('A' and 'B'), then runs the test on a slingshot object. ```R data('slingshotExample', package = "slingshot") rd <- slingshotExample$rd cl <- slingshotExample$cl condition <- factor(rep(c('A','B'), length.out = nrow(rd))) condition[110:139] <- 'A' sds <- slingshot::slingshot(rd, cl) differentiationTest(sds, condition) ``` -------------------------------- ### fateSelectionTest example with slingshot data Source: https://github.com/hectorrdb/condiments/blob/master/man/fateSelectionTest.Rd Runs fateSelectionTest on the slingshot example dataset with a condition vector where cells 110-139 are set to 'A'. The example uses a SlingshotDataSet object created from the example data. ```R data('slingshotExample', package = "slingshot") rd <- slingshotExample$rd cl <- slingshotExample$cl condition <- factor(rep(c('A','B'), length.out = nrow(rd))) condition[110:139] <- 'A' sds <- slingshot::slingshot(rd, cl) fateSelectionTest(sds, condition) ``` -------------------------------- ### Fit GAM and test for differential expression with tradeSeq Source: https://github.com/hectorrdb/condiments/blob/master/vignettes/condiments.Rmd Requires tradeSeq > 1.3.0. Fits a generalized additive model (GAM) to the count matrix and smooths over the trajectory, then tests for condition-dependent expression. The example assumes a count matrix 'counts', a Slingshot object 'sds', and a condition vector 'df$conditions'. ```R library(tradeSeq) sce <- fitGAM(counts = counts, sds = sds, conditions = df$conditions) cond_genes <- conditionTest(sds) ``` -------------------------------- ### Set up knitr options Source: https://github.com/hectorrdb/condiments/blob/master/vignettes/condiments.Rmd Initial chunk to set knitr options for figure positioning and alignment. ```r library(knitr) opts_chunk$set( fig.pos = "!h", out.extra = "", fig.align = "center" ) ``` -------------------------------- ### Load libraries and set seed Source: https://github.com/hectorrdb/condiments/blob/master/vignettes/condiments.Rmd Loads required packages for analysis, data manipulation, and visualization, and sets a random seed for reproducibility. ```r # For analysis library(condiments) library(slingshot) # For data manipulation library(dplyr) library(tidyr) # For visualization library(ggplot2) library(RColorBrewer) library(viridis) set.seed(2071) theme_set(theme_classic()) ``` -------------------------------- ### Load toy dataset Source: https://github.com/hectorrdb/condiments/blob/master/vignettes/condiments.Rmd Loads the toy dataset from the condiments package and extracts the single-cell metadata data frame. ```r data("toy_dataset", package = "condiments") df <- toy_dataset$sd ``` -------------------------------- ### Run topologyTest with default method and custom rep Source: https://github.com/hectorrdb/condiments/blob/master/vignettes/controls.Rmd Runs the topologyTest function with the default method but reduces the number of permutations to 10 (instead of the default 100) to limit run time, which may increase variability in test statistics. ```r top_res <- topologyTest(sds = sds, conditions = df$conditions, rep = 10) knitr::kable(top_res) ``` -------------------------------- ### Load toy dataset and create slingshot object Source: https://github.com/hectorrdb/condiments/blob/master/vignettes/controls.Rmd Loads the toy dataset from the condiments package, extracts the reduced dimensions, and fits a slingshot trajectory for downstream topology tests. ```r data("toy_dataset", package = "condiments") df <- toy_dataset$sd rd <- as.matrix(df[, c("Dim1", "Dim2")]) sds <- slingshot(rd, df$cl) ``` -------------------------------- ### Run topologyTest on slingshot trajectory Source: https://github.com/hectorrdb/condiments/blob/master/vignettes/condiments.Rmd Fits a slingshot trajectory and runs topologyTest to assess whether a common trajectory is appropriate. The test uses repeated permutations and can take about 1m30s to run. ```R rd <- as.matrix(df[, c("Dim1", "Dim2")]) sds <- slingshot(rd, df$cl) ## Takes ~1m30s to run top_res <- topologyTest(sds = sds, conditions = df$conditions) knitr::kable(top_res) ``` -------------------------------- ### Run topologyTest with multiple methods and thresholds Source: https://github.com/hectorrdb/condiments/blob/master/vignettes/controls.Rmd Specifies multiple test methods (KS_mean and Classifier) and multiple thresholds (0, .01, .05, .1) in a single topologyTest call. The permutation step is shared across methods, saving computation time. ```r top_res <- topologyTest(sds = sds, conditions = df$conditions, rep = 10, methods = c("KS_mean", "Classifier"), threshs = c(0, .01, .05, .1)) knitr::kable(top_res) ``` -------------------------------- ### Run topologyTest with parallelisation using BiocParallel Source: https://github.com/hectorrdb/condiments/blob/master/vignettes/controls.Rmd Configures BiocParallel to use 4 workers and enables parallel execution in topologyTest by setting parallel=TRUE and passing the BPPARAM object. ```r library(BiocParallel) BPPARAM <- bpparam() BPPARAM$progressbar <- TRUE BPPARAM$workers <- 4 top_res <- topologyTest(sds = sds, conditions = df$conditions, rep = 100, parallel = TRUE, BPPARAM = BPPARAM) knitr::kable(top_res) ``` -------------------------------- ### Display R session information Source: https://github.com/hectorrdb/condiments/blob/master/vignettes/controls.Rmd Use this R code to print the session information, including R version, platform, and attached packages. Useful for reproducibility and debugging. ```r sessionInfo() ``` -------------------------------- ### Load packages and set seed for condiments workflow Source: https://github.com/hectorrdb/condiments/blob/master/vignettes/controls.Rmd Loads the condiments and slingshot packages and sets a random seed for reproducibility before running the workflow. ```r # For analysis library(condiments) library(slingshot) set.seed(21) ``` -------------------------------- ### Plot pseudotime distributions by condition Source: https://github.com/hectorrdb/condiments/blob/master/vignettes/condiments.Rmd Creates a faceted density plot of pseudotime distributions per lineage, colored by condition. The plot reveals differences between conditions in lineage 2. ```r ggplot(psts, aes(x = pseudotime, fill = conditions)) + geom_density(alpha = .5) + scale_fill_brewer(type = "qual") + facet_wrap(~lineages) + theme(legend.position = "bottom") ``` -------------------------------- ### Run progressionTest with global and per-lineage tests Source: https://github.com/hectorrdb/condiments/blob/master/vignettes/condiments.Rmd Tests for differential progression using the default custom KS test. Setting global = TRUE pools all lineages, while lineages = TRUE tests each lineage independently. The result is displayed as a table. ```r prog_res <- progressionTest(sds, conditions = df$conditions, global = TRUE, lineages = TRUE) knitr::kable(prog_res) ``` -------------------------------- ### Visualize slingshot trajectory Source: https://github.com/hectorrdb/condiments/blob/master/vignettes/condiments.Rmd Plots the inferred slingshot trajectory curves over the cluster labels. ```R ggplot(df, aes(x = Dim1, y = Dim2, col = cl)) + geom_point() + geom_path(data = slingCurves(sds, as.df = TRUE) %>% arrange(Order), aes(group = Lineage), col = "black", size = 2) ``` -------------------------------- ### Pass custom arguments to topologyTest method Source: https://github.com/hectorrdb/condiments/blob/master/vignettes/controls.Rmd Passes additional parameters to the wasserstein_permutation method via args_wass, enabling a faster permutation test with S=100 and 100 iterations. ```r top_res <- topologyTest(sds = sds, conditions = df$conditions, rep = 10, methods = "wasserstein_permutation", args_wass = list(fast = TRUE, S = 100, iterations = 10^2)) knitr::kable(top_res) ``` -------------------------------- ### Extract pseudotime values per lineage and condition Source: https://github.com/hectorrdb/condiments/blob/master/vignettes/condiments.Rmd Prepares a data frame of pseudotime values for each lineage and condition using slingPseudotime and the condition labels from df. The resulting psts object is used for visualization and testing. ```r psts <- slingPseudotime(sds) %>% as.data.frame() %>% mutate(cells = rownames(.), conditions = df$conditions) %>% pivot_longer(starts_with("Lineage"), values_to = "pseudotime", names_to = "lineages") ``` -------------------------------- ### Create simulated differential topology dataset with create_differential_topology() Source: https://github.com/hectorrdb/condiments/blob/master/man/create_differential_topology.Rd Generates a simulated reduced dimension dataset with two lineages and two conditions. Returns a list with 'sd' (dataframe of reduced dimensions, lineage, and condition) and 'mst' (trajectory skeleton). Default parameters: n_cells=200, noise=0.15, shift=10, unbalance_level=0.9, speed=1. ```R sd <- create_differential_topology() ``` -------------------------------- ### Run fateSelectionTest with pairwise = TRUE Source: https://github.com/hectorrdb/condiments/blob/master/vignettes/condiments.Rmd Runs the fateSelectionTest with global = FALSE and pairwise = TRUE to test for differential fate selection. The default classifier test is used, and the result is displayed as a table. A seed is set for reproducibility. ```r set.seed(12) dif_res <- fateSelectionTest(sds, conditions = df$conditions, global = FALSE, pairwise = TRUE) knitr::kable(dif_res) ``` -------------------------------- ### Plot lineage weights for first lineage Source: https://github.com/hectorrdb/condiments/blob/master/vignettes/condiments.Rmd Visualizes the distribution of curve weights for the first lineage across conditions using a density plot. The weights are obtained from slingCurveWeights with as.probs = TRUE, and the plot uses a qualitative color scale. ```r df$weight_1 <- slingCurveWeights(sds, as.probs = TRUE)[, 1] ggplot(df, aes(x = weight_1, fill = conditions)) + geom_density(alpha = .5) + scale_fill_brewer(type = "qual") + labs(x = "Curve weight for the first lineage") ``` -------------------------------- ### progressionTest_multipleSamples,matrix-method Source: https://github.com/hectorrdb/condiments/blob/master/man/progressionTest_multipleSamples.Rd S4 method for matrix pseudotime input. Requires cellWeights, conditions, and Samples arguments. ```APIDOC ## progressionTest_multipleSamples,matrix-method ### Description S4 method for matrix pseudotime input. ### Usage \S4method{progressionTest_multipleSamples}{matrix}( pseudotime, cellWeights, conditions, Samples, ... ) ### Arguments - **pseudotime** - A matrix of pseudotime values, each row represents a cell and each column represents a lineage. - **cellWeights** - Cell weights for each lineage. Ignored if pseudotime is not a matrix. - **conditions** - Either the vector of conditions, or a character indicating which column of the metadata contains this vector. - **Samples** - A vector assigning each cell to a sample. Samples must be shared across all conditions. - **...** - Other arguments passed to progressionTest. ### Value Returns the same object as progressionTest with one additional column per sample. ``` -------------------------------- ### Change method to Classifier and threshold to .05 Source: https://github.com/hectorrdb/condiments/blob/master/vignettes/controls.Rmd Uses method = "Classifier" for progressionTest and thresh = .05 for fateSelectionTest, while keeping other arguments at their defaults. Results are displayed with knitr::kable(). ```R prog_res <- progressionTest(sds, conditions = df$conditions, method = "Classifier") knitr::kable(prog_res) dif_res <- fateSelectionTest(sds, conditions = df$conditions, thresh = .05) knitr::kable(dif_res) ``` -------------------------------- ### Plot cells by condition Source: https://github.com/hectorrdb/condiments/blob/master/vignettes/condiments.Rmd Creates a scatter plot of cells in reduced dimensions, colored by condition. ```r p <- ggplot(df, aes(x = Dim1, y = Dim2, col = conditions)) + geom_point() + scale_color_brewer(type = "qual") p ``` -------------------------------- ### topologyTest_multipleSamples,PseudotimeOrdering-method(sds, conditions, Samples, ...) Source: https://github.com/hectorrdb/condiments/blob/master/man/topologyTest_multipleSamples.Rd S4 method for PseudotimeOrdering objects. Tests differential topology across conditions per sample, with samples not confounded by conditions. ```APIDOC ## topologyTest_multipleSamples,PseudotimeOrdering-method(sds, conditions, Samples, ...) ### Description S4 method for PseudotimeOrdering objects. Tests differential topology across conditions per sample, with samples not confounded by conditions. ### Usage ```r \S4method{topologyTest_multipleSamples}{PseudotimeOrdering}(sds, conditions, Samples, ...) ``` ### Arguments - **sds** - A slingshot object already run on the full dataset. Can be either a SlingshotDataSet or a SingleCellExperiment object. - **conditions** - Either the vector of conditions, or a character indicating which column of the metadata contains this vector. - **Samples** - A vector assigning each cell to a sample. Samples must be shared across all conditions. - **...** - Other arguments passed to topologyTest. ### Value Returns the same object as topologyTest with one more column per sample. ``` -------------------------------- ### progressionTest_multipleSamples,PseudotimeOrdering-method Source: https://github.com/hectorrdb/condiments/blob/master/man/progressionTest_multipleSamples.Rd S4 method for PseudotimeOrdering pseudotime input. ```APIDOC ## progressionTest_multipleSamples,PseudotimeOrdering-method ### Description S4 method for PseudotimeOrdering pseudotime input. ### Usage \S4method{progressionTest_multipleSamples}{PseudotimeOrdering}(pseudotime, conditions, Samples, ...) ### Arguments - **pseudotime** - A PseudotimeOrdering object. - **conditions** - Either the vector of conditions, or a character indicating which column of the metadata contains this vector. - **Samples** - A vector assigning each cell to a sample. Samples must be shared across all conditions. - **...** - Other arguments passed to progressionTest. ### Value Returns the same object as progressionTest with one additional column per sample. ``` -------------------------------- ### Run default progressionTest and fateSelectionTest Source: https://github.com/hectorrdb/condiments/blob/master/vignettes/controls.Rmd Runs the default progression and fate selection tests on a SlingshotDataSet with conditions from df$conditions. The results are displayed with knitr::kable(). ```R prog_res <- progressionTest(sds, conditions = df$conditions) knitr::kable(prog_res) dif_res <- fateSelectionTest(sds, conditions = df$conditions) knitr::kable(dif_res) ``` -------------------------------- ### topologyTest usage and methods Source: https://github.com/hectorrdb/condiments/blob/master/man/topologyTest.Rd Shows the generic and S4 method signatures for topologyTest on SlingshotDataSet, SingleCellExperiment, and PseudotimeOrdering objects. Default methods are 'KS_mean' for two conditions and 'Classifier' otherwise. ```r topologyTest(sds, ...) ``` ```r \S4method{topologyTest}{SlingshotDataSet}( sds, conditions, rep = 100, threshs = 0.01, methods = ifelse(dplyr::n_distinct(conditions) == 2, "KS_mean", "Classifier"), parallel = FALSE, BPPARAM = BiocParallel::bpparam(), args_mmd = list(), args_classifier = list(), args_wass = list(), nmax = nrow(slingshot::slingPseudotime(sds)), distinct_samples = NULL ) ``` ```r \S4method{topologyTest}{SingleCellExperiment}( sds, conditions, rep = 100, threshs = 0.01, methods = ifelse(dplyr::n_distinct(conditions) == 2, "KS_mean", "Classifier"), parallel = FALSE, BPPARAM = BiocParallel::bpparam(), args_mmd = list(), args_classifier = list(), args_wass = list(), nmax = ncol(sds), distinct_samples = NULL ) ``` ```r \S4method{topologyTest}{PseudotimeOrdering}( sds, conditions, rep = 100, threshs = 0.01, methods = ifelse(dplyr::n_distinct(conditions) == 2, "KS_mean", "Classifier"), parallel = FALSE, BPPARAM = BiocParallel::bpparam(), args_mmd = list(), args_classifier = list(), args_wass = list(), nmax = nrow(slingshot::slingPseudotime(sds)), distinct_samples = NULL ) ``` -------------------------------- ### topologyTest_multipleSamples,SingleCellExperiment-method(sds, conditions, Samples, ...) Source: https://github.com/hectorrdb/condiments/blob/master/man/topologyTest_multipleSamples.Rd S4 method for SingleCellExperiment objects. Tests differential topology across conditions per sample, with samples not confounded by conditions. ```APIDOC ## topologyTest_multipleSamples,SingleCellExperiment-method(sds, conditions, Samples, ...) ### Description S4 method for SingleCellExperiment objects. Tests differential topology across conditions per sample, with samples not confounded by conditions. ### Usage ```r \S4method{topologyTest_multipleSamples}{SingleCellExperiment}(sds, conditions, Samples, ...) ``` ### Arguments - **sds** - A slingshot object already run on the full dataset. Can be either a SlingshotDataSet or a SingleCellExperiment object. - **conditions** - Either the vector of conditions, or a character indicating which column of the metadata contains this vector. - **Samples** - A vector assigning each cell to a sample. Samples must be shared across all conditions. - **...** - Other arguments passed to topologyTest. ### Value Returns the same object as topologyTest with one more column per sample. ``` -------------------------------- ### progressionTest_multipleSamples,SlingshotDataSet-method Source: https://github.com/hectorrdb/condiments/blob/master/man/progressionTest_multipleSamples.Rd S4 method for SlingshotDataSet pseudotime input. ```APIDOC ## progressionTest_multipleSamples,SlingshotDataSet-method ### Description S4 method for SlingshotDataSet pseudotime input. ### Usage \S4method{progressionTest_multipleSamples}{SlingshotDataSet}(pseudotime, conditions, Samples, ...) ### Arguments - **pseudotime** - A SlingshotDataSet object. - **conditions** - Either the vector of conditions, or a character indicating which column of the metadata contains this vector. - **Samples** - A vector assigning each cell to a sample. Samples must be shared across all conditions. - **...** - Other arguments passed to progressionTest. ### Value Returns the same object as progressionTest with one additional column per sample. ``` -------------------------------- ### create_differential_topology(n_cells, noise, shift, unbalance_level, speed) Source: https://github.com/hectorrdb/condiments/blob/master/man/create_differential_topology.Rd Creates a simulated reduced dimension dataset for testing differential topology analysis. Returns a list containing the cell data and trajectory skeleton. ```APIDOC ## create_differential_topology(n_cells, noise, shift, unbalance_level, speed) ### Description Creates a simulated reduced dimension dataset for testing differential topology analysis. ### Usage ```r create_differential_topology( n_cells = 200, noise = 0.15, shift = 10, unbalance_level = 0.9, speed = 1 ) ``` ### Parameters - **n_cells** (numeric) - Optional - The number of cells in the dataset. Default: 200. - **noise** (numeric) - Optional - Amount of noise. Between 0 and 1. Default: 0.15. - **shift** (numeric) - Optional - How much should the top lineage shift in condition B. Default: 10. - **unbalance_level** (numeric) - Optional - How much should the bottom lineage be unbalanced toward condition A. Default: 0.9. - **speed** (numeric) - Optional - How fast the cells from condition B should differentiate. Default: 1. ### Return Value A list with two components: - **sd**: An `n_cells` by 4 dataframe containing reduced dimensions coordinates, lineage assignment (1 or 2), and condition assignment (A or B) for each cell. - **mst**: A data.frame containing the skeleton of the trajectories. ### Example ```r sd <- create_differential_topology() ``` ``` -------------------------------- ### topologyTest,PseudotimeOrdering-method Source: https://github.com/hectorrdb/condiments/blob/master/man/topologyTest.Rd Method for PseudotimeOrdering objects. Tests differential topology across conditions using permutation-based tests. ```APIDOC ## topologyTest,PseudotimeOrdering-method ### Description Method for PseudotimeOrdering objects. Tests differential topology across conditions. ### Usage ```r \S4method{topologyTest}{PseudotimeOrdering}( sds, conditions, rep = 100, threshs = 0.01, methods = ifelse(dplyr::n_distinct(conditions) == 2, "KS_mean", "Classifier"), parallel = FALSE, BPPARAM = BiocParallel::bpparam(), args_mmd = list(), args_classifier = list(), args_wass = list(), nmax = nrow(slingshot::slingPseudotime(sds)), distinct_samples = NULL ) ``` ### Arguments - **sds** - A PseudotimeOrdering object already run on the full dataset. - **conditions** - Either the vector of conditions, or a character indicating which column of the metadata contains this vector. - **rep** - How many permutations to run. Default to 100. - **threshs** - the threshold(s) for the KS test or classifier test. Default to .01. - **methods** - The method(s) to use to test. Must be among 'KS_mean', 'Classifier', "KS_all', "mmd' and 'wasserstein_permutation'. - **parallel** - Logical, defaults to FALSE. Set to TRUE if you want to parallellize the fitting. - **BPPARAM** - object of class bpparamClass that specifies the back-end to be used for computations. - **args_mmd** - arguments passed to the mmd test. - **args_classifier** - arguments passed to the classifier test. - **args_wass** - arguments passed to the wasserstein permutation test. - **nmax** - How many samples to use to compute the mmd test. Default to number of rows in slingPseudotime(sds). - **distinct_samples** - The samples to which each cell belong to. Only use with method `distinct`. ### Value A list containing the following components: - **method** - The method used to test - **thresh** - The threshold (if relevant) - **statistic** - the value of the test statistic. - **p.value** - the p-value of the test. ``` -------------------------------- ### slingshot_conditions,PseudotimeOrdering-method Source: https://github.com/hectorrdb/condiments/blob/master/man/slingshot_conditions.Rd S4 method for PseudotimeOrdering objects that refits slingshot per condition with additional parameters for approximation, skeleton adjustment, and verbosity. ```APIDOC ## slingshot_conditions,PseudotimeOrdering-method ### Description S4 method for PseudotimeOrdering objects that refits slingshot per condition with additional parameters for approximation, skeleton adjustment, and verbosity. ### Method S4 method ### Signature slingshot_conditions(sds, conditions, approx_points = 100, adjust_skeleton = TRUE, verbose = TRUE, ...) ### Parameters - **sds** (PseudotimeOrdering) - Required - A slingshot object already run on the full dataset. - **conditions** (vector or character) - Required - Either the vector of conditions, or a character indicating which column of the metadata contains this vector. - **approx_points** (numeric) - Optional - Passed to getCurves. Default: 100. - **adjust_skeleton** (logical) - Optional - Whether to recompute the locations of the nodes after fitting per conditions. Default: TRUE. - **verbose** (logical) - Optional - Control whether messages are printed. Default: TRUE. - **...** - Optional - Other arguments passed to getCurves. ### Value A list of SlingshotDataSet, one per condition. ``` -------------------------------- ### Plot cells with skeleton structure Source: https://github.com/hectorrdb/condiments/blob/master/vignettes/condiments.Rmd Visualizes the underlying skeleton structure of the two conditions by overlaying the MST on the cell plot, faceted by condition. ```r p <- ggplot(df, aes(x = Dim1, y = Dim2, col = conditions)) + geom_point(alpha = .5) + geom_point(data = toy_dataset$mst, size = 2) + geom_path(data = toy_dataset$mst, aes(group = lineages), size = 1.5) + scale_color_brewer(type = "qual") + facet_wrap(~conditions) + guides(col = FALSE) p ``` -------------------------------- ### weights_from_pst(pseudotime, ...) Source: https://github.com/hectorrdb/condiments/blob/master/man/weights_from_pst.Rd Re-creates a weight matrix from pseudotime matrices for cells assigned to lineages. This function is useful for trajectory inference methods that do not perform soft assignment. ```APIDOC ## weights_from_pst(pseudotime, ...) ### Description Most trajectory inference methods do not perform soft assignment but instead assign cells to all possible lineages before a branching point, and then to one or another. This function re-creates a weight matrix from those matrices of pseudotime. ### Usage ```r weights_from_pst(pseudotime, ...) \S4method{weights_from_pst}{matrix}(pseudotime) \S4method{weights_from_pst}{data.frame}(pseudotime) ``` ### Arguments - **pseudotime** (matrix or data.frame) - Required - A matrix or data.frame of [ncells] by [nCurves]. - **...** - Other parameters including: ### Value A object of the same type and dimensions as the original object, with the weights for each curve and cell. ### Example ```r data(list = 'slingshotExample', package = "slingshot") if (!"cl" %in% ls()) { rd <- slingshotExample$rd cl <- slingshotExample$cl } sds <- slingshot::slingshot(rd, cl) weights_from_pst(slingshot::slingPseudotime(sds)) ``` ``` -------------------------------- ### topologyTest_multipleSamples,SlingshotDataSet-method(sds, conditions, Samples, ...) Source: https://github.com/hectorrdb/condiments/blob/master/man/topologyTest_multipleSamples.Rd S4 method for SlingshotDataSet objects. Tests differential topology across conditions per sample, with samples not confounded by conditions. ```APIDOC ## topologyTest_multipleSamples,SlingshotDataSet-method(sds, conditions, Samples, ...) ### Description S4 method for SlingshotDataSet objects. Tests differential topology across conditions per sample, with samples not confounded by conditions. ### Usage ```r \S4method{topologyTest_multipleSamples}{SlingshotDataSet}(sds, conditions, Samples, ...) ``` ### Arguments - **sds** - A slingshot object already run on the full dataset. Can be either a SlingshotDataSet or a SingleCellExperiment object. - **conditions** - Either the vector of conditions, or a character indicating which column of the metadata contains this vector. - **Samples** - A vector assigning each cell to a sample. Samples must be shared across all conditions. - **...** - Other arguments passed to topologyTest. ### Value Returns the same object as topologyTest with one more column per sample. ``` -------------------------------- ### progressionTest_multipleSamples,SingleCellExperiment-method Source: https://github.com/hectorrdb/condiments/blob/master/man/progressionTest_multipleSamples.Rd S4 method for SingleCellExperiment pseudotime input. ```APIDOC ## progressionTest_multipleSamples,SingleCellExperiment-method ### Description S4 method for SingleCellExperiment pseudotime input. ### Usage \S4method{progressionTest_multipleSamples}{SingleCellExperiment}(pseudotime, conditions, Samples, ...) ### Arguments - **pseudotime** - A SingleCellExperiment object. - **conditions** - Either the vector of conditions, or a character indicating which column of the metadata contains this vector. - **Samples** - A vector assigning each cell to a sample. Samples must be shared across all conditions. - **...** - Other arguments passed to progressionTest. ### Value Returns the same object as progressionTest with one additional column per sample. ``` -------------------------------- ### Pass extra parameters to Classifier via args_classifier Source: https://github.com/hectorrdb/condiments/blob/master/vignettes/controls.Rmd Passes additional arguments to the classifier method using args_classifier = list(method = "rf") for progressionTest. fateSelectionTest is run with default settings. Results are displayed with knitr::kable(). ```R prog_res <- progressionTest(sds, conditions = df$conditions, method = "Classifier", args_classifier = list(method = "rf")) knitr::kable(prog_res) dif_res <- fateSelectionTest(sds, conditions = df$conditions) knitr::kable(dif_res) ``` -------------------------------- ### Plot cluster labels Source: https://github.com/hectorrdb/condiments/blob/master/vignettes/condiments.Rmd Plots the cluster labels on the dimensionality reduction representation, used as input for slingshot trajectory inference. ```R ggplot(df, aes(x = Dim1, y = Dim2, col = cl)) + geom_point() ``` -------------------------------- ### Plot raw imbalance scores Source: https://github.com/hectorrdb/condiments/blob/master/vignettes/condiments.Rmd Visualizes the raw imbalance scores on the dimensionality reduction plot using a viridis color scale. ```R ggplot(df, aes(x = Dim1, y = Dim2, col = scores)) + geom_point() + scale_color_viridis_c(option = "C") ``` -------------------------------- ### slingshot_conditions,SingleCellExperiment-method Source: https://github.com/hectorrdb/condiments/blob/master/man/slingshot_conditions.Rd S4 method for SingleCellExperiment objects that refits slingshot per condition with additional parameters for approximation, skeleton adjustment, and verbosity. ```APIDOC ## slingshot_conditions,SingleCellExperiment-method ### Description S4 method for SingleCellExperiment objects that refits slingshot per condition with additional parameters for approximation, skeleton adjustment, and verbosity. ### Method S4 method ### Signature slingshot_conditions(sds, conditions, approx_points = 100, adjust_skeleton = TRUE, verbose = TRUE, ...) ### Parameters - **sds** (SingleCellExperiment) - Required - A slingshot object already run on the full dataset. - **conditions** (vector or character) - Required - Either the vector of conditions, or a character indicating which column of the metadata contains this vector. - **approx_points** (numeric) - Optional - Passed to getCurves. Default: 100. - **adjust_skeleton** (logical) - Optional - Whether to recompute the locations of the nodes after fitting per conditions. Default: TRUE. - **verbose** (logical) - Optional - Control whether messages are printed. Default: TRUE. - **...** - Optional - Other arguments passed to getCurves. ### Value A list of SlingshotDataSet, one per condition. ``` -------------------------------- ### slingshot_conditions,SlingshotDataSet-method Source: https://github.com/hectorrdb/condiments/blob/master/man/slingshot_conditions.Rd S4 method for SlingshotDataSet objects that refits slingshot per condition with additional parameters for approximation, skeleton adjustment, and verbosity. ```APIDOC ## slingshot_conditions,SlingshotDataSet-method ### Description S4 method for SlingshotDataSet objects that refits slingshot per condition with additional parameters for approximation, skeleton adjustment, and verbosity. ### Method S4 method ### Signature slingshot_conditions(sds, conditions, approx_points = 100, adjust_skeleton = TRUE, verbose = TRUE, ...) ### Parameters - **sds** (SlingshotDataSet) - Required - A slingshot object already run on the full dataset. - **conditions** (vector or character) - Required - Either the vector of conditions, or a character indicating which column of the metadata contains this vector. - **approx_points** (numeric) - Optional - Passed to getCurves. Default: 100. - **adjust_skeleton** (logical) - Optional - Whether to recompute the locations of the nodes after fitting per conditions. Default: TRUE. - **verbose** (logical) - Optional - Control whether messages are printed. Default: TRUE. - **...** - Optional - Other arguments passed to getCurves. ### Value A list of SlingshotDataSet, one per condition. ``` -------------------------------- ### Compute imbalance scores with imbalance_score Source: https://github.com/hectorrdb/condiments/blob/master/vignettes/condiments.Rmd Computes raw and scaled imbalance scores for each cell using the imbalance_score function. The neighborhood size is controlled by the k argument; higher values indicate more local imbalance. ```R scores <- imbalance_score(Object = df %>% select(Dim1, Dim2) %>% as.matrix(), conditions = df$conditions) df$scores <- scores$scores df$scaled_scores <- scores$scaled_scores ``` -------------------------------- ### topologyTest,SlingshotDataSet-method Source: https://github.com/hectorrdb/condiments/blob/master/man/topologyTest.Rd Method for SlingshotDataSet objects. Tests differential topology across conditions using permutation-based tests. ```APIDOC ## topologyTest,SlingshotDataSet-method ### Description Method for SlingshotDataSet objects. Tests differential topology across conditions. ### Usage ```r \S4method{topologyTest}{SlingshotDataSet}( sds, conditions, rep = 100, threshs = 0.01, methods = ifelse(dplyr::n_distinct(conditions) == 2, "KS_mean", "Classifier"), parallel = FALSE, BPPARAM = BiocParallel::bpparam(), args_mmd = list(), args_classifier = list(), args_wass = list(), nmax = nrow(slingshot::slingPseudotime(sds)), distinct_samples = NULL ) ``` ### Arguments - **sds** - A SlingshotDataSet object already run on the full dataset. - **conditions** - Either the vector of conditions, or a character indicating which column of the metadata contains this vector. - **rep** - How many permutations to run. Default to 100. - **threshs** - the threshold(s) for the KS test or classifier test. Default to .01. - **methods** - The method(s) to use to test. Must be among 'KS_mean', 'Classifier', "KS_all', "mmd' and 'wasserstein_permutation'. - **parallel** - Logical, defaults to FALSE. Set to TRUE if you want to parallellize the fitting. - **BPPARAM** - object of class bpparamClass that specifies the back-end to be used for computations. - **args_mmd** - arguments passed to the mmd test. - **args_classifier** - arguments passed to the classifier test. - **args_wass** - arguments passed to the wasserstein permutation test. - **nmax** - How many samples to use to compute the mmd test. Default to number of rows in slingPseudotime(sds). - **distinct_samples** - The samples to which each cell belong to. Only use with method `distinct`. ### Value A list containing the following components: - **method** - The method used to test - **thresh** - The threshold (if relevant) - **statistic** - the value of the test statistic. - **p.value** - the p-value of the test. ``` -------------------------------- ### topologyTest_multipleSamples(sds, ...) Source: https://github.com/hectorrdb/condiments/blob/master/man/topologyTest_multipleSamples.Rd Tests whether slingshot should be fitted independently for different conditions per sample, with samples not confounded by conditions. This is the generic function that dispatches to methods based on the class of the sds argument. ```APIDOC ## topologyTest_multipleSamples(sds, ...) ### Description Tests whether slingshot should be fitted independently for different conditions per sample, with samples not confounded by conditions. This is the generic function that dispatches to methods based on the class of the sds argument. ### Usage ```r topologyTest_multipleSamples(sds, ...) ``` ### Arguments - **sds** - A slingshot object already run on the full dataset. Can be either a SlingshotDataSet or a SingleCellExperiment object. - **...** - Other arguments passed to topologyTest. ### Value Returns the same object as topologyTest with one more column per sample. ### Examples ```r data('slingshotExample', package = "slingshot") rd <- slingshotExample$rd cl <- slingshotExample$cl condition <- factor(rep(c('A','B'), length.out = nrow(rd))) condition[110:139] <- 'A' sds <- slingshot::slingshot(rd, cl) samples <- sample(1:2, 140, replace = TRUE) topologyTest_multipleSamples(sds = sds, conditions = condition, Samples = samples, rep = 10) ``` ``` -------------------------------- ### slingshot_conditions(sds, ...) Source: https://github.com/hectorrdb/condiments/blob/master/man/slingshot_conditions.Rd Refits a slingshot trajectory per condition based on an original slingshot object, using the same skeleton. Returns a list of SlingshotDataSet objects, one per condition. ```APIDOC ## slingshot_conditions(sds, ...) ### Description Refits a slingshot trajectory per condition based on an original slingshot object, using the same skeleton. Returns a list of SlingshotDataSet objects, one per condition. ### Method Function call ### Signature slingshot_conditions(sds, ...) ### Parameters - **sds** (SlingshotDataSet or SingleCellExperiment) - Required - A slingshot object already run on the full dataset. - **...** - Optional - Other arguments passed to getCurves. ### Value A list of SlingshotDataSet, one per condition. ### Example ```r data('slingshotExample', package = "slingshot") rd <- slingshotExample$rd cl <- slingshotExample$cl condition <- factor(rep(c('A','B'), length.out = nrow(rd))) condition[110:139] <- 'A' sds <- slingshot::slingshot(rd, cl) sdss <- slingshot_conditions(sds, condition) ``` ```