### Run DeepCAT Docker Container (Bash) Source: https://github.com/s175573/deepcat/blob/master/README.md Runs the DeepCAT Docker container, mounting a local directory for results. This command starts the container and makes the 'Results' directory accessible inside the container for storing output. ```bash docker run -v $(pwd)/Results:/Results deepcat/cancer_associated_tcr:1 ``` -------------------------------- ### Process Raw TCR Repertoire Data using Python Source: https://context7.com/s175573/deepcat/llms.txt Converts raw Adaptive Biotechnology TSV files into a format suitable for iSMART clustering. This script filters non-productive sequences, selects top sequences by frequency, and retains sequences with specific characteristics (10-24 AA, starting with C, ending with F). It processes all .tsv files in a specified input directory and outputs formatted .tsv files. ```python import sys sys.argv = ['PrepareAdaptiveFile.py', 'input_data/', 'output_data/'] exec(open('PrepareAdaptiveFile.py').read()) # Processes all .tsv files in input directory # Filters: removes sequences with *, X, unresolved V-genes # Keeps: sequences 10-24 AA, starting with C, ending with F # Selects: top 10,000 sequences by frequency # Output: TestReal-[filename].tsv with amino_acid, v_gene, frequency columns ``` -------------------------------- ### Download DeepCAT Docker Image (Bash) Source: https://github.com/s175573/deepcat/blob/master/README.md Downloads the DeepCAT Docker image from Docker Hub. This command is used to obtain the pre-built Docker image for running DeepCAT in a containerized environment. ```bash docker pull deepcat/cancer_associated_tcr:1 ``` -------------------------------- ### Save and Load DeepCAT Docker Image (Bash) Source: https://github.com/s175573/deepcat/blob/master/README.md Saves the DeepCAT Docker image to a tar archive and loads it from a tar archive. This is useful for transferring the image between systems or for offline usage. ```bash docker save deepcat/cancer_associated_tcr > deep_cat.tar docker load --input deep_cat.tar ``` -------------------------------- ### Train DeepCAT Models (Python) Source: https://github.com/s175573/deepcat/blob/master/README.md Trains DeepCAT models using specified training and evaluation data. This function performs cross-validation and saves trained models in subdirectories. It requires the DeepCAT library and training data files. ```python from DeepCAT import * PredictClassList,PredictLabelList,AUCDictList = batchTrain(ftumor='TrainingData/TumorCDR3.txt',n=10, feval_tumor='TrainingData/TumorCDR3_test.txt', feval_normal='TrainingData/NormalCDR3_test.txt', STEPs=20000, rate=0.33, fnormal='TrainingData/NormalCDR3.txt') print(AUCDictList) ``` -------------------------------- ### Complete Pipeline Execution (bash) Source: https://context7.com/s175573/deepcat/llms.txt An end-to-end bash script that orchestrates the DeepCAT workflow from raw data to cancer scores. Supports both pre-clustered and raw data inputs. ```APIDOC ## Complete Pipeline Execution ### Description End-to-end bash script that orchestrates the entire DeepCAT workflow from raw data to cancer scores, supporting both pre-clustered and raw data inputs. ### Method Bash Script Execution ### Endpoint N/A (Bash script) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```bash # Process raw TCR repertoire data mkdir my_raw_data # Place your .tsv files in my_raw_data/ bash Script_DeepCAT.sh -r my_raw_data # Process pre-clustered data bash Script_DeepCAT.sh -t SampleData/Cancer ``` ### Response #### Success Response (200) - For raw data processing (`-r`): `Cancer_score.txt` file containing filename and mean cancer score for each processed file. - For pre-clustered data processing (`-t`): Output to standard output with filename and mean cancer score. #### Response Example ``` # Example output for pre-clustered data: TestReal-BR01B.tsv_ClusteredCDR3s_7.5.txt 0.42574785 TestReal-BR05B.tsv_ClusteredCDR3s_7.5.txt 0.38407683 ``` ``` -------------------------------- ### GetFeatureLabels - Prepare Training Data for CNN (Python) Source: https://context7.com/s175573/deepcat/llms.txt Organizes tumor and normal CDR3 sequences into feature matrices and corresponding labels, grouped by sequence length. This prepares data for training CNN models. ```python from DeepCAT import GetFeatureLabels import numpy as np # Prepare training data tumor_sequences = np.array(["CASSLGQAYEQYF", "CASSLAPGTYEQYF", "CASSDTGELF"]) normal_sequences = np.array(["CASSQGAYEQYF", "CASSYTGELF", "CASSLVQYF"]) FeatureDict, LabelDict = GetFeatureLabels(tumor_sequences, normal_sequences) # Access features for length 13 if 13 in FeatureDict: features_L13 = FeatureDict[13]['x'] labels_L13 = LabelDict[13] print(f"Length 13: {features_L13.shape[0]} sequences") print(f"Labels: {np.sum(labels_L13)} tumor, {len(labels_L13) - np.sum(labels_L13)} normal") ``` -------------------------------- ### Execute DeepCAT Pipeline using Bash Source: https://context7.com/s175573/deepcat/llms.txt Orchestrates the entire DeepCAT workflow from raw TCR repertoire data to cancer scores. It supports processing of both raw .tsv files (triggering data preparation and clustering) and pre-clustered data. The script outputs a file containing filenames and their corresponding mean cancer scores. ```bash # Process raw TCR repertoire data mkdir my_raw_data # Place your .tsv files in my_raw_data/ bash Script_DeepCAT.sh -r my_raw_data # This executes: # 1. PrepareAdaptiveFile.py - filters and formats raw data # 2. iSMARTm.py - clusters similar CDR3 sequences # 3. DeepCAT.py - predicts cancer scores # Output: Cancer_score.txt with filename and mean cancer score # Process pre-clustered data bash Script_DeepCAT.sh -t SampleData/Cancer # Output format: # TestReal-BR01B.tsv_ClusteredCDR3s_7.5.txt 0.42574785 # TestReal-BR05B.tsv_ClusteredCDR3s_7.5.txt 0.38407683 ``` -------------------------------- ### Load V-gene Similarity Scores and Obtain CDR3 Clusters Source: https://context7.com/s175573/deepcat/llms.txt Loads V-gene similarity scores from a file and then uses this information, along with input sequences and parameters, to obtain clustered CDR3 sequences. This process involves defining gap penalties, similarity cutoffs, and specifying whether to use V-gene information. ```python VScore = {} for line in vscore_file: parts = line.strip().split('\t') VScore[(parts[0], parts[1])] = int(parts[2]) CL, Seqs, Vgene, PWscore, CDR3Dict = ObtainCL( InputFile=input_file, VScore=VScore, gap=-6, # Gap penalty gapn=1, # Max gaps allowed cutoff=7.5, # Similarity threshold UseV=True, # Use V-gene information outDir='./', Nthread=1 ) print(f"Found {len(CL)} CDR3 clusters") ``` -------------------------------- ### Train Custom DeepCAT Models using Python Source: https://context7.com/s175573/deepcat/llms.txt Performs n-fold cross-validation training of CNN models on custom tumor and normal CDR3 datasets. It allows for configurable training parameters and automatic evaluation, producing lists of predicted class labels, predicted probabilities, and AUC scores for each CDR3 length. Requires training and evaluation files for both tumor and normal datasets. ```python from DeepCAT import batchTrain # Train DeepCAT models from scratch tumor_file = 'TrainingData/TumorCDR3.txt' normal_file = 'TrainingData/NormalCDR3.txt' eval_tumor = 'TrainingData/TumorCDR3_test.txt' eval_normal = 'TrainingData/NormalCDR3_test.txt' PredictClassList, PredictLabelList, AUCDictList = batchTrain( ftumor=tumor_file, fnormal=normal_file, feval_tumor=eval_tumor, feval_normal=eval_normal, n=10, # 10 training cycles STEPs=20000, # Training steps per cycle rate=0.33, # 33% validation, 67% training dir_prefix='./tmp/' ) # Print AUC scores for each CDR3 length for auc_dict in AUCDictList: print(f"AUC scores by length: {auc_dict}") # Example output: {12: 0.78, 13: 0.82, 14: 0.85, 15: 0.81, 16: 0.77} ``` -------------------------------- ### Train Custom DeepCAT Models Source: https://context7.com/s175573/deepcat/llms.txt Performs n-fold cross-validation training of CNN models on custom tumor and normal CDR3 datasets. Allows configuration of training parameters and automatic evaluation. ```APIDOC ## Train Custom DeepCAT Models ### Description Performs n-fold cross-validation training of CNN models on custom tumor and normal CDR3 datasets, with configurable training parameters and automatic evaluation. ### Method Python Function Call ### Endpoint N/A (Python function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python from DeepCAT import batchTrain tumor_file = 'TrainingData/TumorCDR3.txt' normal_file = 'TrainingData/NormalCDR3.txt' eval_tumor = 'TrainingData/TumorCDR3_test.txt' eval_normal = 'TrainingData/NormalCDR3_test.txt' PredictClassList, PredictLabelList, AUCDictList = batchTrain( ftumor=tumor_file, fnormal=normal_file, feval_tumor=eval_tumor, feval_normal=eval_normal, n=10, STEPs=20000, rate=0.33, dir_prefix='./tmp/' ) for auc_dict in AUCDictList: print(f"AUC scores by length: {auc_dict}") ``` ### Response #### Success Response (200) - **PredictClassList** (list) - Predicted class labels for evaluation data. - **PredictLabelList** (list) - True class labels for evaluation data. - **AUCDictList** (list) - A list of dictionaries, where each dictionary contains AUC scores for different CDR3 lengths (e.g., {12: 0.78, 13: 0.82}). #### Response Example ```json [ { "12": 0.78, "13": 0.82, "14": 0.85, "15": 0.81, "16": 0.77 } ] ``` ``` -------------------------------- ### Cluster TCR Sequences by Similarity using Python Source: https://context7.com/s175573/deepcat/llms.txt Identifies groups of similar TCR CDR3 sequences based on sequence alignment and V-gene information. This function is optimized for large-scale datasets using motif-based indexing. It requires the prepared CDR3 sequence data and V-gene scores as input. ```python from iSMARTm import ObtainCL # Cluster CDR3 sequences input_file = 'prepared_data/TestReal-sample.tsv' vscore_file = open('VgeneScores.txt') ``` -------------------------------- ### Predict Cancer Scores for TCR Sequences using Python Source: https://context7.com/s175573/deepcat/llms.txt Analyzes clustered CDR3 sequences from iSMART output files to generate cancer probability scores. It utilizes pre-trained CNN models for sequences of varying lengths (12-16 amino acids) and requires the input clustered CDR3 file and a directory containing checkpoint models. The output includes an overall cancer score and individual sequence scores. ```python from DeepCAT import PredictCancer # Predict cancer score for a single file input_file = 'SampleData/Cancer/TestReal-BR01B.tsv_ClusteredCDR3s_7.5.txt' checkpoint_dir = 'DeepCAT_CHKP' cancer_score, all_scores = PredictCancer(input_file, checkpoint_dir + '/tmp/') print(f"Overall cancer score: {cancer_score}") print(f"Individual sequence scores: {len(all_scores)} sequences analyzed") # Expected output: # Overall cancer score: 0.42 # Individual sequence scores: 1523 sequences analyzed ``` -------------------------------- ### Cluster TCR Sequences by Similarity (iSMART ObtainCL) Source: https://context7.com/s175573/deepcat/llms.txt Identifies groups of similar TCR CDR3 sequences using sequence alignment and V-gene information. Optimized with motif-based indexing for large-scale datasets. ```APIDOC ## Cluster TCR Sequences by Similarity ### Description Identifies groups of similar TCR CDR3 sequences using sequence alignment and V-gene information, optimized with motif-based indexing for large-scale datasets. ### Method Python Function Call ### Endpoint N/A (Python function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python from iSMARTm import ObtainCL input_file = 'prepared_data/TestReal-sample.tsv' vscore_file = open('VgeneScores.txt') # Placeholder for actual function call and parameters # ObtainCL(input_file, vscore_file, ...) ``` ### Response #### Success Response (200) Clustered TCR sequences. The exact output format depends on the function's implementation and specified parameters. #### Response Example ```json { "message": "Clustering complete. Results saved to output/clusters.txt" } ``` ``` -------------------------------- ### PredictEvaluation - Evaluate Model Performance (Python) Source: https://context7.com/s175573/deepcat/llms.txt Generates predictions and calculates Area Under the Curve (AUC) scores for each CDR3 length using trained CNN models. Optionally generates ROC curve visualizations. ```python from DeepCAT import PredictEvaluation import numpy as np # Evaluate model on test data # Assuming FeatureDict and LabelDict are obtained from GetFeatureLabels # eval_feature = FeatureDict # eval_labels = LabelDict # Dummy data for demonstration if FeatureDict and LabelDict are not available eval_feature = {13: {'x': np.random.rand(4, 19, 13), 'length': 13}} eval_labels = {13: np.array([1, 1, 0, 0])} PredictClass, PredictLabels, AUCDict = PredictEvaluation( EvalFeature=eval_feature, EvalLabels=eval_labels, makePlot=True, ID='test_run', dir_prefix='./tmp/' ) # Print AUC for each length for length in range(12, 17): if length in AUCDict and AUCDict[length] is not None: print(f"CDR3 length {length}: AUC = {AUCDict[length]:.3f}") # ROC curve saved to: ./tmp/ROC-test_run.png ``` -------------------------------- ### Predict Cancer Scores for TCR Sequences Source: https://context7.com/s175573/deepcat/llms.txt Analyzes clustered CDR3 sequences to generate cancer probability scores using pre-trained CNN models. Supports sequences of lengths 12-16 amino acids. ```APIDOC ## Predict Cancer Scores for TCR Sequences ### Description Analyzes clustered CDR3 sequences from iSMART output files and generates cancer probability scores using pre-trained CNN models for sequences of different lengths (12-16 amino acids). ### Method Python Function Call ### Endpoint N/A (Python function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python from DeepCAT import PredictCancer input_file = 'SampleData/Cancer/TestReal-BR01B.tsv_ClusteredCDR3s_7.5.txt' checkpoint_dir = 'DeepCAT_CHKP' cancer_score, all_scores = PredictCancer(input_file, checkpoint_dir + '/tmp/') print(f"Overall cancer score: {cancer_score}") print(f"Individual sequence scores: {len(all_scores)} sequences analyzed") ``` ### Response #### Success Response (200) - **cancer_score** (float) - The overall cancer probability score. - **all_scores** (list) - A list containing the cancer scores for individual sequences. #### Response Example ```json { "cancer_score": 0.42, "all_scores": "1523 sequences analyzed" } ``` ``` -------------------------------- ### AAindexEncoding - Encode CDR3 Sequences for CNN (Python) Source: https://context7.com/s175573/deepcat/llms.txt Encodes amino acid CDR3 sequences into numerical feature matrices using PCA-transformed AAindex biochemical properties. This is suitable for input into deep learning models like Convolutional Neural Networks (CNNs). ```python from DeepCAT import AAindexEncoding # Encode a CDR3 sequence cdr3_sequence = "CASSLGQAYEQYF" encoded_matrix = AAindexEncoding(cdr3_sequence) print(f"Encoded shape: {encoded_matrix.shape}") # Use in model prediction import numpy as np encoded_batch = np.array([AAindexEncoding(seq) for seq in ["CASSLGQAYEQYF", "CASSLAPGTYEQYF"]]) # Shape: (2, 19, 13) - batch of 2 sequences ``` -------------------------------- ### Process Raw TCR Repertoire Data Source: https://context7.com/s175573/deepcat/llms.txt Converts raw Adaptive Biotechnology TSV files into the format required for iSMART clustering. Filters non-productive sequences and selects top sequences by frequency. ```APIDOC ## Process Raw TCR Repertoire Data ### Description Converts raw Adaptive Biotechnology TSV files into the format required for iSMART clustering by filtering non-productive sequences and selecting top sequences by frequency. ### Method Python Script Execution ### Endpoint N/A (Python script) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import sys sys.argv = ['PrepareAdaptiveFile.py', 'input_data/', 'output_data/'] exec(open('PrepareAdaptiveFile.py').read()) ``` ### Response #### Success Response (200) Processed `.tsv` files in the specified output directory, formatted for iSMART clustering. Each file contains `amino_acid`, `v_gene`, and `frequency` columns. #### Response Example ``` # Example output file content (TestReal-sample.tsv): amino_acid,v_gene,frequency CASSDSRGNTGELAFF,TRAV1-2,1500 CATAGGSNTGELAFF,TRAV3-1,1200 ... ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.