### Installing Libra R Package from GitHub Source: https://github.com/neurorestore/libra/blob/main/README.md This R command uses the 'devtools' package to install the Libra R package directly from its GitHub repository. This is the final step to get the Libra package installed and ready for use in the R environment. ```R devtools::install_github("neurorestore/Libra") ``` -------------------------------- ### Installing devtools Package in R Source: https://github.com/neurorestore/libra/blob/main/README.md This R command installs the 'devtools' package from CRAN, which is a prerequisite for installing R packages directly from GitHub. It ensures that the necessary tools for package development and installation are available in the R environment. ```R install.packages("devtools") ``` -------------------------------- ### Installing Bioconductor Packages for Differential Expression in R Source: https://github.com/neurorestore/libra/blob/main/README.md This R code block first checks if 'BiocManager' is installed, installing it if necessary. It then uses 'BiocManager' to install essential Bioconductor packages ('edgeR', 'DESeq2', 'limma') required for performing differential expression testing with Libra. ```R if (!requireNamespace("BiocManager", quietly = TRUE)) install.packages("BiocManager") BiocManager::install(c("edgeR", "DESeq2", "limma")) ``` -------------------------------- ### Installing Seurat Package in R Source: https://github.com/neurorestore/libra/blob/main/README.md This R command installs the 'Seurat' package from CRAN. Seurat is a widely used R toolkit for single-cell genomics and is required by Libra for handling Seurat objects as input for single-cell methods. ```R install.packages("Seurat") ``` -------------------------------- ### Running Libra's `run_de` with Custom Column Names (R) Source: https://github.com/neurorestore/libra/blob/main/README.md This R example shows how to use `run_de` when your metadata columns for cell types and experimental conditions have non-default names. The `cell_type_col` and `label_col` arguments allow specifying custom column names like 'cell.type' and 'condition' respectively. ```R DE = run_de(expr, meta = meta, cell_type_col = "cell.type", label_col = "condition") ``` -------------------------------- ### Loading Toy Dataset for Libra Demonstration (R) Source: https://github.com/neurorestore/libra/blob/main/README.md This snippet loads the `hagai_toy` single-cell RNA-seq dataset, which is bundled with the Libra package. This dataset serves as a demonstration input for Libra's functionalities, consisting of 600 cells distributed across six replicates and two conditions. ```R data("hagai_toy") ``` -------------------------------- ### Running Libra's `run_de` with Default Parameters (R) Source: https://github.com/neurorestore/libra/blob/main/README.md This R code demonstrates how to execute the `run_de` function in Libra using default column names for cell types, replicates, and labels. It takes a preprocessed expression matrix (`expr`) and a metadata data frame (`meta`) as input, returning the differential expression results. ```R library(Libra) DE = run_de(expr, meta = meta) ``` -------------------------------- ### Running Pseudobulk Differential Expression with DESeq2 (R) Source: https://github.com/neurorestore/libra/blob/main/README.md This code performs differential expression analysis using a pseudobulk approach with the `DESeq2` method and a Likelihood Ratio Test (`LRT`). It demonstrates how to specify a different statistical framework and method within Libra's `run_de` function. ```R DE = run_de(hagai_toy, de_family = 'pseudobulk', de_method = 'DESeq2', de_type = 'LRT') ``` -------------------------------- ### Generating Pseudobulk Matrices with `to_pseudobulk` (R) Source: https://github.com/neurorestore/libra/blob/main/README.md This R snippet illustrates how to explicitly generate pseudobulk matrices from single-cell data using Libra's `to_pseudobulk` function. This can be useful if you need to inspect or manipulate the pseudobulk data before proceeding with differential expression analysis. ```R matrices = to_pseudobulk(expr, meta = meta) ``` -------------------------------- ### Running Mixed-Model Differential Expression with Libra (R) Source: https://github.com/neurorestore/libra/blob/main/README.md This snippet initiates differential expression analysis using a mixed-model approach, which by default employs a negative binomial model structure. This method is suitable for accounting for both fixed and random effects in single-cell data. ```R DE = run_de(hagai_toy, de_family = 'mixedmodel') ``` -------------------------------- ### Running Libra's `run_de` on Seurat/Signac Object (R) Source: https://github.com/neurorestore/libra/blob/main/README.md This R code demonstrates the simplified usage of `run_de` when working directly with a Seurat or Signac object. Libra can automatically extract the necessary expression data and metadata from the object, provided `sc@meta.data` contains the required 'cell_type' and 'label' columns. ```R DE = run_de(sc) ``` -------------------------------- ### Running Parallelized Mixed-Model DE with 8 Threads (R) Source: https://github.com/neurorestore/libra/blob/main/README.md This snippet demonstrates how to run Libra's mixed-model differential expression analysis using eight parallel threads. The `n_threads` argument allows users to optimize runtime by leveraging multiple CPU cores, which is particularly beneficial for larger datasets. ```R DE = run_de(hagai_toy, de_family = 'mixedmodel', de_method = 'linear', de_type = 'LRT', n_threads = 8) ``` -------------------------------- ### Running Default Differential Expression with Libra (R) Source: https://github.com/neurorestore/libra/blob/main/README.md This snippet executes the `run_de` function on the `hagai_toy` dataset using Libra's default statistical framework. The function performs differential expression analysis, with the results stored in the `DE` object for subsequent inspection. ```R DE = run_de(hagai_toy) ``` -------------------------------- ### Running Linear Mixed-Model Differential Expression with LRT (R) Source: https://github.com/neurorestore/libra/blob/main/README.md This code performs differential expression analysis using a linear mixed-model with a Likelihood Ratio Test (`LRT`). It illustrates how to adjust the `de_method` argument for mixed models, allowing for different underlying model structures. ```R DE = run_de(hagai_toy, de_family = 'mixedmodel', de_method = 'linear', de_type = 'LRT') ``` -------------------------------- ### Inspecting Seurat Object Metadata in Libra (R) Source: https://github.com/neurorestore/libra/blob/main/README.md This code inspects the `meta.data` slot of the `hagai_toy` Seurat object. It displays the initial rows of the metadata, confirming the presence and structure of essential columns like `cell_type` and `label`, which are directly used as input by Libra. ```R head(hagai_toy@meta.data) ``` -------------------------------- ### Calculating Delta Variance in Single-Cell Data (R) Source: https://github.com/neurorestore/libra/blob/main/README.md This code calculates the 'delta variance' for genes in the `hagai_toy` dataset. Delta variance quantifies the difference in gene expression variance between pseudobulks and pseudo-replicates, aiding in the identification of potential false positives in differential expression results from methods that do not account for biological replicates. ```R DV = calculate_delta_variance(hagai_toy) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.