### CIBERSORT Setup and Execution Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/README.md Provides instructions for the one-time setup required to use the CIBERSORT method, including registering the CIBERSORT binary and signature matrix. After setup, CIBERSORT can be used with the standard 'deconvolute' function. ```r # One-time configuration set_cibersort_binary("~/CIBERSORT.R") set_cibersort_mat("~/LM22.txt") # Now available for current session result <- deconvolute(expr_matrix, method = "cibersort") ``` -------------------------------- ### Create a CIBERSORT setup script Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/configuration.md To maintain CIBERSORT configuration across sessions, create a setup script that registers the binary and signature matrix paths. This script can then be sourced at the beginning of an R session. ```r library(immunedeconv) set_cibersort_binary("~/cibersort_tools/CIBERSORT.R") set_cibersort_mat("~/cibersort_tools/LM22.txt") message("CIBERSORT configured successfully") ``` -------------------------------- ### Source CIBERSORT setup script Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/configuration.md After creating the setup script, source it to apply the CIBERSORT configuration for the current session. This allows subsequent calls to deconvolute using CIBERSORT methods without re-registering paths. ```r source("~/setup_cibersort.R") # Now CIBERSORT methods are available result <- deconvolute(expr_matrix, method = "cibersort") ``` -------------------------------- ### Install ImmuneDeconv using remotes package Source: https://github.com/omnideconv/immunedeconv/blob/master/README.md Installs the immunedeconv R package from GitHub using the remotes package. This method also handles the installation of CRAN, Bioconductor, and GitHub dependencies. Ensure you have the 'remotes' package installed first. ```r install.packages("remotes") remotes::install_github("omnideconv/immunedeconv") ``` -------------------------------- ### Example Available Datasets Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/types.md Shows a sample of the character vector containing all method and dataset names for which cell type mappings are available. ```R c("xcell", "epic", "quantiseq", "cibersort", "timer", "mcp_counter", ...) ``` -------------------------------- ### Install ImmuneDeconv via Bioconda Source: https://github.com/omnideconv/immunedeconv/blob/master/README.md Installs the r-immunedeconv package and its dependencies using conda from the bioconda and conda-forge channels. This method is recommended for easier dependency management on Linux and MacOS. ```bash conda install -c bioconda -c conda-forge r-immunedeconv ``` -------------------------------- ### Handle Unknown Deconvolution Method Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/errors.md This example demonstrates calling deconvolute with an unknown method and how to correct it by specifying a valid method name. ```r # Error: "unknown_method" is not recognized result <- deconvolute(expr_matrix, method = "unknown_method") # Fix: use valid method result <- deconvolute(expr_matrix, method = "quantiseq") ``` -------------------------------- ### Basic Deconvolution with Quantiseq Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/README.md Demonstrates the basic deconvolution process using the 'quantiseq' method with example expression data. Ensure the 'immunedeconv' library is loaded. ```r library(immunedeconv) # Load example data data(dataset_racle) expr_matrix <- dataset_racle$expr_mat # Run deconvolution result <- deconvolute(expr_matrix, method = "quantiseq") head(result) ``` -------------------------------- ### Deconvolute Mouse RNA-seq Data Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/api-reference/deconvolute-mouse.md Load example mouse RNA-seq data and run mMCP-counter. This is a basic example demonstrating the core functionality. ```r library(immunedeconv) # Load example mouse RNA-seq data data(dataset_petitprez) expr_matrix <- dataset_petitprez$expr_mat # Run mMCP-counter result <- deconvolute_mouse(expr_matrix, method = "mmcp_counter") head(result) ``` -------------------------------- ### Configure xCell Cores using Environment Variable Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/api-reference/configuration.md This example demonstrates how to set the MAX_CORES environment variable before loading the library to control the number of cores used by xCell. The package will use the minimum of the specified MAX_CORES and 2. ```r # Set environment variable before loading package Sys.setenv("MAX_CORES" = "4") library(immunedeconv) # xCell will use at most 2 cores (min(4, 2) = 2) result <- deconvolute(expr_matrix, method = "xcell") ``` -------------------------------- ### Run seqImmuCC with LLSR Algorithm Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/api-reference/deconvolute-mouse.md Perform deconvolution using the seqImmuCC method with the LLSR algorithm. This example highlights the selection of a specific algorithm for seqImmuCC. ```r result_seqimmucc <- deconvolute_mouse( expr_matrix, method = "seqimmucc", algorithm = "LLSR" ) ``` -------------------------------- ### Example Cell Type Hierarchy Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/types.md Demonstrates the hierarchical structure of cell types using a tree representation, encoding biological relationships. ```R root ├── Immune cell │ ├── T cell │ │ ├── T cell CD4+ │ │ ├── T cell CD8+ │ │ └── T cell regulatory (Treg) │ ├── B cell │ ├── Macrophage │ ├── Dendritic cell │ └── ... └── Stromal cell ├── Fibroblast └── ... ``` -------------------------------- ### Example Cell Type Mapping Data Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/types.md Illustrates the structure of the cell_type_map data frame, showing mappings from method-specific cell types to a controlled vocabulary. ```R method_dataset method_cell_type cell_type xcell T cells T cell epic B cells B cell quantiseq Macrophages Macrophage ``` -------------------------------- ### Data Objects Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/INDEX.txt Documentation for key data objects used within the package, including method lists, cell type references, and example datasets. ```APIDOC ## Data Objects ### Description Reference for data structures and objects available in the immunedeconv package. ### Key Objects - `deconvolution_methods` and `deconvolution_methods_mouse`: Lists of available deconvolution algorithms. - `cell_type_map`, `cell_type_tree`: Structures for cell type standardization. - `available_datasets`: Reference datasets for cell type analysis. - `dataset_racle`, `dataset_petitprez`: Example datasets. - `config_env`: Configuration environment object. ``` -------------------------------- ### Run deconvolution with xcell Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/api-reference/deconvolute.md Loads example gene expression data and runs deconvolution using the 'xcell' method. Ensure the 'immunedeconv' library is loaded. ```r library(immunedeconv) # Load example gene expression data data(dataset_racle) expr_matrix <- dataset_racle$expr_mat # Run deconvolution with xcell result <- deconvolute(expr_matrix, method = "xcell", arrays = FALSE) head(result) ``` -------------------------------- ### Run ESTIMATE Algorithm with deconvolute_estimate Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/api-reference/deconvolute-estimate.md This snippet demonstrates how to load example gene expression data and use the `deconvolute_estimate` function to compute ESTIMATE scores. It also shows how to print the full results and extract specific scores like tumor purity and immune score. ```r library(immunedeconv) # Load example gene expression data data(dataset_racle) expr_matrix <- dataset_racle$expr_mat # Run ESTIMATE algorithm estimate_scores <- deconvolute_estimate(expr_matrix) # View results print(estimate_scores) # Extract tumor purity tumor_purity <- estimate_scores["TumorPurity", ] print(tumor_purity) # Extract immune score immune_score <- estimate_scores["ImmuneScore", ] print(immune_score) ``` -------------------------------- ### Create and Activate Conda Environment Source: https://github.com/omnideconv/immunedeconv/blob/master/README.md Creates a new conda environment named 'deconvolution' and activates it for installing the immunedeconv package. This is an optional step to isolate dependencies. ```bash conda create -n deconvolution conda activate deconvolution ``` -------------------------------- ### Run EPIC with Custom Signature and Gene Variance Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/api-reference/custom-deconvolution.md Example of running the deconvolute_epic_custom function with a custom signature matrix and an optional gene variance matrix. Ensure necessary libraries are loaded. ```r library(immunedeconv) # Create custom signature matrix with full gene set custom_sig_full <- matrix(rnorm(5000), nrow = 500, ncol = 10) rownames(custom_sig_full) <- paste0("GENE", 1:500) colnames(custom_sig_full) <- paste0("CellType", 1:10) # Specify signature genes (subset) sig_genes <- paste0("GENE", 1:50) # Optional: gene variance matrix genes_var_mat <- matrix(abs(rnorm(500)), nrow = 500, ncol = 10) rownames(genes_var_mat) <- rownames(custom_sig_full) colnames(genes_var_mat) <- colnames(custom_sig_full) # Run EPIC with custom signature result <- deconvolute_epic_custom( expr_matrix, signature_matrix = custom_sig_full, signature_genes = sig_genes, genes_var = genes_var_mat ) ``` -------------------------------- ### Aggregate Mouse Cell Types using reduce_mouse_cell_types Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/api-reference/mouse-utilities.md Demonstrates how to use the `reduce_mouse_cell_types` function to aggregate detailed cell type estimates from deconvolution results into major cell type categories. This is useful when you have existing deconvolution results and need to group them. The example shows aggregation using the 'sum' method, suitable for regression-based methods like DCQ. ```r library(immunedeconv) data(dataset_petitprez) expr_matrix <- dataset_petitprez$expr_mat # Run DCQ dcq_results <- deconvolute_dcq( expr_matrix, n_repeats = 10, combine_cells = FALSE # Get all detailed cell types first ) # Aggregate to major cell types # (actually, deconvolute_dcq with combine_cells=TRUE does this automatically) # This function is useful if you have existing results major_cell_types <- reduce_mouse_cell_types( dcq_results, method = "sum" ) ``` -------------------------------- ### Set MAX_CORES Environment Variable (Bash) Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/configuration.md Set the MAX_CORES environment variable before starting an R session to control xCell parallelization. The actual cores used will be the minimum of MAX_CORES and 2. ```bash # Set before starting R session export MAX_CORES=4 R ``` -------------------------------- ### Mouse Data Deconvolution and Conversion Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/README.md Shows how to perform deconvolution directly on mouse expression data using 'deconvolute_mouse' or by converting mouse genes to human genes for use with human-specific methods. Requires loading example mouse data. ```r data(dataset_petitprez) mouse_expr <- petitprez$expr_mat # Mouse-specific deconvolution result <- deconvolute_mouse(mouse_expr, method = "mmcp_counter") # Or convert to human and use human methods human_expr <- convert_human_mouse_genes(mouse_expr, convert_to = "human") result <- deconvolute(human_expr, method = "quantiseq") ``` -------------------------------- ### Get All Descendant Cell Types Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/api-reference/cell-type-mapping.md Retrieve all descendant cell types for a given cell type in the hierarchy. Optionally filter by a specific deconvolution method to get method-specific subtypes. ```r library(immunedeconv) # Get all T cell subtypes in the vocabulary all_t_cells <- get_all_children("T cell") # Get all xcell cell types under T cell xcell_t_cells <- get_all_children("T cell", method = "xcell") ``` -------------------------------- ### Run BASE Algorithm with Custom Parameters Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/api-reference/deconvolute-mouse.md Apply the BASE deconvolution algorithm with specified number of permutations and log10 transformation. This demonstrates parameter tuning for the BASE method. ```r result_base <- deconvolute_mouse( expr_matrix, method = "base", n_permutations = 100, log10 = TRUE ) ``` -------------------------------- ### get_all_children() Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/api-reference/cell-type-mapping.md Get all descendant cell types of a given cell type in the hierarchy, optionally filtered by method. ```APIDOC ## get_all_children() ### Description Get all descendant cell types of a given cell type in the hierarchy, optionally filtered by method. ### Signature ```r get_all_children( cell_type, method = NULL ) ``` ### Parameters | Parameter | Type | Required | Default | Description | |-----------|------|----------|---------|-------------| | cell_type | character | Yes | — | Cell type name from the controlled vocabulary. Must exist in `cell_type_tree`. | | method | character | No | NULL | Method or dataset identifier. If provided, returns only method-specific cell type names mapped to the hierarchy. If NULL, returns all descendant nodes. | ### Return Value A character vector of cell type names. If method is NULL, includes all descendants. If method is specified, returns the method's cell type names up to the highest mapped level. ### Example ```r library(immunedeconv) # Get all T cell subtypes in the vocabulary all_t_cells <- get_all_children("T cell") # Get all xcell cell types under T cell xcell_t_cells <- get_all_children("T cell", method = "xcell") ``` ``` -------------------------------- ### Configuration Functions Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/INDEX.txt Functions for setting up and managing the package's configuration environment. ```APIDOC ## Configuration Functions ### Description Manages the package's runtime environment and settings. ### Features - Setting up configuration parameters. - Accessing configuration objects. ``` -------------------------------- ### Method Wrappers Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/INDEX.txt Wrappers for various deconvolution methods available in the package, allowing users to easily apply different algorithms. ```APIDOC ## Method Wrappers ### Description These functions provide a consistent interface to apply a wide range of deconvolution algorithms. ### Methods Includes wrappers for methods such as: xCell, TIMER, EPIC, Quantiseq, CIBERSORT, and more. ``` -------------------------------- ### Validate TIMER Cancer Type Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/errors.md This example shows how to call deconvolute with an invalid cancer type for TIMER, and how to fix it by using a valid cancer code. ```r # Error: "invalid_cancer" is not in timer_available_cancers deconvolute(expr_matrix, method = "timer", indications = c("invalid_cancer")) # Fix: use valid code deconvolute(expr_matrix, method = "timer", indications = c("brca")) ``` -------------------------------- ### Register CIBERSORT binary and signature matrix Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/configuration.md Configure the paths to the CIBERSORT R script and the LM22 signature matrix. This is necessary before using CIBERSORT methods. ```r library(immunedeconv) # Step 1: Register CIBERSORT binary set_cibersort_binary("~/cibersort_tools/CIBERSORT.R") # Step 2: Register signature matrix set_cibersort_mat("~/cibersort_tools/LM22.txt") ``` -------------------------------- ### Custom Signature Deconvolution with EPIC Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/README.md Illustrates how to use the EPIC deconvolution method with a custom signature matrix. Requires an expression matrix, a custom signature matrix, and a vector of signature genes. ```r # With EPIC and custom signature matrix custom_sig <- matrix(rnorm(1000), nrow = 100, ncol = 10) rownames(custom_sig) <- paste0("GENE", 1:100) colnames(custom_sig) <- paste0("CellType", 1:10) result <- deconvolute_epic_custom( expr_matrix, signature_matrix = custom_sig, signature_genes = paste0("GENE", 1:50) ) ``` -------------------------------- ### Reinstall immunedeconv Package Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/errors.md Provides commands to reinstall the immunedeconv package to resolve issues with missing internal data files. Supports both CRAN and GitHub installations, including Conda. ```r remove.packages("immunedeconv") # For conda: conda install -c bioconda r-immunedeconv # For GitHub: remotes::install_github("omnideconv/immunedeconv") ``` -------------------------------- ### Method Wrapper Functions Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/INDEX.txt Provides individual wrapper functions for each supported deconvolution method, allowing for fine-grained control and method-specific parameter tuning. ```APIDOC ## Method Wrapper Functions (e.g., xcell, mcp_counter, epic, etc.) ### Description These functions provide direct access to individual deconvolution algorithms. Each wrapper is tailored to a specific method (e.g., xcell, mcp_counter, epic, quantiseq, cibersort, timer, abis, consensus_tme for human; mmcp_counter, seqimmucc, dcq, base for mouse), offering detailed control over method-specific parameters and requirements. ### Method Not applicable (function signatures) ### Endpoint Not applicable (function signatures) ### Parameters Parameters vary per method wrapper. Refer to specific method documentation for details. Common parameters may include: - **expr_matrix** (matrix) - Input gene expression matrix. - **arrays** (boolean) - Whether to use array-based input (for some methods). - **tumor_mode** (boolean) - Whether to apply tumor-specific adjustments. - **normalization** (string) - Normalization method to apply. ### Request Example ```R # Example for xcell wrapper xcell(expr_matrix, arrays = TRUE, ...) # Example for mcp_counter wrapper mcp_counter(expr_matrix, ...) ``` ### Response #### Success Response (200) - **deconvolution_results** (list or data.frame) - Method-specific output containing cell type proportions or scores. ``` -------------------------------- ### Deconvolute SeqImmuCC (Mouse) Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/api-reference/method-wrappers.md Wrapper for seqImmuCC immune cell quantification. Supports 'LLSR' (standalone) and 'SVR' (CIBERSORT-based) algorithms. For 'SVR', CIBERSORT binary and LM22 signature matrix must be set. ```r library(immunedeconv) data(dataset_petitprez) # Using LLSR (no CIBERSORT needed) result <- deconvolute_seqimmucc( dataset_petitprez$expr_mat, algorithm = "LLSR" ) # Using SVR (requires CIBERSORT setup) set_cibersort_binary("~/CIBERSORT.R") set_cibersort_mat("~/LM22.txt") result <- deconvolute_seqimmucc( dataset_petitprez$expr_mat, algorithm = "SVR" ) ``` -------------------------------- ### Configuration Functions Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/INDEX.txt Functions for configuring the immunedeconv package, specifically for setting paths to external tools like CIBERSORT. ```APIDOC ## Configuration Functions (set_cibersort_binary, set_cibersort_mat) ### Description These functions allow users to configure the immunedeconv package by specifying the locations of external dependencies, such as the CIBERSORT executable binary and its required signature matrix (.mat file). ### Method Not applicable (function signatures) ### Endpoint Not applicable (function signatures) ### Parameters - **binary_path** (string) - The file path to the CIBERSORT executable. - **mat_path** (string) - The file path to the CIBERSORT signature matrix (.mat file). ### Request Example ```R # Set the path to the CIBERSORT binary set_cibersort_binary('/path/to/cibersort/cibersort.R') # Set the path to the CIBERSORT signature matrix set_cibersort_mat('/path/to/cibersort/LM22.mat') ``` ### Response #### Success Response (200) - **Status** (string) - Confirmation message indicating successful configuration. ``` -------------------------------- ### Single-Cell Simulation Utilities Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/INDEX.txt Functions for simulating bulk expression data from single-cell data, including normalization and sample generation. ```APIDOC ## Single-Cell Simulation Functions (scale_to_million, make_random_bulk, make_bulk_eset) ### Description This module provides tools for simulating bulk RNA-seq data from single-cell expression profiles. Functions include `scale_to_million` for TPM normalization, `make_random_bulk` for simulating a single bulk sample, and `make_bulk_eset` for simulating multiple samples, often utilizing the ExpressionSet object. ### Method Not applicable (function signatures) ### Endpoint Not applicable (function signatures) ### Parameters - **sc_data** (object) - Single-cell expression data (e.g., ExpressionSet). - **num_cells** (integer) - Number of cells to simulate. - **num_samples** (integer) - Number of bulk samples to simulate. ### Request Example ```R # Normalize single-cell data to TPM tpm_data <- scale_to_million(raw_counts) # Simulate a single bulk sample random_bulk <- make_random_bulk(tpm_data, num_cells = 1000) # Simulate multiple bulk samples bulk_eset <- make_bulk_eset(tpm_data, num_samples = 5) ``` ### Response #### Success Response (200) - **normalized_data** (matrix) - Normalized expression data. - **simulated_bulk_sample** (vector or matrix) - Simulated bulk expression profile. - **simulated_bulk_eset** (ExpressionSet) - An ExpressionSet object containing simulated bulk samples. ``` -------------------------------- ### Custom Methods Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/INDEX.txt Allows users to implement and utilize their own custom deconvolution signatures and methods. ```APIDOC ## Custom Deconvolution ### Description Enables the use of user-defined deconvolution signatures and custom algorithms. ``` -------------------------------- ### Deconvolute with TIMER Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/api-reference/method-wrappers.md Wrapper for TIMER cancer-immune cell composition analysis. Requires specifying cancer type codes for each sample using the `indications` parameter. ```r library(immunedeconv) data(dataset_racle) # Specify cancer types for each sample result <- deconvolute_timer( dataset_racle$expr_mat, indications = c("brca", "brca", "brca", "brca") ) ``` -------------------------------- ### Generate Simulated Bulk RNA-seq Sample Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/api-reference/single-cell-simulation.md Generates a simulated bulk RNA-seq sample by randomly sampling single cells from an expression set. This is useful for testing deconvolution methods or simulating bulk data with known cell type compositions. Ensure the `cell_fractions` names match the `cell_type` in the `eset`'s `pData`. ```r library(immunedeconv) library(Biobase) # Create toy single-cell expression set expr <- matrix(c( rep(c(1, 0, 0), 300), rep(c(0, 1, 0), 300), rep(c(0, 0, 1), 300) ), nrow = 3) gene_names <- c("CD8A", "CD4", "CD19") rownames(expr) <- gene_names cell_types <- c(rep("T cell CD8+", 300), rep("T cell CD4+", 300), rep("B cell", 300)) pdata <- data.frame(cell_type = cell_types) fdata <- data.frame(gene_symbol = gene_names) rownames(fdata) <- gene_names eset <- ExpressionSet(expr, phenoData = as(pdata, "AnnotatedDataFrame"), featureData = as(fdata, "AnnotatedDataFrame") ) # Create simulated bulk with specific cell fractions simulated_bulk <- make_random_bulk( eset, c("T cell CD8+" = 0.3, "B cell" = 0.4, "T cell CD4+" = 0.3), n_cells = 1000 ) print(simulated_bulk) ``` -------------------------------- ### Data Conversion Utilities Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/INDEX.txt Utility functions for converting between different data formats, such as ExpressionSet and matrices. ```APIDOC ## Data Conversion Utilities (eset_to_matrix) ### Description This utility function facilitates the conversion of an `ExpressionSet` object, commonly used in Bioconductor, into a standard matrix format, which can be more convenient for certain downstream analyses or compatibility with other tools. ### Method Not applicable (function signature) ### Endpoint Not applicable (function signature) ### Parameters - **eset_object** (ExpressionSet) - The input ExpressionSet object. ### Request Example ```R # Convert an ExpressionSet to a matrix expression_matrix <- eset_to_matrix(my_eset_object) ``` ### Response #### Success Response (200) - **expression_matrix** (matrix) - The gene expression data converted into a matrix format. ``` -------------------------------- ### Simulation Functions Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/INDEX.txt Tools for simulating bulk RNA-seq data from single-cell data, useful for testing and validation. ```APIDOC ## Simulation Functions ### Description Allows users to simulate bulk RNA-seq expression profiles from single-cell data. ### Use Cases - Testing deconvolution methods. - Validating analysis pipelines. ``` -------------------------------- ### make_bulk_eset Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/api-reference/single-cell-simulation.md Generates multiple simulated bulk RNA-seq samples from a single-cell dataset. It allows for specifying cell fractions, the number of cells to sample, and the aggregation function. ```APIDOC ## make_bulk_eset() ### Description Generate multiple simulated bulk RNA-seq samples from a single-cell dataset. ### Signature ```r make_bulk_eset( eset, cell_fractions, n_cells = 500, combine = mean ) ``` ### Parameters #### Parameters - **eset** (Biobase::ExpressionSet) - Yes - Description: Single-cell expression set. Each column is one cell. Must have `cell_type` column in pData. - **cell_fractions** (data.frame or tibble) - Yes - Description: One row per desired simulated sample. Columns are cell types with values = desired fractions (0–1 range). Column names must match values in pData(eset)$cell_type. - **n_cells** (integer) - No - Default: 500 - Description: Number of single cells to sample for each bulk sample. - **combine** (function) - No - Default: mean - Description: Aggregation function (e.g., `mean`, `median`, `sum`). ### Return Value An ExpressionSet with multiple samples (columns). Expression matrix has genes as rows and samples as columns. All expression values are rescaled to TPM. pData contains the input cell_fractions (one row per sample). fData is copied from the input eset. ### Example ```r library(immunedeconv) library(Biobase) library(tibble) # Create multiple simulated samples with different cell compositions desired_cell_fractions <- tibble( "T cell CD8+" = c(0.1, 0.2, 0.3), "T cell CD4+" = c(0.9, 0.7, 0.5), "B cell" = c(0, 0.1, 0.2) ) simulated_eset <- make_bulk_eset( eset, desired_cell_fractions, n_cells = 500 ) # Extract expression matrix expr_matrix <- exprs(simulated_eset) print(dim(expr_matrix)) # 3 genes x 3 samples # Get sample composition print(pData(simulated_eset)) ``` ``` -------------------------------- ### Load Petitprez Dataset Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/types.md Loads the dataset_petitprez object, which contains RNA-seq expression data and FACS-measured immune cell fractions from mouse blood and spleen samples. Use this to access the expression matrix and reference fractions. ```r data(dataset_petitprez) expr_matrix <- dataset_petitprez$expr_mat ref_fractions <- dataset_petitprez$ref ``` -------------------------------- ### Deconvolute with quanTIseq Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/api-reference/method-wrappers.md Use this wrapper for quanTIseq immune quantification, with options for tumor optimization. Ensure the gene expression matrix uses HGNC symbols as rownames. ```r library(immunedeconv) data(dataset_racle) result <- deconvolute_quantiseq( dataset_racle$expr_mat, tumor = TRUE, arrays = FALSE, scale_mrna = TRUE ) ``` -------------------------------- ### Run TIMER with cancer type specification Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/api-reference/deconvolute.md Executes the 'timer' deconvolution method, requiring the 'indications' parameter to specify the cancer type for each sample. This is necessary for TIMER analysis. ```r indications <- c("brca", "brca", "brca", "brca") result_timer <- deconvolute(expr_matrix, method = "timer", indications = indications) ``` -------------------------------- ### Register CIBERSORT Signature Matrix Path Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/api-reference/configuration.md Use this function to specify the location of the CIBERSORT signature matrix (LM22.txt). This is required for CIBERSORT deconvolution. ```r library(immunedeconv) # Register CIBERSORT signature matrix set_cibersort_mat("/path/to/LM22.txt") # Now CIBERSORT methods can be used result <- deconvolute(expr_matrix, method = "cibersort") ``` -------------------------------- ### Register CIBERSORT Binary Path Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/api-reference/configuration.md Use this function to specify the location of the CIBERSORT.R script. This is required before using CIBERSORT deconvolution methods. ```r library(immunedeconv) # Register CIBERSORT binary set_cibersort_binary("/path/to/CIBERSORT.R") # Now CIBERSORT methods can be used result <- deconvolute(expr_matrix, method = "cibersort") ``` -------------------------------- ### Type Definitions Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/INDEX.txt Overview of the type definitions used in the package, including vectors, data frames, matrices, and tree structures. ```APIDOC ## Type Definitions ### Description Details the various data types and structures utilized by the immunedeconv package. ### Types - Named vectors - Data frames - Matrices - Tree structures - Environment objects ``` -------------------------------- ### Generate Bulk Expression Sets with make_bulk_eset Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/api-reference/single-cell-simulation.md Use `make_bulk_eset` to create multiple simulated bulk RNA-seq samples from a single-cell ExpressionSet. Specify desired cell type fractions for each sample and the number of cells to sample. The function aggregates expression values using a specified function (default is mean) and rescales all expression values to TPM. ```r library(immunedeconv) library(Biobase) library(tibble) # Create multiple simulated samples with different cell compositions desired_cell_fractions <- tibble( "T cell CD8+" = c(0.1, 0.2, 0.3), "T cell CD4+" = c(0.9, 0.7, 0.5), "B cell" = c(0, 0.1, 0.2) ) simulated_eset <- make_bulk_eset( eset, desired_cell_fractions, n_cells = 500 ) # Extract expression matrix expr_matrix <- exprs(simulated_eset) print(dim(expr_matrix)) # 3 genes x 3 samples # Get sample composition print(pData(simulated_eset)) ``` -------------------------------- ### Set MAX_CORES Environment Variable (R) Source: https://github.com/omnideconv/immunedeconv/blob/master/_autodocs/configuration.md Alternatively, set the MAX_CORES environment variable within an R session before loading the immunedeconv package. This also controls xCell parallelization. ```r # In R, after package loads: library(immunedeconv) # MAX_CORES=4, so xcell_cores will be 2 (min(4, 2)) # Or set in R before loading package: Sys.setenv("MAX_CORES" = "8") library(immunedeconv) ```