Before analysis

Before running this pipeline you should do next steps:

  1. Save your parsed MiTCR data to the immdata variable (it must be a list with mitcr data frames).
immdata <- parse.folder('/home/username/mitcrdata/')
  1. Save the immdata variable to the some folder as the .rda file.
save(immdata, file = '/home/username/immdata.rda')
  1. In the code block below change the path string to the path to yours immdata.rda file. After that click the Knit HTML button to start analysis and make an output .html file with it's results.
load('../data/twb.rda')
immdata <- twb
library(tcR)
  1. Friendly advice: run the pipeline on first N top sequences first and then set up the size of figures.
N <- 10000
immdata <- lapply(immdata, head, N)

Number of shared clones and clonotypes

Number of shared clones (CDR3 nucleotide sequences)

-- without and with normalisation

crs1 <- repOverlap(immdata, .norm=F, .verbose=F)
crs2 <- repOverlap(immdata, .norm=T, .verbose=F)
do.call(grid.arrange, list(vis.heatmap(crs1, .title = 'Number of shared clones', .legend = 'Shared clones'), vis.heatmap(crs2, .title = 'Number of shared clones', .legend = 'Shared clones'), nrow = 1))

Number of shared clonotypes (CDR3 amino acid sequences)

-- without and with normalisation

crs1 <- repOverlap(immdata, .seq = "aa", .norm=F, .verbose=F)
crs2 <- repOverlap(immdata, .seq = "aa", .norm=T, .verbose=F)
do.call(grid.arrange, list(vis.heatmap(crs1), vis.heatmap(crs2), nrow = 1))

Number of shared clones using V-segments

-- without and with normalisation

crs1 <- repOverlap(immdata, .vgene = T, .norm=F, .verbose=F)
crs2 <- repOverlap(immdata, .vgene = T, .norm=T, .verbose=F)
do.call(grid.arrange, list(vis.heatmap(crs1, .title = 'Number of shared clones + V', .legend = 'Shared clones'), vis.heatmap(crs2, .title = 'Number of shared clones + V'), nrow = 1))

Number of shared clonotypes using V-segments

-- without and with normalisation

crs1 <- repOverlap(immdata, .seq = "aa", .vgene = T, .norm=F, .verbose=F)
crs2 <- repOverlap(immdata, .seq = "aa", .vgene = T, .norm=T, .verbose=F)
do.call(grid.arrange, list(vis.heatmap(crs1, .title = 'Number of shared clonotypes + V'), vis.heatmap(crs2, .title = 'Number of shared clonotypes + V'), nrow = 1))

Segments statistics

V-segments usage

vis.gene.usage(immdata, HUMAN_TRBV, .ncol = 2, .coord.flip = F)

V-segments summary statistics

# Change the groups variable for plotting V-usage boxplot for groups.
groups <- list(Group.A = names(immdata)[1:(length(immdata) / 2)],
               Group.B = names(immdata)[(length(immdata) / 2 + 1) : length(immdata)])
vis.group.boxplot(geneUsage(immdata, HUMAN_TRBV, .norm = T), groups, .rotate.x = T)

J-segments usage

vis.gene.usage(immdata, HUMAN_TRBJ, .coord.flip=F, .ncol = 2)

Jennsen - Shannon Divergence applied to the segments frequency of supplied data frames

V-segments Jennsen - Shannon Divergence among repertoires

res <- js.div.seg(immdata, HUMAN_TRBV, .frame='all', .verbose = F)
vis.heatmap(round(res, 5))

V-segments Jennsen - Shannon Divergence radarplot

res <- js.div.seg(immdata, HUMAN_TRBV, .frame='all', .verbose = F)
vis.radarlike(res, .ncol = 2)

PCA on segments' frequencies

PCA on V-segments statistics

pca.segments(immdata)

PCA on V-J segments statistics

pca.segments.2D(immdata, .genes = list(HUMAN_TRBV, HUMAN_TRBJ))

Top cross

top.cross.plot(top.cross(permutedf(immdata), seq(500, min(sapply(immdata, nrow)), 500), .verbose = F))

Shared repertoire statistics by clonotypes using V-segments

imm.sh <- shared.repertoire(immdata, 'av', .verbose = F)
shared.clones.count(imm.sh)
shared.representation(imm.sh)

Rarefaction group analysis

clmn <- 'Read.count'
if (!is.na(immdata[[1]]$Umi.count[1])) {
  clmn <- 'Umi.count'
}
vis.rarefaction(rarefaction(immdata, .col = clmn, .verbose = F), list(A = c("Subj.A", "Subj.B"), B = c("Subj.C", "Subj.D")), .log = T)


imminfo/tcr documentation built on June 13, 2020, 7:01 a.m.