rm(list=ls())
#devtools::install_github("ncborcherding/scRepertoire")
# Load the package into R
library(immunarch)
library(scRepertoire)
library(tidyverse)
library(SingleCellExperiment)
library(Seurat)
read_mixcr_n_trans<- function(file,...){
df <- read.delim(file)
# transform the cell id {be consist with RNA data}
{
well<- gsub(df$cellId,pattern = "[AGCT]*-",replacement = "")
hp<- gsub(df$cellId,pattern = "-[AGCT]*-.*",replacement = "")
rt<- str_extract(df$cellId,pattern = "-[AGCT]{10}")%>%
str_sub(.,start = 2,end = nchar(.))
}
# add a column named "tagValueCELL" {as normal mixcr output}
df$tagValueCELL<- paste(well,hp,rt,sep ="_" )
return(df)
}
# Step1: Load MIXCR output -----------------------------------------
fn1 <- "mixcr_output/xxxxxxxxxxxx.clones.tsv"
fn2 <- "mixcr_output/xxxxxxxxxxxx..clones.tsv"
fn3 <- "mixcr_output/xxxxxxxxxxxx..clones.tsv"
filelist <- c(fn1,fn2,fn3)
samples <- c("A","B","C")
contig_list<- lapply(filelist, function(x) read_mixcr_n_trans(x))
colnames(contig_list[[1]])
# convert to "scRepertoire" style
contig.list <- loadContigs(input = contig_list,
format = "MiXCR")
names(contig.list)
colnames(contig.list[[1]])
head((contig.list[[1]]))
#[1] "barcode" "chain" "reads" "v_gene" "d_gene" "j_gene" "c_gene" "cdr3_nt" "cdr3"
combined.TCR <- combineTCR(contig.list,
# samples = samples, # names of different samples # can be NULL
removeNA = FALSE,
removeMulti = FALSE,
filterMulti = FALSE)
names(combined.TCR)
colnames(combined.TCR[[1]])
head((combined.TCR[[1]]))[,1:5] # sample name pasted to cell_id
# [1] "barcode" "sample" "TCR1" "cdr3_aa1" "cdr3_nt1" "TCR2" "cdr3_aa2" "cdr3_nt2"
#[9] "CTgene" "CTnt" "CTaa" "CTstrict"
# Basic clone analysis-------------------------------------
## 獨(dú)特克隆數(shù)量-----
#the total or relative numbers of unique clones.
clonalQuant(combined.TCR,
cloneCall="strict",
chain = "both",
scale = TRUE)
# 指定自定義分組進(jìn)行統(tǒng)計(jì)
clonalQuant(combined.TCR, cloneCall = "gene", group.by = "sample", scale = TRUE)
##克隆豐度 ----
clonalAbundance(combined.TCR,
cloneCall = "gene",
scale = FALSE)
#密度圖
clonalAbundance(combined.TCR, cloneCall = "gene", scale = TRUE)
##克隆長(zhǎng)度-----
clonalLength(combined.TCR,
cloneCall="aa", #cloneCall can only be “nt” or “aa”
chain = "both") # “both” for combined chain visualization
# “TRA”, “TRB”, “TRD”, “TRG”, “IGH” or “IGL” to select single chain
clonalLength(combined.TCR,
cloneCall="aa",
chain = "TRA",
scale = TRUE)
## 克隆比較
# 沖積圖
clonalCompare(combined.TCR,
top.clones = 10,
samples = samples,
# highlight.clones = c("CAYRSGARDDKIIF"),
cloneCall="aa",
graph = "alluvial")
#散點(diǎn)圖
clonalScatter(combined.TCR,
cloneCall ="gene",
x.axis = samples[1],
y.axis = samples[2],
dot.size = "total",
graph = "proportion")
clonalScatter(combined.TCR,
cloneCall ="gene",
x.axis = samples[2],
y.axis = samples[3],
dot.size = "total",
graph = "proportion")
##克隆穩(wěn)態(tài)
clonalHomeostasis(combined.TCR,
cloneCall = "gene")
## 克隆比例
clonalProportion(combined.TCR,
cloneCall = "gene")
## TCR cluster
sub_combined <- clonalCluster(combined.TCR[[1]],
chain = "TRA",
sequence = "aa",
threshold = 0.85,
group.by = NULL)
sub_combined$TRA_cluster
#Cluster denotes if the cluster was called using the normalized Levenshtein distance, which takes the edit distance calculated between 2 sequences
#and divides that by the mean of the sequence lengths.
#Unconnected sequences will have NA values.
##combine with RNA ------
# seurat object after umap :
combined <- readRDS(file = "RNA/Seurat_output/prefiltered_combined.rds")
sce <- Seurat::as.SingleCellExperiment(combined)
sce <- combineExpression(combined.TCR,
sce,
cloneCall="gene",
#group.by = "sample",
proportion = TRUE)
#Define color palette
colorblind_vector <- hcl.colors(n=7, palette = "inferno", fixup = TRUE)
colnames(colData(sce))
singleCellTK::plotUMAP(sce,colorBy = "cloneSize") +
scale_color_manual(values=rev(colorblind_vector[c(1,3,5,7)]))
scTCR-seq分析: MIXCR + scRepertoire
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
- 文/潘曉璐 我一進(jìn)店門(mén)灼卢,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái),“玉大人来农,你說(shuō)我怎么就攤上這事〕缪撸” “怎么了沃于?”我有些...
- 文/不壞的土叔 我叫張陵,是天一觀(guān)的道長(zhǎng)海诲。 經(jīng)常有香客問(wèn)我繁莹,道長(zhǎng),這世上最難降的妖魔是什么特幔? 我笑而不...
- 正文 為了忘掉前任咨演,我火速辦了婚禮,結(jié)果婚禮上蚯斯,老公的妹妹穿的比我還像新娘薄风。我一直安慰自己,他們只是感情好拍嵌,可當(dāng)我...
- 文/花漫 我一把揭開(kāi)白布遭赂。 她就那樣靜靜地躺著,像睡著了一般横辆。 火紅的嫁衣襯著肌膚如雪撇他。 梳的紋絲不亂的頭發(fā)上,一...
- 那天狈蚤,我揣著相機(jī)與錄音困肩,去河邊找鬼。 笑死脆侮,一個(gè)胖子當(dāng)著我的面吹牛锌畸,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播他嚷,決...
- 文/蒼蘭香墨 我猛地睜開(kāi)眼蹋绽,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼芭毙!你這毒婦竟也來(lái)了?” 一聲冷哼從身側(cè)響起卸耘,我...
- 序言:老撾萬(wàn)榮一對(duì)情侶失蹤退敦,失蹤者是張志新(化名)和其女友劉穎,沒(méi)想到半個(gè)月后蚣抗,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體侈百,經(jīng)...
- 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
- 正文 我和宋清朗相戀三年翰铡,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了钝域。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
- 正文 年R本政府宣布,位于F島的核電站漠秋,受9級(jí)特大地震影響笙蒙,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜庆锦,卻給世界環(huán)境...
- 文/蒙蒙 一捅位、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧搂抒,春花似錦艇搀、人聲如沸。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)。三九已至誉帅,卻和暖如春淀散,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背蚜锨。 一陣腳步聲響...
- 正文 我出身青樓郭膛,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親氛悬。 傳聞我的和親對(duì)象是個(gè)殘疾皇子则剃,可洞房花燭夜當(dāng)晚...
推薦閱讀更多精彩內(nèi)容
- 我也認(rèn)為長(zhǎng)讀長(zhǎng)測(cè)序是 RNA 測(cè)序的未來(lái)耘柱!隨著價(jià)格的降低和堿基質(zhì)量的提升,傳統(tǒng)的二代RNA-seq會(huì)被逐漸取代棍现。 ...
- 前言 如果你和我一樣是小白调煎,那么恭喜你! 看完這篇文章己肮,你也可以擁有一個(gè)這樣的博客啦士袄! 歡迎在文末留言,或者點(diǎn)擊加...
- github地址:https://github.com/seandavi/awesome-single-cell這...
- 擬時(shí)間分析簡(jiǎn)介 擬時(shí)序(pseudotime)分析,又稱(chēng)細(xì)胞軌跡(cell trajectory)分析艘绍,通過(guò)擬時(shí)分...
- 一個(gè)強(qiáng)大的網(wǎng)絡(luò)分析shell腳本分享(實(shí)時(shí)流量鞍盗、連接統(tǒng)計(jì))linux shell腳本之家http://www.jb...