HUB
Sign inSign up

tcranalyzer/dev_jde

By tcranalyzer

•Updated 3 months ago

Shiny application for T-cell receptor repertoire analysis and antigen annotation

Image
Data science
0

2.5K

tcranalyzer/dev_jde repository overview

⁠TCRanalyzer: A user-friendly tool for comprehensive analysis of T-cell diversity, dynamics and potential antigen targets

T cells are critical for immune responses, recognizing antigens via their unique T-cell receptors (TCRs). Analyzing the diverse TCR repertoires, especially the hypervariable CDR3 region, is essential for understanding immune function in health and disease. Current TCR analysis tools often require specialized expertise, computational resources, or sacrifice biological information for efficiency. To address these limitations, we developed TCRanalyzer, a fast and comprehensive TCR analysis pipeline within a user-friendly graphical interface. TCRanalyzer covers all steps from data loading, aggregation and optional sequence clustering, to the analysis of TCR diversity metrics, clonal expansion and antigen specificity. Applied to datasets from patients with either benign or malignant tumors, TCRanalyzer identified changes in TCR clonality, clonal expansion and shifts in antigen specificity across different cohorts or following immunotherapy, thereby demonstrating its potential to dissect critical immunological processes. TCRanalyzer provides a robust and user-friendly tool for TCR sequence analysis, enhancing research in immunology and related fields.


⁠Table of Contents

⁠I. Installation

TCRanalyzer is available out-of-the-box as a Docker container (https://hub.docker.com/r/tcranalyzer/application⁠), which may be started within a graphical environment (Docker Desktop) or from the command line.

  1. Start Docker Desktop (Download available at: https://www.docker.com/products/docker-desktop/⁠)
  2. Search for 'tcranalyzer/application' and click 'Pull'

Wait until the download is finished and that's it. You can now follow the [Quick start](#Quick start) guide below to start your first analysis in TCRanalyzer.

⁠Option 2: Command line installation (Powershell, Bash)

To use TCRanalyzer from the command line, make sure that Docker is installed (https://docs.docker.com/engine/install/⁠).

Pull the TCRanalyzer Docker container from Docker Hub:

docker pull tcranalyzer/application:latest

⁠II. Overview

Overview of TCRanalyzer

⁠III. Quick start

Important: Before starting TCRanalyzer, always ensure your sample names follow the proper format (“PatIDSubsetXTx”) and that your sequencing data is stored in a folder structured as MyFolder/Data/studyname/. Please refer to our How to use your own data⁠ guide for more information.

⁠1) Start the Docker container

1. Run "tcranalyzer/application" in Docker Desktop

  • Search for "tcranalyzer/application" (in "Images")
  • Click "Run" (in "Actions")

2. Add "optional settings"

  • Host port = 3838,
  • Host path = select MyPath/MyFolder (containing a folder of your studyfiles "/studyfiles")
  • Container path= /app/Data
⁠Option 2: Use the command line (PowerShell, Bash)

Start the container by mounting your desired directory into the directory /app/Data within the TCRanalyzer Docker container. This mounted volume becomes your working environment. Within it, a Data folder and a Results folder will be created automatically when you run the modules. You should place your sequencing data folder inside this working environment so that the modules can locate and process your data.

Below is an example command with explanations for each flag:

docker run -it --rm \
  -p 3838:3838 \
  -v /MyPath/MyFolder:/app/Data \
  --name tcranalyzer \
  tcranalyzer/application:latest

Explanation of flags:

  • -it
    Runs the container in interactive mode with a TTY attached. It is useful for debugging with real‑time output.

  • --rm
    Automatically removes the container when it exits.

  • -p 3838:3838
    Maps port 3838 of the container to port 3838 on the host. This allows you to access the Shiny application through your browser using http://localhost:3838.

  • -v /MyPath/MyFolder:/app/Data
    Mounts the host directory /MyPath/MyFolder into the container at /app/Data.
    Note: This mounted volume is your working environment. You need to place your sequencing data folder inside this mounted volume so that the modules can find and process the data correctly. When the container starts, it will create a Data folder and a Results folder within /app/Data.

  • --name tcranalyzer
    Assigns the name tcranalyzer to the container.

  • tcranalyzer/application:latest
    Specifies the Docker image to use (with the latest tag). Make sure this image exists on your system or in your repository.

With this setup, after you start the container, your working environment is set up in /MyPath/MyFolder (mounted as /app/Data inside the container). The modules will create and populate the Data and Results folders within that directory based on your analysis workflows.

⁠File permissions for bind-mounted directories

TCRanalyzer writes intermediate data, results, and module log files to the host directory mounted at /app/Data. This directory must therefore be writable by the container.

Do not add --user $(id -u):$(id -g) by default. Docker Desktop, standard rootful Docker, rootless Docker, and Docker installations using user-namespace remapping handle host and container user IDs differently. On rootless or user-namespace-remapped systems, explicitly passing the host UID/GID can map to subordinate IDs on the host and make generated files inaccessible to the host user.

Before starting TCRanalyzer, verify that the working directory is writable on the host. For Bash-compatible shells:

touch /MyPath/MyFolder/.tcranalyzer_write_test && \
  rm /MyPath/MyFolder/.tcranalyzer_write_test

On a standard rootful Linux Docker installation, if the default command creates files owned by root on the host, you can instead run TCRanalyzer with your host UID and GID:

docker run -it --rm \
  --user "$(id -u):$(id -g)" \
  -e HOME=/tmp \
  -p 3838:3838 \
  -v /MyPath/MyFolder:/app/Data \
  --name tcranalyzer \
  tcranalyzer/application:latest

Do not use this --user form on rootless or user-namespace-remapped Docker installations unless it is recommended by your local administrator.

You can inspect Docker's UID/GID mapping with:

docker run --rm \
  --entrypoint sh \
  tcranalyzer/application:latest \
  -c 'echo "UID map:"; cat /proc/self/uid_map; echo "GID map:"; cat /proc/self/gid_map'

If container UID 0 is already mapped to your host UID, as can occur with rootless Docker on HPC systems, use the default command without --user. Site-specific instructions supplied by an HPC or system administrator take precedence over these general examples.

⁠2) Open the app

Open http://localhost:3838 in your web browser

Note: By accessing "localhost" your data remains on your local computer and analyses are performed on your own system. It will not be forwarded to the internet.

⁠Optionally: Load zipped Data into your Working Environment

The Load Study Files tab in TCRanalyzer lets you import your study data directly from a ZIP file into your working environment - no manual file copying or external uploads required. Here's how it works:

  • Study Name Assignment:
    Enter a study name in the provided text field. This name becomes the folder name in your working environment. All data extracted from the ZIP file will be organized under this folder.

  • ZIP File Selection:
    Use the file input to browse and select your ZIP file. The selected ZIP file contains your study's sequencing data. Importantly, the file is not uploaded to any remote server - it remains local and is only used to extract its contents into the container’s mounted volume.

  • Data Extraction:
    When you click the "Extract Study Data" button, the application will unzip the file directly into your working environment (the mounted volume, typically found at /app/Data). During extraction, two folders are created automatically: one for raw data (Data) and one for analysis results (Results).

  • Local Working Environment:
    The mounted volume serves as your working environment, where all study data is stored and processed. This approach ensures that your data stays on your local system (or in your designated workspace) and is immediately available for analysis by the container’s modules.

This feature streamlines the process of importing study data. Instead of manually copying and extracting files via your file browser, you simply select the ZIP file in the UI, and the data is automatically extracted into your working directory. This makes it easier and more efficient to update or import new data without leaving the TCRanalyzer interface.

⁠3) Start your analyses
  1. Choose a module
  2. Select or fill in parameters
  3. Click Run

That's it, TCRanalyzer does the rest. You can find a folder containing all generated results in the folder you provided in step 1.

Please read our Paper for a detailed description of the functionalities of each module

Note: Base Module 1 has to be run once for every new dataset before any analysis module can be started. Base Module 2 is optional and is only required if clustered TCR data should be used as input for Analysis Module 1 or 2.

⁠Optionally: Backup specific files

In the Backup tab you can select specific folders and files from your working environment to create a ZIP archive. This ZIP file is generated and downloaded locally to your PC. Nothing is stored externally - sensitive data remains on your system.

  • File Selection:
    Use the interactive folder tree to choose the folders and files you want to include in the backup.

  • Filename:
    Enter your desired filename in the provided text field. The application will create a ZIP file with that name.

  • ZIP Creation:
    Click the "Zip and Save Selected Data for a Backup" button. The selected data is compressed into a ZIP file, which is then downloaded directly to your PC.

By performing the backup locally, your data stays secure on your machine and is never transmitted over the web.

⁠4) Close TCRanalyzer

You can stop the app in Docker Desktop (Container -> Actions -> Stop)

⁠IV. Parameters

⁠1) Study name

= folder name containing your sequencing data

  • This parameter is needed in every module and tells TCRanalyzer which dataset you want to use
  • Example: HCC
⁠2) Count cutoff

= All samples with a total CDR3 count <= cutoff will be removed from the dataset.

  • Default: 100 (can be changed to any other number)
⁠3) Clustered TCR

= Do you want to analyze unclustered ("No") or clustered CDR3 ("Yes")?

  • "No": aggregated datasets from Base Module 1 will be analyzed
  • "Yes": aggregated & clustered datasets from Base Module 2 will be analyzed
  • Note: If you select "yes" and get an error, please check if you ran Base Module 2 on the dataset once.
⁠4) Comparison

The Comparison setting defines whether the analysis compares different subsets or different timepoints within one subset. The fields shown in the interface depend on Compare Dynamics.

When Compare Dynamics = No:

  • Subset compares two different subsets at one fixed timepoint.
    • Subset 1 and Subset 2: the two subsets to compare.
    • Timepoint: the fixed timepoint used for both subsets.
  • Timepoint compares two timepoints within one subset.
    • Subset: the subset to analyze.
    • Timepoint 1 and Timepoint 2: the two timepoints to compare.

These non-dynamics runs generate the static AM1 comparison outputs, including Simpson's Clonality, percentage of Singletons (PoS), and clone-overlap results.

Matched samples are paired by patient ID. Normality is assessed using the Shapiro–Wilk test, using paired differences for matched samples. Depending on normality and pairing, comparisons are performed using paired or Welch’s t-tests, or Wilcoxon signed-rank or rank-sum tests, respectively. If all paired differences are zero, the P-value is set to 1.

⁠5) Compare Dynamics?

Set Compare Dynamics to Yes to run a dynamics-only comparison based on time intervals. Static timepoint comparison fields are hidden and are not used for the analysis, output directory, or filenames. Dynamics-only runs generate the clonal-expansion comparison outputs for Expanded Singletons (ES) and Expanded Non-Singletons (ENS).

⁠When Comparison = Subset

You compare one time interval from Subset 1 with one time interval from Subset 2. The ordinary fixed Timepoint field is not used.

  • Time Interval 1: interval for Subset 1 (for example, T0-T1).
  • Time Interval 2: interval for Subset 2 (for example, T0-T1).

The two subsets may be compared over the same interval. For example, HCCtissue T0-T1 can be compared with HCCblood T0-T1.

⁠When Comparison = Timepoint

You compare two different time intervals within one subset. The ordinary Timepoint 1 and Timepoint 2 fields are not used.

  • Subset: the subset to analyze.
  • Time Interval 1: the first interval (for example, T0-T1).
  • Time Interval 2: the second interval (for example, T1-T2).
⁠Dynamics output directories

Dynamics-only run directories are identified by the selected subset(s) and intervals. They do not contain an unrelated fixed timepoint. For example:

Results/HCC/AM1/Subset__HCCtissue-vs-HCCblood__dynamics-T0-T1-vs-T0-T1__aggr/
⁠Important Notes:
  • The available timepoints are parsed from the sequencing-data filenames at runtime.
  • If the timepoints required for a comparison are not available, review the sequencing-data filenames.
  • If sequencing data were added or removed, re-run at least Base Module 1.
  • A single dynamics interval must contain two different timepoints (for example, T0-T1, not T0-T0).
  • For Comparison = Timepoint, the two selected dynamics intervals must also be different from one another.
⁠6) TCR chain

= Did you sequence CDR3 from TCR alpha ("TRA") or beta chain ("TRB")? Note: TCRanalyzer will select the compatible subset of CDR3 sequences in the CDR3-antigen database.

⁠7) Annotation

= Decides on the type of antigen annotation that should be analyzed (recommended: gene.exactly; see our ReadMe for details)

  • This parameter is needed for the comparison of antigen specificities between the two groups of TCR repertoires (as selected previously)
  • "gene.exactly" (recommended): CDR3s are annotated with target genes, if the filtered alignments with VDJdb CDR3s have one or several identical target gene annotations
  • "species.exactly": CDR3s are annotated with target species, if the filtered alignments with VDJdb CDR3s have one or several identical target species annotations
  • "gene.max": CDR3s are annotated with the most frequent target gene in the filtered alignments with VDJdb CDR3s
  • "species.max": CDR3s are annotated with the most frequent target species in the filtered alignments with VDJdb CDR3s

CDR3 sequences are aligned against the selected VDJdb TCR chain using MMseqs2. Only alignments with an E-value <= 0.05 are retained. The best alignment is selected by lowest E-value, followed by highest bit score and sequence identity. Antigen frequencies are calculated from clone counts relative to the total annotated clone count of each sample. An antigen absent from an otherwise annotated sample is assigned a frequency of zero.Samples without annotated clone counts remain missing.

⁠8) Volcano Plot P-value Type

This parameter determines which type of p-value is used in the volcano plot. You can choose between:

  • p (corrected): Applies multiple testing correction using the Benjamini-Hochberg method to control the false discovery rate (FDR). This is strongly recommended, especially when working with large datasets where multiple comparisons increase the risk of false positives.
  • p: Raw, unadjusted p-values. Use with caution, as these do not account for multiple testing and may lead to misleading results.

For comparative AM2 analyses, the volcano-plot x-axis shows the difference in mean antigen frequency between the two groups, calculated as Group 2 minus Group 1. For a Subset comparison this corresponds to Subset 2 minus Subset 1. For a Timepoint comparison it corresponds to Timepoint 2 minus Timepoint 1. Positive values therefore indicate a higher mean antigen frequency in the second group.

⁠V. Example data

...

⁠VI. How to use your own data

Important: If you change your dataset, you must either assign a new folder name for the updated dataset or delete the associated files in the Data and Results Directories, as these processes build upon one another’s results. Please rerun at least BM1.

⁠1) Check sample names
  • The names of your samples have to follow the format: "PatID_SubsetX_Tx"
  • Important: Use only combinations of letter(s) and/or number(s) for PatID and SubsetX (special characters, symbols or spaces will result in errors)
  • PatID: unique identifier for each patient, e.g. "Pat123"
  • SubsetX: unique identifier for each subset, e.g. "Blood"
  • Tx: unique identifier for timepoints, e.g. "T0" (use "T" followed by a number)
  • Sample names could be: "Pat123_Blood_T0", "Pat123_Blood_T2", "Pat123_Tumor_T0", "Pat123_CD8_T3"
⁠2) Save your sequencing data in MyFolder/Data/studyname
  • MyFolder: The folder where your data and all results of your analyses will be stored (We recommend creating a new folder for TCRanalyzer and save your recent and all future data for analysis there)
  • Data: If not already done, create the subfolder "Data", e.g. "MyFolder/Data"
  • studyname: To add new sequencing data for analysis, create a new subfolder in "MyFolder/Data", e.g. "MyFolder/Data/studyname" (Note: we recommend choosing a short, unique foldername without using any special characters or spaces. All generated results will carry this name.)
  • Save only your sequencing data in "MyFolder/Data/studyname", nothing else.
  • Note: You can have several studyname-folders with different names. You will choose in each module which dataset you want to use/analyze by providing the folder name (with parameter: Study name).
⁠3) Proceed with our [Quick start](#quick start) guide

⁠VII. Plot manipulation

If you are familiar with R, you can use the fixVis function of the R package 'immunarch' (https://immunarch.com/⁠) to customize compatible AM1 plots. TCRanalyzer saves the corresponding AM1 plot objects as .rda files in the run-specific fixVis directories. AM2 volcano plots are provided as PDF files and are not saved as .rda plot objects.

Dependencies:

⁠1. Open RStudio & load immunarch
library(immunarch)
⁠2. Load your plot
load("MyFolder/Results/studyname/AM1/fixVis/plotname.rda")

Or you can simply double-click on plotname.rda in the fixVis folder.

⁠3. Use the fixVis function of immunarch
fixVis(plot.tmp)

A graphical interface will open where you can adjust your plot manually.

Note: plot.tmp is the name of the plot in your global environment in R. You can exchange "plot.tmp" with another plot of your R environment.

You can visit https://immunarch.com/⁠ for more information on plot manipulation with fixVis.

⁠VIII. Troubleshooting

⁠Sudden Stop of the Processes
⁠Unexpected Stopping in Virtual Machine (e.g., WSL):

Check if RAM is sufficient: You can monitor the system's memory usage by running htop (if not installed, you can install it using sudo apt install htop in your virtual machine or Docker container). In htop, observe the memory and swap usage. If the system is running low on memory, it might cause processes to stop unexpectedly. If needed allocate more memory to your Virtual Machine.

⁠Unexpected Stopping in Docker Desktop

Allocate more RAM to the Docker container: If you suspect insufficient memory is causing the issue in a Docker container, you can increase the allocated RAM by modifying the Docker settings:

  • Open Docker Desktop.
  • Go to Settings -> Resources.
  • Adjust the Memory slider to allocate more RAM to the Docker container.

After adjusting the settings, restart the container to apply the changes.

⁠Permission denied for /app/Data

TCRanalyzer requires write access to the directory mounted at /app/Data. At startup, the container checks this and exits with a diagnostic message if the directory is not writable.

If you receive a permission error:

  1. Verify that the host working directory is writable using the write test described above.
  2. Check whether Docker uses rootless mode or user-namespace remapping before adding a --user option.
  3. Avoid broad permission changes such as chmod -R 777 as a general solution. On managed HPC systems, follow the local storage and Docker policy.
⁠Other Errors

“In case of errors, check the module log files generated in the directory mounted to /app/Data: info_bm1.log, info_bm2.log, info_am1.log, and info_am2.log. If you need help regarding an error, please contact us with the corresponding log file attached.”

⁠IX. Contact

You can create an issue in the TCRanalyzer GitLab repository⁠ or contact us directly via [email protected]⁠.

⁠X. Citation

If you use TCRanalyzer in your research, please cite:

Seifert N, Reinke S, Kurz NS, Demmer J, Kornrumpf K, Beißbarth T, Klapper W, Altenbuchinger M. TCRanalyzer: A user-friendly tool for comprehensive analysis of T-cell diversity, dynamics and potential antigen targets. bioRxiv. 2025. doi: 10.1101/2025.05.09.652820⁠.

Preprint: https://www.biorxiv.org/content/10.1101/2025.05.09.652820v1.full.pdf⁠

⁠XI. License

The package is freely distributed under the CC-BY 4.0 International license.

For commercial or server use, please contact us via [email protected]⁠.

Tag summary

Content type

Image

Digest

sha256:7ecbbfa45…

Size

1.7 GB

Last updated

3 months ago

docker pull tcranalyzer/dev_jde