diff --git a/R/CellHashing.R b/R/CellHashing.R index e9f6752..d3867ec 100644 --- a/R/CellHashing.R +++ b/R/CellHashing.R @@ -703,10 +703,11 @@ GetExampleMarkdown <- function(dest) { #' @param molInfoFile An optional path to the 10x molecule_info.h5. #' @param majorityConsensusThreshold This applies to calculating a consensus call when multiple algorithms are used. If NULL, then all non-negative calls must agree or that cell is marked discordant. If non-NULL, then the number of algorithms returning the top call is divided by the total number of non-negative calls. If this ratio is above the majorityConsensusThreshold, that value is selected. For example, when majorityConsensusThreshold=0.6 and the calls are: HTO-1,HTO-1,Negative,HTO-2, then 2/3 calls are for HTO-1, giving 0.66. This is greater than the majorityConsensusThreshold of 0.6, so HTO-1 is returned. This can be useful for situations where most algorithms agree, but a single caller fails. #' @param callerDisagreementThreshold If provided, the agreement rate will be calculated between each caller and the simple majority call, ignoring discordant and no-call cells. If any caller has an disagreement rate above this threshold, it will be dropped and the consensus call re-calculated. The general idea is to drop a caller that is systematically discordant. +#' @param datatypeName For output from CellRanger >= 3.0 with multiple data types, the result of Seurat::Read10X is a list. You need to supply the name of the Antibody Capture #' @param title A title for the HTML report #' @importFrom rmdformats html_clean #' @export -CallAndGenerateReport <- function(rawCountData, reportFile, callFile, rawFeatureMatrixH5 = NULL, barcodeWhitelist = NULL, barcodeBlacklist = c('no_match', 'total_reads', 'unmapped'), cellbarcodeWhitelist = 'inputMatrix', methods = c('bff_cluster', 'gmm_demux', 'dropletutils'), methodsForConsensus = NULL, minCountPerCell = 5, title = NULL, metricsFile = NULL, rawCountsExport = NULL, skipNormalizationQc = FALSE, keepMarkdown = FALSE, molInfoFile = NULL, majorityConsensusThreshold = NULL, callerDisagreementThreshold = NULL, doTSNE = TRUE) { +CallAndGenerateReport <- function(rawCountData, reportFile, callFile, rawFeatureMatrixH5 = NULL, barcodeWhitelist = NULL, barcodeBlacklist = c('no_match', 'total_reads', 'unmapped'), cellbarcodeWhitelist = 'inputMatrix', methods = c('bff_cluster', 'gmm_demux', 'dropletutils'), methodsForConsensus = NULL, minCountPerCell = 5, title = NULL, metricsFile = NULL, rawCountsExport = NULL, skipNormalizationQc = FALSE, keepMarkdown = FALSE, molInfoFile = NULL, majorityConsensusThreshold = NULL, callerDisagreementThreshold = NULL, doTSNE = TRUE, datatypeName = NULL) { rmd <- system.file("rmd/cellhashR.rmd", package = "cellhashR") if (!file.exists(rmd)) { stop(paste0('Unable to find file: ', rmd)) diff --git a/R/Preprocessing.R b/R/Preprocessing.R index d0fde9c..ff25771 100644 --- a/R/Preprocessing.R +++ b/R/Preprocessing.R @@ -116,7 +116,7 @@ ProcessCountMatrix <- function(rawCountData=NA, minCountPerCell = 5, barcodeWhit print(paste0('Using: ', datatypeName)) barcodeData <- barcodeData[[datatypeName]] } else { - print('The data were generated from multiple data types, which are listed above. Please use the datatypeName argument to specify which assay to use') + stop('The data were generated from multiple data types, which are listed above. Please use the datatypeName argument to specify which assay to use') } } diff --git a/inst/rmd/cellhashR.rmd b/inst/rmd/cellhashR.rmd index af47022..f44bcdc 100644 --- a/inst/rmd/cellhashR.rmd +++ b/inst/rmd/cellhashR.rmd @@ -39,13 +39,13 @@ if (!file.exists(rawCountData)) { stop(paste0('Could not find rawCountData: ', rawCountData)) } -optionalVars <- c('barcodeWhitelist', 'barcodeBlacklist', 'cellbarcodeWhitelist', 'minCountPerCell', 'metricsFile', 'rawCountsExport', 'molInfoFile', 'rawFeatureMatrixH5', 'methodsForConsensus', 'majorityConsensusThreshold', 'callerDisagreementThreshold', 'doTSNE') +optionalVars <- c('barcodeWhitelist', 'barcodeBlacklist', 'cellbarcodeWhitelist', 'minCountPerCell', 'metricsFile', 'rawCountsExport', 'molInfoFile', 'rawFeatureMatrixH5', 'methodsForConsensus', 'majorityConsensusThreshold', 'callerDisagreementThreshold', 'doTSNE', 'datatypeName') for (v in optionalVars) { if (!exists(v)) { if (v == 'minCountPerCell') { minCountPerCell <- 5 } else if (v == 'doTSNE') { - doTSNE <- TRUE + t <- TRUE } else { assign(v, NULL) } @@ -72,7 +72,7 @@ if (!is.null(metricsFile)) { ```{r QC} -barcodeData <- ProcessCountMatrix(rawCountData = rawCountData, minCountPerCell = minCountPerCell, barcodeWhitelist = barcodeWhitelist, barcodeBlacklist = barcodeBlacklist, cellbarcodeWhitelist = cellbarcodeWhitelist, saveOriginalCellBarcodeFile = saveOriginalCellBarcodeFile, metricsFile = metricsFile) +barcodeData <- ProcessCountMatrix(rawCountData = rawCountData, minCountPerCell = minCountPerCell, barcodeWhitelist = barcodeWhitelist, barcodeBlacklist = barcodeBlacklist, cellbarcodeWhitelist = cellbarcodeWhitelist, saveOriginalCellBarcodeFile = saveOriginalCellBarcodeFile, metricsFile = metricsFile, datatypeName = datatypeName) if (nrow(barcodeData) == 0) { stop('No passing barcodes') } diff --git a/man/CallAndGenerateReport.Rd b/man/CallAndGenerateReport.Rd index 28d6b8a..443bad1 100644 --- a/man/CallAndGenerateReport.Rd +++ b/man/CallAndGenerateReport.Rd @@ -23,7 +23,8 @@ CallAndGenerateReport( molInfoFile = NULL, majorityConsensusThreshold = NULL, callerDisagreementThreshold = NULL, - doTSNE = TRUE + doTSNE = TRUE, + datatypeName = NULL ) } \arguments{ @@ -64,6 +65,8 @@ CallAndGenerateReport( \item{callerDisagreementThreshold}{If provided, the agreement rate will be calculated between each caller and the simple majority call, ignoring discordant and no-call cells. If any caller has an disagreement rate above this threshold, it will be dropped and the consensus call re-calculated. The general idea is to drop a caller that is systematically discordant.} \item{doTSNE}{If true, tSNE will be run on results as part of QC. This can be memory intensive and is not strictly needed, so it can be skipped if desired.} + +\item{datatypeName}{For output from CellRanger >= 3.0 with multiple data types, the result of Seurat::Read10X is a list. You need to supply the name of the Antibody Capture} } \description{ Runs the default processing pipeline