Skip to content

Commit

Permalink
Fully support 10x multi-assay data (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
bbimber authored Feb 15, 2023
1 parent 35b8dd9 commit f4ac351
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion R/CellHashing.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion R/Preprocessing.R
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
}

Expand Down
6 changes: 3 additions & 3 deletions inst/rmd/cellhashR.rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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')
}
Expand Down
5 changes: 4 additions & 1 deletion man/CallAndGenerateReport.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f4ac351

Please sign in to comment.