### Install SoupX Development Version from GitHub Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html Installs the latest development version of the SoupX package directly from GitHub using the devtools package. This is useful for accessing experimental features. ```r devtools::install_github("constantAmateur/SoupX", ref = "devel") ``` -------------------------------- ### Install SoupX from CRAN Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html Installs the stable version of the SoupX package from the Comprehensive R Archive Network (CRAN). This is the recommended method for most users. ```r install.packages("SoupX") ``` -------------------------------- ### Load SoupX Package Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html Loads the SoupX package into the current R session, making its functions available for use. This should be run after installation. ```r library(SoupX) ``` -------------------------------- ### Quickstart: Decontaminate 10X Data Source: https://github.com/constantamateur/soupx/blob/master/README.md Demonstrates the basic workflow for decontaminating 10X Genomics data using SoupX. It involves loading the data, automatically estimating contamination, and adjusting the counts. ```R sc = load10X('path/to/your/cellranger/outs/folder') sc = autoEstCont(sc) out = adjustCounts(sc) ``` -------------------------------- ### Manually Install 'multtest' Package Source: https://github.com/constantamateur/soupx/blob/master/README.md Provides instructions to manually install the 'multtest' package from Bioconductor. This is a dependency that might be required by SoupX and could cause installation errors if not present. ```R BiocManager::install('multtest') ``` -------------------------------- ### Install SoupX Development Version Source: https://github.com/constantamateur/soupx/blob/master/README.md Installs the latest development version of SoupX directly from its GitHub repository. This is useful for users who want to access the newest features or bug fixes. ```R devtools::install_github("constantAmateur/SoupX",ref='devel') ``` -------------------------------- ### Install SoupX from CRAN Source: https://github.com/constantamateur/soupx/blob/master/README.md Installs the latest stable release of the SoupX package from the Comprehensive R Archive Network (CRAN). This is the recommended method for most users. ```R install.packages('SoupX') ``` -------------------------------- ### Load Pre-processed PBMC Data Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html Loads a pre-processed SoupChannel object named PBMC_sc, often used for examples or testing, and assigns it to the 'sc' variable. This bypasses the need for downloading and reading raw data files. ```R data(PBMC_sc) sc = PBMC_sc sc ``` -------------------------------- ### Install SoupX STAN Branch Source: https://github.com/constantamateur/soupx/blob/master/README.md Installs a specific 'STAN' branch from the SoupX GitHub repository, likely for per-cell contamination estimation. This is typically for advanced users or specific experimental needs. ```R devtools::install_github("constantAmateur/SoupX",ref='STAN') ``` -------------------------------- ### Quickstart: Decontaminate Custom Data Source: https://github.com/constantamateur/soupx/blob/master/README.md Shows how to decontaminate arbitrary single-cell RNA-seq data using SoupX. This method requires manually providing droplet and count data, along with cluster labels. ```R sc = SoupChannel(table_of_droplets,table_of_counts) sc = setClusters(sc,cluster_labels) sc = autoEstCont(sc) out = adjustCounts(sc) ``` -------------------------------- ### Typical SoupX Workflow for 10X Data Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html Demonstrates a common workflow for processing 10X Genomics data with SoupX. It involves loading the data, automatically estimating contamination, and adjusting the counts. ```r sc = load10X("Path/to/cellranger/outs/folder/") sc = autoEstCont(sc) out = adjustCounts(sc) ``` -------------------------------- ### Load 10x Data with Soupx Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html Loads 10x Genomics data into a SoupChannel object using the convenience function load10X. This function simplifies the process of initializing a Soupx analysis for 10x data. ```R sc = load10X(tmpDir) ``` -------------------------------- ### Load Single-Channel SoupX Data into Seurat Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html This snippet demonstrates loading SoupX-adjusted counts for a single channel directly into a Seurat object. It requires the Seurat package. ```r library(Seurat) srat = CreateSeuratObject(out) ``` -------------------------------- ### Manually Create SoupChannel from 10x Data Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html Manually constructs a SoupChannel object by reading filtered and raw gene-bc matrices using Seurat::Read10X and then initializing SoupChannel. This method is useful for custom data loading. ```R toc = Seurat::Read10X(file.path(tmpDir, "filtered_gene_bc_matrices", "GRCh38")) tod = Seurat::Read10X(file.path(tmpDir, "raw_gene_bc_matrices", "GRCh38")) sc = SoupChannel(tod, toc) ``` -------------------------------- ### Download and Extract 10x Genomics Data Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html Downloads compressed 10x Genomics data files (raw and filtered matrices) and extracts their contents using R's download.file and untar functions. Requires a temporary directory for storage. ```R download.file("https://cf.10xgenomics.com/samples/cell-exp/2.1.0/pbmc4k/pbmc4k_raw_gene_bc_matrices.tar.gz", destfile = file.path(tmpDir, "tod.tar.gz")) download.file("https://cf.10xgenomics.com/samples/cell-exp/2.1.0/pbmc4k/pbmc4k_filtered_gene_bc_matrices.tar.gz", destfile = file.path(tmpDir, "toc.tar.gz")) untar(file.path(tmpDir, "tod.tar.gz"), exdir = tmpDir) untar(file.path(tmpDir, "toc.tar.gz"), exdir = tmpDir) ``` -------------------------------- ### Visualize Gene Expression Ratio with plotMarkerMap Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html This snippet demonstrates how to use the `plotMarkerMap` function from the soupx library to visualize the ratio of observed counts for a specific gene (e.g., 'IGKC') to an expected count based on background 'soup'. It assumes the 'sc' object is already loaded and processed. ```r gg = plotMarkerMap(sc, "IGKC") plot(gg) ``` -------------------------------- ### CSS for Code Styling and Layout Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html This CSS defines styles for various code elements and document layout. It includes rules for pre-formatted text, inline code, source code blocks with line numbering, and specific element styling for better readability and presentation. ```css code{white-space: pre-wrap;} span.smallcaps{font-variant: small-caps;} span.underline{text-decoration: underline;} div.column{display: inline-block; vertical-align: top; width: 50%;} div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} ul.task-list{list-style: none;} code { white-space: pre; } .sourceCode { overflow: visible; } pre > code.sourceCode { white-space: pre; position: relative; } pre > code.sourceCode > span { display: inline-block; line-height: 1.25; } pre > code.sourceCode > span:empty { height: 1.2em; } .sourceCode { overflow: visible; } code.sourceCode > span { color: inherit; text-decoration: inherit; } div.sourceCode { margin: 1em 0; } pre.sourceCode { margin: 0; } @media screen { div.sourceCode { overflow: auto; } } @media print { pre > code.sourceCode { white-space: pre-wrap; } pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; } } pre.numberSource code { counter-reset: source-line 0; } pre.numberSource code > span { position: relative; left: -4em; counter-increment: source-line; } pre.numberSource code > span > a:first-child::before { content: counter(source-line); position: relative; left: -1em; text-align: right; vertical-align: baseline; border: none; display: inline-block; -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; padding: 0 4px; width: 4em; color: #aaaaaa; } pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; } div.sourceCode {} @media screen { pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; } } code span.al { color: #ff0000; font-weight: bold; } /* Alert */ code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */ code span.at { color: #7d9029; } /* Attribute */ code span.bn { color: #40a070; } /* BaseN */ code span.bu { } /* BuiltIn */ code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */ code span.ch { color: #4070a0; } /* Char */ code span.cn { color: #880000; } /* Constant */ code span.co { color: #60a0b0; font-style: italic; } /* Comment */ code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */ code span.do { color: #ba2121; font-style: italic; } /* Documentation */ code span.dt { color: #902000; } /* DataType */ code span.dv { color: #40a070; } /* DecVal */ code span.er { color: #ff0000; font-weight: bold; } /* Error */ code span.ex { } /* Extension */ code span.fl { color: #40a070; } /* Float */ code span.fu { color: #06287e; } /* Function */ code span.im { } /* Import */ code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */ code span.kw { color: #007020; font-weight: bold; } /* Keyword */ code span.op { color: #666666; } /* Operator */ code span.ot { color: #007020; } /* Other */ code span.pp { color: #bc7a00; } /* Preprocessor */ code span.sc { color: #4070a0; } /* SpecialChar */ code span.ss { color: #bb6688; } /* SpecialString */ code span.st { color: #4070a0; } /* String */ code span.va { color: #19177c; } /* Variable */ code span.vs { color: #4070a0; } /* VerbatimString */ code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */ body { background-color: #fff; margin: 1em auto; max-width: 700px; overflow: visible; padding-left: 2em; padding-right: 2em; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 1.35; } #TOC { clear: both; margin: 0 0 10px 10px; padding: 4px; width: 400px; border: 1px solid #CCCCCC; border-radius: 5px; backgroun ``` -------------------------------- ### Setting a uniform prior for autoEstCont in R Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html Demonstrates how to set a uniform prior for the autoEstCont function by adjusting the priorRhoStdDev parameter. This affects the prior distribution used in the Bayesian estimation of rho. ```r sc = autoEstCont(sc, priorRhoStdDev = 0.3) ``` -------------------------------- ### Visualize Data with Annotation using ggplot2 Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html Prepares data for visualization by extracting metadata and calculating mean coordinates for different annotations. Uses ggplot2 for plotting, demonstrating how to visually inspect the data. ```R library(ggplot2) dd = PBMC_metaData[colnames(sc$toc), ] mids = aggregate(cbind(RD1, RD2) ~ Annotation, data = dd, FUN = mean) ``` -------------------------------- ### Using quickMarkers for Gene Discovery Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html The `quickMarkers` function is employed to identify marker genes within distinct cell clusters. This process aids in understanding gene expression patterns and potential background contamination. It requires pre-defined clusters and will fail if none are available. The output is intended for qualitative biological insight, not quantitative gene selection. ```R quickMarkers(sce, method = "classic", q = 0.6, p.value = 0.05, restricted = NULL, subset.clusters = NULL, subset.genes = NULL, direction = "any", assay.type = "logcounts", subset.assay = NULL, num.threads = 1, BPPARAM = NULL, verbose = FALSE) ``` -------------------------------- ### Load Multi-Channel SoupX Data into Seurat Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html This snippet shows how to process and combine count matrices from multiple channels using SoupX and load them into a single Seurat object. It iterates through a list of experiment data, adjusts counts, renames cells with experiment prefixes, and then combines them. ```r library(Seurat) srat = list() for (nom in names(scs)) { # Clean channel named 'nom' tmp = adjustCounts(scs[[nom]]) # Add experiment name to cell barcodes to make them unique colnames(tmp) = paste0(nom, "_", colnames(tmp)) # Store the result srat[[nom]] = tmp } # Combine all count matricies into one matrix srat = do.call(cbind, srat) srat = CreateSeuratObject(srat) ``` -------------------------------- ### Set Custom Soup Profile without Empty Droplets Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html Creates a SoupChannel object and sets a custom soup profile using data.frame calculations when empty droplets are not available. It utilizes the Matrix library for sparse matrix operations. ```R library(Matrix) toc = sc$toc scNoDrops = SoupChannel(toc, toc, calcSoupProfile = FALSE) # Calculate soup profile soupProf = data.frame(row.names = rownames(toc), est = rowSums(toc)/sum(toc), counts = rowSums(toc)) scNoDrops = setSoupProfile(scNoDrops, soupProf) ``` -------------------------------- ### Visualize Expression Distribution with plotChangeMap Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html This function call visualizes the distribution of expression data, specifically showing the fraction of 'soup' removed from each cell. It takes the corrected data (`sc`), output directory (`out`), and the gene of interest (`"IGKC"`) as arguments. ```r plotChangeMap(sc, out, "IGKC") ``` -------------------------------- ### Loading 10X Data Source: https://github.com/constantamateur/soupx/blob/master/README.md Loads data from the 10X Genomics format. Note that `load10X` now requires a version of `Seurat::Read10X` that retains numeric suffixes. ```R load10X(data_dir, gene_file, cell_file) ``` -------------------------------- ### Explicitly Estimate Soup Profile Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html Explicitly calls the estimateSoup function on a SoupChannel object to calculate the ambient RNA profile. This can be done when calcSoupProfile is set to FALSE during initialization. ```R sc = SoupChannel(tod, toc, calcSoupProfile = FALSE) sc = estimateSoup(sc) ``` -------------------------------- ### Apply Pandoc CSS Styles to Pre.sourceCode (JavaScript) Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html This JavaScript code modifies CSS rules to apply the styles defined for 'div.sourceCode' to 'pre.sourceCode'. This is done to ensure consistent styling, especially for color and background properties, across different rendering contexts. ```javascript (function() { var sheets = document.styleSheets; for (var i = 0; i < sheets.length; i++) { if (sheets[i].ownerNode.dataset["origin"] !== "pandoc") continue; try { var rules = sheets[i].cssRules; } catch (e) { continue; } for (var j = 0; j < rules.length; j++) { var rule = rules[j]; // check if there is a div.sourceCode rule if (rule.type !== rule.STYLE_RULE || rule.selectorText !== "div.sourceCode") continue; var style = rule.style.cssText; // check if color or background-color is set if (rule.style.color === '' && rule.style.backgroundColor === '') continue; // replace div.sourceCode by a pre.sourceCode rule sheets[i].deleteRule(j); sheets[i].insertRule('pre.sourceCode{' + style + '}', j); } } })(); ``` -------------------------------- ### Adjusting Counts for Integer Output Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html Shows how to ensure that the output counts from `adjustCounts` are integers, either by rounding the result or by setting the `roundToInt` argument to TRUE during the function call. ```r # Option 1: Rounding the output out = round(adjustCounts(sc)) # Option 2: Setting roundToInt=TRUE out = adjustCounts(sc, roundToInt=TRUE) ``` -------------------------------- ### Setting Clusters with setClusters Source: https://github.com/constantamateur/soupx/blob/master/README.md Ensures clustering information is provided to SoupX for accurate contamination adjustment. This can be done by manually running setClusters or automatically via load10X. ```R setClusters(soupChannel, clusterVector) ``` -------------------------------- ### Add Clustering Metadata to SoupChannel Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html Adds clustering information to the SoupChannel object using the setClusters function. This metadata is crucial for accurate contamination fraction estimation. ```R data(PBMC_metaData) sc = setClusters(sc, setNames(PBMC_metaData$Cluster, rownames(PBMC_metaData))) ``` -------------------------------- ### Visualize cells for contamination estimation Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html Visualizes the cells marked for estimating contamination using the `estimateNonExpressingCells` function. It plots a map indicating which cells should be used for estimation based on a provided gene set and the estimation matrix. ```r plotMarkerMap(sc, geneSet = igGenes, useToEst = useToEst) ``` -------------------------------- ### Manually Setting the Contamination Fraction Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html This section describes how to manually set the contamination fraction for all cells using the `setContaminationFraction` function. This can be useful for ensuring a high level of contamination removal, even if it means discarding some true expression. ```APIDOC ## POST /setContaminationFraction ### Description Manually sets the contamination fraction for the SoupX object. This allows for direct control over the proportion of data considered as contamination. ### Method POST ### Endpoint /setContaminationFraction ### Parameters #### Request Body - **sc** (object) - Required - The SoupX object containing the data. - **contaminationFraction** (numeric) - Required - The contamination fraction to set (e.g., 0.2 for 20%). ### Request Example ```json { "sc": "", "contaminationFraction": 0.2 } ``` ### Response #### Success Response (200) - **sc** (object) - The updated SoupX object with the contamination fraction set. #### Response Example ```json { "sc": "" } ``` ``` -------------------------------- ### Manually Setting Contamination Fraction Source: https://github.com/constantamateur/soupx/blob/master/README.md Allows users to manually adjust the contamination rate if automatic estimation is not yielding satisfactory results. This is useful when SoupX errs on the side of caution and retains too much contamination. ```R setContaminationFraction(soupChannel, fraction) ``` -------------------------------- ### Plotting Marker Distribution Source: https://github.com/constantamateur/soupx/blob/master/README.md A function to visualize marker gene distribution, aiding in the selection of genes for contamination estimation. It helps identify suitable gene sets when standard ones fail. ```R plotMarkerDistribution(soupChannel) ``` -------------------------------- ### Create Annotated Scatter Plot with ggplot2 Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html Generates a scatter plot using ggplot2, mapping variables to axes and color. It includes adding labels for specific data points and customizing the legend. This is useful for visualizing relationships and identifying clusters in data. ```r gg = ggplot(dd, aes(RD1, RD2)) + geom_point(aes(colour = Annotation), size = 0.2) + geom_label(data = mids, aes(label = Annotation)) + ggtitle("PBMC 4k Annotation") + guides(colour = guide_legend(override.aes = list(size = 1))) plot(gg) ``` -------------------------------- ### Estimate Contamination Fraction (soupx) Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html Estimates the contamination fraction using the automated method in soupx. This function takes a soupx object as input and returns a processed object with contamination estimates. It is a key step in data preprocessing for single-cell RNA sequencing analysis. ```r sc = autoEstCont(sc) ``` -------------------------------- ### Automatic Contamination Estimation Source: https://github.com/constantamateur/soupx/blob/master/README.md This function automatically estimates the contamination fraction without requiring the user to specify a gene set. It simplifies the process and addresses a common user need. ```R autoEstCont(soupChannel) ``` -------------------------------- ### Adjusting Counts Source: https://github.com/constantamateur/soupx/blob/master/README.md Adjusts raw counts to account for contamination. The algorithm has been significantly optimized for speed, and the parallel option has been removed. ```R adjustCounts(soupChannel) ``` -------------------------------- ### Visualize marker gene distribution across cells Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html This R code snippet uses the `plotMarkerDistribution` function to visualize the distribution of expression for potential marker genes across all cells in the dataset. If no specific gene lists are provided, the function attempts to identify and plot cluster marker genes. It can help in assessing the specificity of gene expression patterns. ```R plotMarkerDistribution(sc) ``` -------------------------------- ### Visualize Gene Expression on tSNE Map (R) Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html This code snippet visualizes the expression of the gene IGKC on a tSNE map. It assumes that tSNE coordinates (RD1, RD2) and gene counts are available in data frames 'dd' and 'sc' respectively. The output is a ggplot object showing cells colored by IGKC expression. ```r dd$IGKC = sc$toc["IGKC", ] gg = ggplot(dd, aes(RD1, RD2)) + geom_point(aes(colour = IGKC > 0)) plot(gg) ``` -------------------------------- ### Identify Genes with Quantitative Differences in R Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html Calculates the ratio of genes with quantitative differences after correction compared to before correction. It identifies the top 20 genes with the highest ratio, focusing on genes where the corrected value is less than or equal to the original value. ```R tail(sort(rowSums(sc$toc > out)/rowSums(sc$toc > 0)), n = 20) ``` -------------------------------- ### Calculate Contamination Fraction in Soupx Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html Estimates the global contamination fraction using specified gene sets and cells for estimation. It modifies the object's metadata to include the contamination fraction estimate. This function is robust when clustering information is available. ```R sc = calculateContaminationFraction(sc, list(IG = igGenes), useToEst = useToEst) ``` -------------------------------- ### Set Contamination Fraction in SoupX Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html Manually sets the contamination fraction for all cells in the SoupChannel object. This is useful for conservative removal of contamination or when a higher percentage of soup removal is required. ```r sc = setContaminationFraction(sc, 0.2) ``` -------------------------------- ### Saving Corrected Counts for 10X Data with DropletUtils Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html Save the Soupx-corrected expression matrix in the 10X Genomics file format. This allows for seamless integration with downstream analysis tools and pipelines that expect this standard format. The `write10xCounts` function from the DropletUtils package is used for this purpose. ```r DropletUtils:::write10xCounts("./strainedCounts", out) ``` -------------------------------- ### Add Dimensionality Reduction Metadata to SoupChannel Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html Adds dimensionality reduction data (e.g., RD1, RD2) to the SoupChannel object using the setDR function. This facilitates visualization and analysis of the single-cell data. ```R sc = setDR(sc, PBMC_metaData[colnames(sc$toc), c("RD1", "RD2")]) ``` -------------------------------- ### Define immunoglobulin genes list in R Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html This R code defines a vector named 'igGenes' containing a comprehensive list of constant immunoglobulin genes. This list is used to estimate cellular contamination based on their expression levels. ```r igGenes = c("IGHA1", "IGHA2", "IGHG1", "IGHG2", "IGHG3", "IGHG4", "IGHD", "IGHE", "IGHM", "IGLC1", "IGLC2", "IGLC3", "IGLC4", "IGLC5", "IGLC6", "IGLC7", "IGKC") ``` -------------------------------- ### Estimate non-expressing cells with SoupX Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html Estimates cells that should not be used for contamination correction by identifying cells with low expression of specified genes. It takes a single-cell object and a list of genes as input, returning a matrix indicating which cells to use for estimation. ```r useToEst = estimateNonExpressingCells(sc, nonExpressedGeneList = list(IG = igGenes), clusters = FALSE) ``` -------------------------------- ### Plotting Gene Expression Changes with Soupx Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html Visualize the impact of Soupx correction on gene expression by plotting changes across different genes. This function helps identify genes whose expression patterns are most affected by soup contamination removal, particularly those highly expressed in specific contexts. ```r plotChangeMap(sc, out, "LYZ") plotChangeMap(sc, out, "CD74") plotChangeMap(sc, out, "IL32") plotChangeMap(sc, out, "TRAC") plotChangeMap(sc, out, "S100A9") plotChangeMap(sc, out, "NKG7") plotChangeMap(sc, out, "GNLY") plotChangeMap(sc, out, "CD4") plotChangeMap(sc, out, "CD8A") ``` -------------------------------- ### Calculate and Identify Most Zeroed Genes in R Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html Calculates the number of non-zero cells before and after correction, then determines the fraction of cells that went from non-zero to zero. It identifies the top 10 genes with the highest such fraction. ```R cntSoggy = rowSums(sc$toc > 0) cntStrained = rowSums(out > 0) mostZeroed = tail(sort((cntSoggy - cntStrained)/cntSoggy), n = 10) mostZeroed ``` -------------------------------- ### Define Non-Expressed Gene List for Soupx Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html This code defines a list of gene groups to be used for estimating the contamination fraction. Each element in the list represents a biological group of genes that are expected to be non-expressed in certain cell types. This allows Soupx to collectively assess contamination using these defined groups. ```r nonExpressedGeneList = list(HB = c("HBB", "HBA2"), IG = c("IGKC")) ``` -------------------------------- ### Define List of Non-Expressed Genes (R) Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html This R code snippet defines a list named 'nonExpressedGeneList'. This list contains two named elements: 'HB' for Haemoglobin genes and 'IG' for Immunoglobulin genes. These genes are included in analyses due to their biological correlation, even if not highly expressed. ```r nonExpressedGeneList = list(HB = c("HBB", "HBA2"), IG = c("IGKC", "IGHG1", "IGHG3")) ``` -------------------------------- ### Estimating Non-Expressing Cells Source: https://github.com/constantamateur/soupx/blob/master/README.md This function estimates contamination by identifying cells with minimal endogenous expression. Options exist to adjust criteria like `maximumContamination` and `pCut`, or to process cells independently by setting `clusters=FALSE`. ```R estimateNonExpressingCells(soupChannel, maximumContamination = ..., pCut = ..., clusters = FALSE) ``` -------------------------------- ### Adjust Gene Counts for Contamination in Soupx Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html Corrects the original count matrix by removing estimated background expression. This function utilizes clustering information to improve the accuracy of count redistribution, addressing cell-specific contamination rates. The output is a sparse matrix with corrected counts. ```R out = adjustCounts(sc) ``` -------------------------------- ### Estimate Non-Expressing Cells using R Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html Estimates non-expressing cells in single-cell RNA sequencing data using the `estimateNonExpressingCells` function from the SoupX package. This function requires a single-cell object (`sc`) and a list of genes that are not expressed (`nonExpressedGeneList`). It returns an object that can be used for further analysis, such as plotting. ```r useToEst = estimateNonExpressingCells(sc, nonExpressedGeneList = list(IG = igGenes)) ``` -------------------------------- ### Display top 20 most expressed genes in sc data Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html This R code snippet displays the top 20 genes with the highest estimated expression values from the `sc$soupProfile` object, sorted in descending order. It helps in identifying potentially highly expressed genes, though these may not always be population-specific. ```R head(sc$soupProfile[order(sc$soupProfile$est, decreasing = TRUE), ], n = 20) ``` -------------------------------- ### Remove HTML Attributes from Headers (JavaScript) Source: https://github.com/constantamateur/soupx/blob/master/inst/doc/pbmcTutorial.html This JavaScript code iterates through elements with class 'level' and removes all attributes from their first child if it's an H1-H6 tag. This ensures compatibility with older Pandoc versions. ```javascript document.addEventListener('DOMContentLoaded', function(e) { var hs = document.querySelectorAll("div.section\[class*='level'\] > :first-child"); var i, h, a; for (i = 0; i < hs.length; i++) { h = hs[i]; if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 a = h.attributes; while (a.length > 0) h.removeAttribute(a[0].name); } }); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.