Skip to content

Commit d6a6bd9

Browse files
committed
resolve merge conflicts
2 parents 919371a + d2db984 commit d6a6bd9

7 files changed

Lines changed: 98 additions & 79 deletions

R/bambu-assignDist.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
#' @inheritParams bambu
33
#' @import data.table
44
#' @noRd
5-
assignReadClasstoTranscripts <- function(readClassList, annotations, isoreParameters,
5+
assignReadClasstoTranscripts <- function(readClassList, annotations, rcAssignmentParameters,
66
verbose, sampleMetadata, extractBarcodeUMI,
77
returnDistTable = FALSE, trackReads = TRUE) {
88
if (is.character(readClassList)) readClassList <- readRDS(file = readClassList)
9-
metadata(readClassList)$readClassDist <- calculateDistTable(readClassList, annotations, isoreParameters, verbose, returnDistTable)
9+
metadata(readClassList)$readClassDist <- calculateDistTable(readClassList, annotations, rcAssignmentParameters, verbose, returnDistTable)
1010
readClassList <- splitReadClassFiles(readClassList)
1111
readClassDt <- genEquiRCs(metadata(readClassList)$readClassDist, annotations, verbose)
1212
readClassDt$eqClass.match = match(readClassDt$eqClassById,metadata(readClassList)$eqClassById)

R/bambu-extendAnnotations-utilityExtend.R

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ filterTranscriptsByAnnotation <- function(rowDataCombined, annotationGrangesList
112112
} else if(is.null(NDR)) {
113113
NDR <- 0.5
114114
}
115-
filterSet <- (rowDataCombined$NDR <= NDR | rowDataCombined$readClassType == "equal:compatible")
115+
filterSet <- ((!is.na(rowDataCombined$NDR) & rowDataCombined$NDR <= NDR) | rowDataCombined$readClassType == "equal:compatible")
116116
lowConfidenceTranscripts <- combindRowDataWithRanges(
117117
rowDataCombined[!filterSet,],
118118
exonRangesCombined[!filterSet])
@@ -224,7 +224,7 @@ calculateNDROnTranscripts <- function(combinedTranscripts, useTxScore = FALSE){
224224
} else {
225225
combinedTranscripts$NDR <- calculateNDR(combinedTranscripts$maxTxScore, equal)
226226
}
227-
combinedTranscripts$NDR[combinedTranscripts$maxTxScore==-1] <- 1
227+
combinedTranscripts$NDR[combinedTranscripts$maxTxScore==-1] <- NA
228228
return(combinedTranscripts)
229229
}
230230

@@ -827,15 +827,14 @@ addGeneIdsToReadClassTable <- function(readClassTable, distTable,
827827
#' @description This function train a model for use on other data
828828
#' @param extendedAnnotations A GRangesList object produced from bambu(quant = FALSE) or rowRanges(se)
829829
#' @param NDR The maximum NDR for novel transcripts to be in extendedAnnotations (0-1). If not provided a recommended NDR is calculated.
830-
#' @param includeRef A boolean which if TRUE will also filter out reference annotations based on their NDR
831830
#' @param prefix A string which determines which transcripts are considered novel by bambu and will be filtered (by default = 'Bambu')
832831
#' @param baselineFDR a value between 0-1. Bambu uses this FDR on the trained model to recommend an equivilent NDR threshold to be used for the sample. By default, a baseline FDR of 0.1 is used. This does not impact the analysis if an NDR is set.
833832
#' @param defaultModels a bambu trained model object that bambu will use when fitReadClassModel==FALSE or the data is not suitable for training, defaults to the pretrained model in the bambu package
834833
#' Output - returns a similiar GRangesList object with entries swapped into or out of metadata(extendedAnnotations)$lowConfidenceTranscripts
835834
#' @details
836835
#' @return extendedAnnotations with a new NDR threshold
837836
#' @export
838-
setNDR <- function(extendedAnnotations, NDR = NULL, includeRef = FALSE, prefix = 'Bambu', baselineFDR = 0.1, defaultModels2 = defaultModels){
837+
setNDR <- function(extendedAnnotations, NDR = NULL, prefix = 'Bambu', baselineFDR = 0.1, defaultModels2 = defaultModels){
839838
#Check to see if the annotations/gtf are dervived from Bambu
840839
if(is.null(mcols(extendedAnnotations)$NDR)){
841840
warning("Annotations were not extended by Bambu (or the wrong prefix was provided). NDR can not be set")
@@ -852,17 +851,10 @@ setNDR <- function(extendedAnnotations, NDR = NULL, includeRef = FALSE, prefix =
852851
message("Recommending a novel discovery rate (NDR) of: ", NDR)
853852
}
854853

855-
#If reference annotations should be filtered too (note that reference annotations with no read support arn't filtered)
856-
if(includeRef){
857-
toRemove <- (!is.na(mcols(extendedAnnotations)$NDR) & mcols(extendedAnnotations)$NDR > NDR)
858-
toAdd <- !is.na(mcols(metadata(extendedAnnotations)$lowConfidenceTranscripts)$NDR) &
859-
mcols(metadata(extendedAnnotations)$lowConfidenceTranscripts)$NDR <= NDR
860-
} else {
861-
toRemove <- (mcols(extendedAnnotations)$NDR > NDR &
862-
grepl(prefix, mcols(extendedAnnotations)$TXNAME))
863-
toAdd <- (mcols(metadata(extendedAnnotations)$lowConfidenceTranscripts)$NDR <= NDR &
864-
grepl(prefix, mcols(metadata(extendedAnnotations)$lowConfidenceTranscripts)$TXNAME))
865-
}
854+
toRemove <- (mcols(extendedAnnotations)$NDR > NDR &
855+
grepl(prefix, mcols(extendedAnnotations)$TXNAME))
856+
toAdd <- (mcols(metadata(extendedAnnotations)$lowConfidenceTranscripts)$NDR <= NDR &
857+
grepl(prefix, mcols(metadata(extendedAnnotations)$lowConfidenceTranscripts)$TXNAME))
866858

867859
temp <- c(metadata(extendedAnnotations)$lowConfidenceTranscripts[!toAdd], extendedAnnotations[toRemove])
868860
extendedAnnotations <- c(extendedAnnotations[!toRemove], metadata(extendedAnnotations)$lowConfidenceTranscripts[toAdd])
@@ -880,7 +872,7 @@ setNDR <- function(extendedAnnotations, NDR = NULL, includeRef = FALSE, prefix =
880872

881873
#' Extend annotations by clusters
882874
#' @noRd
883-
isore.extendAnnotations.clusters <- function(readClassList, annotations, clusters, NDR, isoreParameters, stranded, bpParameters, fusionMode, verbose = FALSE){
875+
isore.extendAnnotations.clusters <- function(readClassList, annotations, clusters, NDR, discoveryParameters, stranded, bpParameters, fusionMode, verbose = FALSE){
884876
message("--- Start extending annotations for clusters ---")
885877
#if clustering is a csv, create a list with the barcodes for each cluster
886878
#csv must have two cols with heading barcode, cluster
@@ -912,21 +904,21 @@ isore.extendAnnotations.clusters <- function(readClassList, annotations, cluster
912904
rowData(rcf.filt)$startSD <- 0
913905
rowData(rcf.filt)$endSD <- 0
914906
rowData(rcf.filt)$readCount.posStrand <- 0
915-
thresholdIndex <- which(rowData(rcf.filt)$readCount>=isoreParameters$min.readCount)
916-
model <- trainBambu(rcf.filt, verbose = verbose, min.readCount = isoreParameters$min.readCount)
907+
thresholdIndex <- which(rowData(rcf.filt)$readCount>=discoveryParameters$min.readCount)
908+
model <- trainBambu(rcf.filt, verbose = verbose, min.readCount = discoveryParameters$min.readCount)
917909
txScore <- getTranscriptScore(rowData(rcf.filt)[thresholdIndex,], model,
918910
defaultModels)
919911
rowData(rcf.filt)$txScore <- rep(NA,nrow(rcf.filt))
920912
rowData(rcf.filt)$txScore[thresholdIndex] <- txScore
921913
#txScores = cbind(txScores, rowData(rcf.filt)$txScore)
922914
rcfs.clusters[[names(clusters)[i]]] <- rcf.filt
923915
annotations.clusters[[names(clusters)[i]]] <- bambu.extendAnnotations(list(rcf.filt), annotations, NDR,
924-
isoreParameters, stranded, bpParameters, fusionMode, verbose)
916+
discoveryParameters, stranded, bpParameters, fusionMode, verbose)
925917
}
926918
if(length(rcfs.clusters)>0){
927919
print("--- Merging all individual clusters ---")
928920
annotations.clusters[["merged"]] <- bambu.extendAnnotations(rcfs.clusters, annotations, NDR,
929-
isoreParameters, stranded, bpParameters, fusionMode, verbose)
921+
discoveryParameters, stranded, bpParameters, fusionMode, verbose)
930922
}
931923

932924
return(annotations.clusters)

R/bambu-extendAnnotations.R

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
#' @inheritParams bambu
44
#' @noRd
55
bambu.extendAnnotations <- function(readClassList, annotations, NDR,
6-
isoreParameters, stranded, bpParameters, fusionMode = FALSE, verbose = FALSE) {
6+
discoveryParameters, stranded, bpParameters, fusionMode = FALSE, verbose = FALSE) {
77
start.ptm_all <- proc.time()
88
combinedTxCandidates <- isore.combineTranscriptCandidates(readClassList,
99
stranded, ## stranded used for unspliced reduce
10-
min.readCount = isoreParameters[["min.readCount"]],
11-
min.readFractionByGene = isoreParameters[["min.readFractionByGene"]],
12-
min.txScore.multiExon = isoreParameters[["min.txScore.multiExon"]],
13-
min.txScore.singleExon = isoreParameters[["min.txScore.singleExon"]],
10+
min.readCount = discoveryParameters[["min.readCount"]],
11+
min.readFractionByGene = discoveryParameters[["min.readFractionByGene"]],
12+
min.txScore.multiExon = discoveryParameters[["min.txScore.multiExon"]],
13+
min.txScore.singleExon = discoveryParameters[["min.txScore.singleExon"]],
1414
bpParameters,
1515
verbose)
1616
end.ptm_all <- proc.time()
@@ -20,21 +20,21 @@ bambu.extendAnnotations <- function(readClassList, annotations, NDR,
2020
annotations <- isore.extendAnnotations(
2121
combinedTranscripts = combinedTxCandidates,
2222
annotationGrangesList = annotations,
23-
remove.subsetTx = isoreParameters[["remove.subsetTx"]],
24-
min.sampleNumber = isoreParameters[["min.sampleNumber"]],
23+
remove.subsetTx = discoveryParameters[["remove.subsetTx"]],
24+
min.sampleNumber = discoveryParameters[["min.sampleNumber"]],
2525
NDR = NDR,
26-
min.exonDistance = isoreParameters[["min.exonDistance"]],
27-
min.exonOverlap = isoreParameters[["min.exonOverlap"]],
26+
min.exonDistance = discoveryParameters[["min.exonDistance"]],
27+
min.exonOverlap = discoveryParameters[["min.exonOverlap"]],
2828
min.primarySecondaryDist =
29-
isoreParameters[['min.primarySecondaryDist']],
29+
discoveryParameters[['min.primarySecondaryDist']],
3030
min.primarySecondaryDistStartEnd =
31-
isoreParameters[['min.primarySecondaryDistStartEnd1']],
31+
discoveryParameters[['min.primarySecondaryDistStartEnd1']],
3232
min.readFractionByEqClass =
33-
isoreParameters[['min.readFractionByEqClass']],
33+
discoveryParameters[['min.readFractionByEqClass']],
3434
fusionMode = fusionMode,
35-
prefix = isoreParameters[["prefix"]],
36-
baselineFDR = isoreParameters[["baselineFDR"]],
37-
defaultModels = isoreParameters[["defaultModels"]],
35+
prefix = discoveryParameters[["prefix"]],
36+
baselineFDR = discoveryParameters[["baselineFDR"]],
37+
defaultModels = discoveryParameters[["defaultModels"]],
3838
verbose = verbose)
3939
end.ptm_all <- proc.time()
4040
if (verbose) message("extend annotations in ",

R/bambu-processReads.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#' @noRd
1515
bambu.processReads <- function(reads, annotations, genomeSequence,
1616
readClass.outputDir=NULL, yieldSize=1000000, bpParameters,
17-
stranded=FALSE, verbose=FALSE, isoreParameters = setIsoreParameters(NULL),
17+
stranded=FALSE, verbose=FALSE, discoveryParameters = setDiscoveryParameters(NULL),
1818
processByChromosome = FALSE, processByBam = TRUE, trackReads = trackReads, fusionMode = fusionMode,
1919
extractBarcodeUMI = FALSE, dedupUMI = FALSE) {
2020
genomeSequence <- checkInputSequence(genomeSequence)
@@ -40,11 +40,11 @@ bambu.processReads <- function(reads, annotations, genomeSequence,
4040
reads <- BamFileList(reads, yieldSize = yieldSize)
4141
names(reads) <- tools::file_path_sans_ext(BiocGenerics::basename(reads))
4242
}
43-
min.readCount <- isoreParameters[["min.readCount"]]
44-
fitReadClassModel <- isoreParameters[["fitReadClassModel"]]
45-
defaultModels <- isoreParameters[["defaultModels"]]
46-
returnModel <- isoreParameters[["returnModel"]]
47-
min.exonOverlap <- isoreParameters[["min.exonOverlap"]]
43+
min.readCount <- discoveryParameters[["min.readCount"]]
44+
fitReadClassModel <- discoveryParameters[["fitReadClassModel"]]
45+
defaultModels <- discoveryParameters[["defaultModels"]]
46+
returnModel <- discoveryParameters[["returnModel"]]
47+
min.exonOverlap <- discoveryParameters[["min.exonOverlap"]]
4848

4949
if(processByBam){
5050
readClassList <- bplapply(seq_along(reads), function(i) {

R/bambu-quantify.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
#' @inheritParams bambu
33
#' @import data.table
44
#' @noRd
5-
bambu.quantify <- function(readClassDt, countMatrix, incompatibleCountMatrix, txid.index, GENEIDs, emParameters,
5+
bambu.quantify <- function(readClassDt, countMatrix, incompatibleCountMatrix, txid.index, GENEIDs, emParameters,
66
trackReads = FALSE, returnDistTable = FALSE,
7-
verbose = FALSE, isoreParameters = setIsoreParameters(NULL)) {
7+
verbose = FALSE) {
88
start.ptm <- proc.time()
99
readClassDt$nobs = countMatrix[readClassDt$eqClass.match]
1010
readClassDt$nobs[is.na(readClassDt$nobs)] = 0

0 commit comments

Comments
 (0)