all_times <- list() # store the time for each chunk knitr::knit_hooks$set(time_it = local({ now <- NULL function(before, options) { if (before) { now <<- Sys.time() } else { res <- difftime(Sys.time(), now, units = "secs") all_times[[options$label]] <<- res } } })) knitr::opts_chunk$set( tidy = TRUE, tidy.opts = list(width.cutoff = 95), message = FALSE, warning = FALSE, time_it = TRUE ) suppressMessages(library(scRepertoire)) data("contig_list") combined.TCR <- combineTCR(contig_list, samples = c("P17B", "P17L", "P18B", "P18L", "P19B","P19L", "P20B", "P20L"))
Depending on the pipeline used to generate the single-cell object, there may be inherent mismatches in the barcodes in the single-cell object and the output of combineBCR()
or combineTCR()
. In particular, by default, Seurat will amend the suffix of the barcodes with _X, so the barcodes change like:
original: ACGTACGTACGTACGT-1 seurat-modified: ACGTACGTACGTACGT-1_1
scRepertoire uses the samples in combineTCR()
or combineBCR()
to add a prefix to the barcodes (using the samples and/or ID parameters):
original: ACGTACGTACGTACGT-1 scRepertoire-modified: Sample1_ACGTACGTACGTACGT-1
The easiest way to make these compatible is to rename the cell barcodes in the Seurat object by using the RenameCells()
from the SeuratObject package.
cell.barcodes <- rownames(seuratObj[[]]) #removing the _1 at the end of the barcodes) cell.barcodes <- stringr::str_split(cell.barcodes, "_", simplify = TRUE)[,1] #adding the prefix of the orig.ident to the barcodes, assuming that is the sample ids cell.barcodes <- paste0(seuratObj$orig.ident, "_", cell.barcodes) seuratObj <- RenameCells(seuratObj, new.names = cell.barcodes)
For all visualizations in scRepertoire, there are 2 ways to adjust the color scheme:
hcl.pals()
. clonalQuant(combined.TCR, cloneCall="strict", chain = "both", scale = TRUE, palette = "Zissou 1") clonalQuant(combined.TCR, cloneCall="strict", chain = "both", scale = TRUE) + scale_fill_manual(values = hcl.colors(8,"geyser"))
The order of the group plotting (whether along an axis or in color) can be directly ordered using the order.by parameter in functions. Here we can place a vector of strings that will set the exact plotting order. If using order.by it is important to make sure your vectors match the group.by strings exactly.
Alternatively, we can set order.by = "alphanumeric", if we would like the plots sorted in order of the group.by variable.
clonalQuant(combined.TCR, cloneCall="strict", chain = "both", scale = TRUE, order.by = c("P17B","P18B","P19B","P20B","P17L","P18L","P19L","P20L"))
Within each of the general analysis functions, there is the ability to export the data frame used to create the visualization. To get the exported values, use exportTable = TRUE. It will return the data frame used to make the graph instead of the visual output.
clonalQuant_output <- clonalQuant(combined.TCR, cloneCall="strict", scale = TRUE, exportTable = TRUE) clonalQuant_output
We are working on submitting the scRepertoire as a peer review article,
Submit a GitHub issue - if possible please include a reproducible example. Alternatively, an example with the internal scRep_example and contig_list would be extremely helpful.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.