### Install Python Dependencies Source: https://github.com/gunsagargulati/cytotrace/blob/master/README.md Install required Python packages for multi-batch analysis. ```shell $ pip install scanoramaCT update $ pip install numpy ``` ```shell $ git clone https://github.com/gunsagargulati/scanoramaCT.git $ cd scanorama/ $ python setup.py install --user ``` -------------------------------- ### Install and Load CytoTRACE Source: https://context7.com/gunsagargulati/cytotrace/llms.txt Install the package from GitHub using devtools and load it into the R environment. ```r # Install from GitHub install.packages("devtools") devtools::install_github("gunsagargulati/CytoTRACE") # Load the package library(CytoTRACE) ``` -------------------------------- ### Install CytoTRACE R Package Source: https://github.com/gunsagargulati/cytotrace/blob/master/README.md Install the development version of the package from GitHub using devtools. ```r install.packages("devtools") devtools::install_github("gunsagargulati/CytoTRACE") ``` -------------------------------- ### Access Included Datasets Source: https://context7.com/gunsagargulati/cytotrace/llms.txt Load example bone marrow differentiation datasets provided with the package for testing. ```r library(CytoTRACE) # 10x Genomics bone marrow expression data data(marrow_10x_expr) # Format: Matrix with genes as rows, cells as columns # Values: Unique molecular identifiers (UMIs) dim(marrow_10x_expr) # genes x cells # 10x Genomics bone marrow phenotype labels data(marrow_10x_pheno) # Format: Named character vector matching cell IDs table(marrow_10x_pheno) # View cell type distribution # Smart-seq2 bone marrow expression data data(marrow_plate_expr) # Format: Matrix with genes as rows, cells as columns # Values: Raw counts # Smart-seq2 bone marrow phenotype labels data(marrow_plate_pheno) # Format: Named character vector matching cell IDs # Complete workflow example results <- CytoTRACE(marrow_10x_expr) plotCytoTRACE(results, phenotype = marrow_10x_pheno, gene = "Kit") plotCytoGenes(results, numOfGenes = 15) ``` -------------------------------- ### Configure Python Path for Reticulate Source: https://github.com/gunsagargulati/cytotrace/blob/master/README.md Set the environment variable to ensure R uses the correct Python installation. ```python Sys.setenv(RETICULATE_PYTHON="/PATH/TO/PYTHON/BIN"). ``` -------------------------------- ### Initialize Visualization Source: https://context7.com/gunsagargulati/cytotrace/llms.txt Load the library to prepare for generating 2D visualization plots and tables. ```r library(CytoTRACE) ``` -------------------------------- ### Run iCytoTRACE Integration Source: https://context7.com/gunsagargulati/cytotrace/llms.txt Integrate multiple heterogeneous scRNA-seq datasets using Scanorama before computing differentiation predictions. ```r library(CytoTRACE) # Load two bone marrow datasets profiled on different platforms data(marrow_10x_expr) # 10x Genomics platform data(marrow_plate_expr) # Smart-seq2 platform # Create a list of gene expression matrices # Each matrix should have genes as rows and cells as columns datasets <- list(marrow_10x_expr, marrow_plate_expr) # Run integrated CytoTRACE across multiple batches results <- iCytoTRACE(datasets) # Access integrated results # CytoTRACE scores across all datasets (harmonized) integrated_cytotrace <- results$CytoTRACE # Batch-corrected gene expression matrix (Scanorama-corrected) corrected_expr <- results$exprMatrix # Integrated gene counts signature integrated_gcs <- results$GCS # Corrected gene counts per cell corrected_counts <- results$Counts # Genes associated with iCytoTRACE cyto_genes <- results$cytoGenes # Low-dimensional embedding coordinates (100 t-SNE components) embedding_coords <- results$coord # Filtered cells from all datasets filtered <- results$filteredCells # Run with fast mode for large integrated datasets (>10,000 cells) results_fast <- iCytoTRACE( datasets, enableFast = TRUE, ncores = 4, subsamplesize = 1000 ) ``` -------------------------------- ### Run iCytoTRACE on Multiple Batches Source: https://github.com/gunsagargulati/cytotrace/blob/master/README.md Integrate and analyze multiple scRNA-seq datasets from different platforms. ```r datasets <- list(marrow_10x_expr, marrow_plate_expr) results <- iCytoTRACE(datasets) ``` -------------------------------- ### Run CytoTRACE Analysis and Visualization Source: https://context7.com/gunsagargulati/cytotrace/llms.txt Execute the CytoTRACE algorithm and generate various visualizations including phenotype labels, custom embeddings, and gene expression plots. ```r data(marrow_10x_expr) data(marrow_10x_pheno) # Phenotype labels for cells results <- CytoTRACE(marrow_10x_expr) # Basic visualization - just CytoTRACE scores plotCytoTRACE(results) # Output files: CytoTRACE_plot.pdf, CytoTRACE_plot_table.txt # Full visualization with phenotype labels and gene expression plotCytoTRACE( cyto_obj = results, phenotype = marrow_10x_pheno, # Named character vector of cell phenotypes gene = "Kit" # Gene to visualize (case-insensitive) ) # Output files: # - CytoTRACE_plot.pdf: t-SNE plots colored by CytoTRACE, phenotype, and gene expression # - CytoTRACE_by_Phenotype_Boxplot.pdf: Boxplot of CytoTRACE by phenotype # - CytoTRACE_plot_table.txt: Tab-delimited table with all values # Use custom 2D embedding (e.g., UMAP from Seurat) custom_embedding <- data.frame( UMAP1 = runif(ncol(results$exprMatrix)), # Replace with actual UMAP coordinates UMAP2 = runif(ncol(results$exprMatrix)) ) rownames(custom_embedding) <- colnames(results$exprMatrix) plotCytoTRACE( cyto_obj = results, phenotype = marrow_10x_pheno, gene = "Cd34", emb = custom_embedding # Custom embedding coordinates ) # Custom color palette plotCytoTRACE( cyto_obj = results, phenotype = marrow_10x_pheno, colors = c("purple", "yellow", "green") # Custom gradient colors ) # Specify output directory plotCytoTRACE( cyto_obj = results, phenotype = marrow_10x_pheno, gene = "Kit", outputDir = "/path/to/output/" # Must end with "/" ) # Plot custom values instead of gene expression custom_values <- results$GCS # Gene counts signature plotCytoTRACE( cyto_obj = results, otherValue = custom_values, otherName = "GCS Score" ) ``` -------------------------------- ### Run CytoTRACE on Custom Dataset Source: https://github.com/gunsagargulati/cytotrace/blob/master/README.md Execute CytoTRACE on a single-cell expression matrix, with optional multi-core support. ```r results <- cytoTRACE(marrow_10x_expr) ``` ```r results <- cytoTRACE(marrow_10x_expr, enableFast = TRUE, ncores = 8) ``` -------------------------------- ### iCytoTRACE Function Source: https://context7.com/gunsagargulati/cytotrace/llms.txt Integrates and analyzes multiple heterogeneous scRNA-seq batches/datasets from different platforms. ```APIDOC ## iCytoTRACE(datasets, enableFast = FALSE, ncores = NULL, subsamplesize = 1000) ### Description Uses Scanorama to merge datasets before computing integrated CytoTRACE predictions. Requires Python dependencies (scanoramaCT and numpy). ### Parameters #### Request Body - **datasets** (list) - Required - List of gene expression matrices (genes as rows, cells as columns). - **enableFast** (boolean) - Optional - Enable subsampling for large datasets (>10,000 cells). - **ncores** (integer) - Optional - Number of CPU cores for parallel processing. - **subsamplesize** (integer) - Optional - Subsample size per chunk for fast mode. ### Response - **CytoTRACE** (numeric vector) - Harmonized differentiation scores. - **exprMatrix** (matrix) - Batch-corrected expression matrix. - **GCS** (numeric vector) - Integrated gene counts signature. - **Counts** (numeric vector) - Corrected gene counts per cell. - **cytoGenes** (vector) - Genes associated with iCytoTRACE. - **coord** (matrix) - Low-dimensional embedding coordinates (100 t-SNE components). - **filteredCells** (vector) - Filtered cells from all datasets. ``` -------------------------------- ### Visualize CytoTRACE Gene Correlations Source: https://context7.com/gunsagargulati/cytotrace/llms.txt Generate bar plots showing genes associated with stemness and differentiation. Requires a previously computed CytoTRACE object. ```r library(CytoTRACE) # Run CytoTRACE first data(marrow_10x_expr) results <- CytoTRACE(marrow_10x_expr) # Basic usage - plot top 10 genes on each end plotCytoGenes(results) # Output: CytoGenes.pdf - bar plot showing top stemness and differentiation genes # Show more genes plotCytoGenes( cyto_obj = results, numOfGenes = 20 # Show top 20 genes on each end ) # Custom colors plotCytoGenes( cyto_obj = results, numOfGenes = 15, colors = c("red", "blue") # First: less differentiated, Second: more differentiated ) # Specify output directory plotCytoGenes( cyto_obj = results, numOfGenes = 10, outputDir = "/path/to/output/" # Must end with "/" ) # Manually inspect gene correlations # Genes positively correlated = associated with less differentiated cells # Genes negatively correlated = associated with more differentiated cells cyto_genes <- results$cytoGenes top_stemness <- head(cyto_genes, 10) # Most correlated with stemness top_differentiated <- tail(cyto_genes, 10) # Most correlated with differentiation ``` -------------------------------- ### Run CytoTRACE Analysis Source: https://context7.com/gunsagargulati/cytotrace/llms.txt Process gene expression matrices to predict differentiation states, including options for batch correction and fast processing for large datasets. ```r library(CytoTRACE) # Load example bone marrow 10x scRNA-seq data (included with package) # mat: gene expression matrix with genes as rows, cells as columns data(marrow_10x_expr) # Basic usage - run CytoTRACE on a single dataset results <- CytoTRACE(marrow_10x_expr) # Access results # CytoTRACE scores: 1.0 = least differentiated (stem-like), 0.0 = most differentiated cytotrace_scores <- results$CytoTRACE head(cytotrace_scores) # Output: Named numeric vector with values between 0 and 1 # Gene counts per cell gene_counts <- results$Counts # Gene counts signature (GCS) - geometric mean of top 200 genes correlated with gene counts gcs_scores <- results$GCS # Genes correlated with CytoTRACE (sorted by correlation) cyto_genes <- results$cytoGenes top_stemness_genes <- head(cyto_genes, 20) # Genes associated with less differentiated cells # Normalized expression matrix after processing expr_matrix <- results$exprMatrix # Check filtered cells (poor quality cells removed) filtered_cells <- results$filteredCells # Run with batch correction (if cells come from different technical batches) batch_labels <- c(rep("batch1", 500), rep("batch2", 500)) # Example batch vector results_batch_corrected <- CytoTRACE(marrow_10x_expr, batch = batch_labels) # Fast mode for large datasets (>3,000 cells) with parallel processing results_fast <- CytoTRACE( marrow_10x_expr, enableFast = TRUE, # Enable subsampling for speed ncores = 8, # Use 8 CPU cores subsamplesize = 1000 # Subsample size per chunk ) ``` -------------------------------- ### CytoTRACE Function Source: https://context7.com/gunsagargulati/cytotrace/llms.txt Predicts differentiation states of single cells from a single scRNA-seq dataset. ```APIDOC ## CytoTRACE(mat, batch = NULL, enableFast = FALSE, ncores = NULL, subsamplesize = 1000) ### Description Processes gene expression matrices, normalizes data, calculates gene counts signatures, and applies diffusion-based smoothing to generate robust differentiation predictions. ### Parameters #### Request Body - **mat** (matrix) - Required - Gene expression matrix with genes as rows and cells as columns. - **batch** (vector) - Optional - Batch labels for batch correction. - **enableFast** (boolean) - Optional - Enable subsampling for large datasets (>3,000 cells). - **ncores** (integer) - Optional - Number of CPU cores for parallel processing. - **subsamplesize** (integer) - Optional - Subsample size per chunk for fast mode. ### Response - **CytoTRACE** (numeric vector) - Differentiation scores (1.0 = stem-like, 0.0 = differentiated). - **Counts** (numeric vector) - Gene counts per cell. - **GCS** (numeric vector) - Gene counts signature. - **cytoGenes** (vector) - Genes correlated with CytoTRACE. - **exprMatrix** (matrix) - Normalized expression matrix. - **filteredCells** (vector) - List of filtered cells. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.