Skip to content

R function to generate a circos-style ggplot from single-cell TCR data.

License

Notifications You must be signed in to change notification settings

aislyn/TCR_circos

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TCR_circos

The TCR_circos function is meant to create a circos-style ggplot full of annotations for single cell TCR data. Each "spoke" is intended to be a clonotype with the outmost ring being a clonotype's frequency and the inner rings showing the frequency of annotations for each clonotype. TCR_circos relies on cowplots to stack the annotation rings.

It takes the following arguments:

df: the data frame off annotations. It is intended to run from a dataframe where all column annotations are factors and each row is a cell.

clonotype: is the (string) name of the column for the outmost clonotype annotations.

annotation: vector of the names of the columns to use as the inner annotation rings.

colors: is a named list of named vectors for the annotation colors.

scale: scale value for the width of the inner rings compared to the outmost. Sensible values are from 0.1 to 0.5.

gap: size of the gap between the rings. Sensible values are from 0 to 0.2.

max.n: The value to scale the count frequency for each clonotype to. Defaults to the max in the data, but can be set to another value so as to keep two separate plots on the same scale.

out put

The function outputs a list of two plots. The first is the circos plot and the second is its legends.

example

df = read_csv("path/to/example_TCR_data.csv", col_types = "ffffff")

colors = list("Cluster" = rainbow(11)[c(1,6,2,7,8,3,11,4,9,5,10)] %>% setNames(1:11),
              "mait_evidence" = topo.colors(12)[c(1,9,5,11,3,7)] %>%  setNames(levels(df$mait_evidence)),
              "n_TRB" = c("0" = "black", "1" = "tomato", "2"="goldenrod2"))
              
example_plot1 = TCR_circos(df[1:500,],  clonotype ="cdr3s_nt", annotations = annotations, colors = colors)
plot_grid(example_plot1$plot, example_plot1$legend, nrow=1)

example_plot1

example_plot2 = TCR_circos(df[1:500,],  clonotype ="cdr3s_nt", annotations = c("mait_evidence","n_TRB"), scale = 0.5, gap = 0.2, colors = colors)
plot_grid(example_plot2$plot, example_plot2$legend, nrow=1) -> example_plot2_with_legend

example_plot2

ordering

Currently the plot only orders by clonotype frequency, but later versions will hopfully allow for custom ordering and a dendrogram plot in the middle.

data

The example data file provided here was downloaded from 10X genomics and processed as if it was the cell metadata for single cell TCR/transcriptome analysis.

About

R function to generate a circos-style ggplot from single-cell TCR data.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages