# knitr::knit_hooks$set(optipng = knitr::hook_optipng) # knitr::opts_chunk$set(optipng = '-o7') knitr::opts_chunk$set(echo = TRUE) knitr::opts_chunk$set(fig.align = "center") knitr::opts_chunk$set(fig.width = 18) knitr::opts_chunk$set(fig.height = 12) library(immunarch) data(scdata)
This is a vignette dedicated to provide an overview on how to work with single-cell paired chain data in
immunarch
Single-cell support is currently in the development version. In order to access it, you need to install the latest development version of the package by executing the following command:
install.packages("devtools"); devtools::install_github("immunomind/immunarch", ref="dev")
To read paired chain data into
immunarch
use therepLoad
function with.mode = "paired"
. Currently we support 10X Genomics only.To subset immune repertoires by specific barcodes use the
select_barcodes
function. Output ofSeurat::Idents()
as a barcode vector works.To create cluster-specific and patient-specific datasets using barcodes from the output of
Seurat::Idents()
use theselect_clusters
function.
immunarch
Load the package into the R enviroment:
library(immunarch)
For testing purposes we attached a new paired chain dataset to immunarch
. Load it by executing the following command:
data(scdata)
To load your own datasets, use the repLoad
function. Currently we implemented paired chain data support for 10X Genomics data only. A working example of loading datasets into R:
file_path <- paste0(system.file(package = "immunarch"), "/extdata/sc/flu.csv.gz") igdata <- repLoad(file_path, .mode = "paired") igdata$meta head(igdata$data[[1]][c(1:7, 16, 17)])
To subset the data by barcodes, use the select_barcodes
function.
barcodes <- c("AGTAGTCAGTGTACTC-1", "GGCGACTGTACCGAGA-1", "TTGAACGGTCACCTAA-1") new_df <- select_barcodes(scdata$data[[1]], barcodes) new_df
To create a new dataset with cluster-specific immune repertoires, use the select_clusters
function:
scdata_pat <- select_clusters(scdata, scdata$bc_patient, "Patient") names(scdata_pat$data) scdata_pat$meta
To create a new dataset with cluster-specific immune repertoires, use the select_clusters
function. You can apply this function after you created patient-specific datasets to get patient-specific cell cluster-specific immune repertoires, e.g., a Memory B Cell repertoire for a specific patient:
scdata_cl <- select_clusters(scdata_pat, scdata$bc_cluster, "Cluster") names(scdata_cl$data) scdata_cl$meta
Most functions will work out-of-the-box with paired chain data.
p1 <- repOverlap(scdata_cl$data) %>% vis() p2 <- repDiversity(scdata_cl$data) %>% vis() target <- c("CARAGYLRGFDYW;CQQYGSSPLTF", "CARATSFYYFHHW;CTSYTTRTTLIF", "CARDLSRGDYFPYFSYHMNVW;CQSDDTANHVIF", "CARGFDTNAFDIW;CTAWDDSLSGVVF", "CTREDYW;CMQTIQLRTF") p3 <- trackClonotypes(scdata_cl$data, target, .col = "aa") %>% vis() (p1 + p2) / p3
Several functions may work incorrectly with paired chain data in this release of immunarch
. Let us know via GitHub Issues!
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.