From 04246ecdc9422ceac5e1e6dfbe3fc671ec120dc9 Mon Sep 17 00:00:00 2001 From: bbimber Date: Thu, 30 Nov 2023 09:54:57 -0800 Subject: [PATCH] Update docs --- R/TCR.R | 43 +++++++++++++++-------------- man/CreateMergedTcrClonotypeFile.Rd | 5 +++- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/R/TCR.R b/R/TCR.R index 6d8795e..2953b69 100644 --- a/R/TCR.R +++ b/R/TCR.R @@ -60,8 +60,9 @@ DownloadAndAppendTcrClonotypes <- function(seuratObject, outPath = tempdir(), dr #' @param downloadPath The output filepath for per-dataset files #' @param allowMissing If true, samples missing data will be skipped. Otherwise, the function will fail. #' @param cellRangerType The type of cellranger data to download. Either all_contig_annotations.csv or filtered_contig_annotations.csv +#' @param dropConflictingVJSegments If true, any TRB rows with a TRA/D V/J segments will as dropped, as are TRA rows with TRB/G segments #' @export -CreateMergedTcrClonotypeFile <- function(seuratObj, outputFile, overwriteTcrTable = F, downloadPath = tempdir(), allowMissing = FALSE, cellRangerType = 'filtered_contig_annotations.csv'){ +CreateMergedTcrClonotypeFile <- function(seuratObj, outputFile, overwriteTcrTable = F, downloadPath = tempdir(), allowMissing = FALSE, cellRangerType = 'filtered_contig_annotations.csv', dropConflictingVJSegments = TRUE){ if (all(is.null(seuratObj[['BarcodePrefix']]))){ stop('Seurat object lacks BarcodePrefix column') } @@ -95,28 +96,30 @@ CreateMergedTcrClonotypeFile <- function(seuratObj, outputFile, overwriteTcrTabl dat$raw_clonotype_id <- ifelse(dat$is_cell == "true" & dat$productive == "true", yes = paste0(barcodePrefix,'_', dat$raw_clonotype_id), no = "") # Check for TRA/B segments that dont match the chain: - sel <- dat$chain == 'TRA' & grepl(dat$v_gene, pattern = 'BV|GV') - if (sum(sel) > 0) { - print(paste0('Dropping TRA rows with a BV/GV genes, total: ', sum(sel))) - dat <- dat[!sel] - } + if (dropConflictingVJSegments) { + sel <- dat$chain == 'TRA' & grepl(dat$v_gene, pattern = 'BV|GV') + if (sum(sel) > 0) { + print(paste0('Dropping TRA rows with a BV/GV genes, total: ', sum(sel))) + dat <- dat[!sel,] + } - sel <- dat$chain == 'TRA' & grepl(dat$j_gene, pattern = 'BJ|GJ') - if (sum(sel) > 0) { - print(paste0('Dropping TRA rows with a BJ/GJ genes, total: ', sum(sel))) - dat <- dat[!sel] - } + sel <- dat$chain == 'TRA' & grepl(dat$j_gene, pattern = 'BJ|GJ') + if (sum(sel) > 0) { + print(paste0('Dropping TRA rows with a BJ/GJ genes, total: ', sum(sel))) + dat <- dat[!sel,] + } - sel <- dat$chain == 'TRB' & grepl(dat$v_gene, pattern = 'AV|DV') - if (sum(sel) > 0) { - print(paste0('Dropping TRB rows with a AV/DV genes, total: ', sum(sel))) - dat <- dat[!sel] - } + sel <- dat$chain == 'TRB' & grepl(dat$v_gene, pattern = 'AV|DV') + if (sum(sel) > 0) { + print(paste0('Dropping TRB rows with a AV/DV genes, total: ', sum(sel))) + dat <- dat[!sel,] + } - sel <- dat$chain == 'TRB' & grepl(dat$v_gene, pattern = 'AJ|DJ') - if (sum(sel) > 0) { - print(paste0('Dropping TRB rows with a AJ/DJ genes, total: ', sum(sel))) - dat <- dat[!sel] + sel <- dat$chain == 'TRB' & grepl(dat$v_gene, pattern = 'AJ|DJ') + if (sum(sel) > 0) { + print(paste0('Dropping TRB rows with a AJ/DJ genes, total: ', sum(sel))) + dat <- dat[!sel,] + } } write.table(dat, diff --git a/man/CreateMergedTcrClonotypeFile.Rd b/man/CreateMergedTcrClonotypeFile.Rd index 18b2df7..f0aea46 100644 --- a/man/CreateMergedTcrClonotypeFile.Rd +++ b/man/CreateMergedTcrClonotypeFile.Rd @@ -10,7 +10,8 @@ CreateMergedTcrClonotypeFile( overwriteTcrTable = F, downloadPath = tempdir(), allowMissing = FALSE, - cellRangerType = "filtered_contig_annotations.csv" + cellRangerType = "filtered_contig_annotations.csv", + dropConflictingVJSegments = TRUE ) } \arguments{ @@ -25,6 +26,8 @@ CreateMergedTcrClonotypeFile( \item{allowMissing}{If true, samples missing data will be skipped. Otherwise, the function will fail.} \item{cellRangerType}{The type of cellranger data to download. Either all_contig_annotations.csv or filtered_contig_annotations.csv} + +\item{dropConflictingVJSegments}{If true, any TRB rows with a TRA/D V/J segments will as dropped, as are TRA rows with TRB/G segments} } \description{ Download TCR Clonotypes for all datasets in a seuratObj, update their cellbarcodes with barcodePrefix, and create a merged table