Skip to content

Commit 5fdb3ce

Browse files
authored
Merge pull request #462 from GoekeLab/patch_bigsamples
Patch bigsamples
2 parents 4b1edc2 + 18b6a3a commit 5fdb3ce

File tree

2 files changed

+34
-30
lines changed

2 files changed

+34
-30
lines changed

R/bambu-extendAnnotations-utilityCombine.R

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ isore.combineTranscriptCandidates <- function(readClassList,
1717
combinedSplicedTranscripts <-
1818
combineSplicedTranscriptModels(readClassList, bpParameters,
1919
min.readCount, min.readFractionByGene,
20-
min.txScore.multiExon, min.txScore.singleExon, verbose) %>% data.table()
20+
min.txScore.multiExon, min.txScore.singleExon, verbose)
2121
combinedSplicedTranscripts[,confidenceType := "highConfidenceJunctionReads"]
2222
combinedUnsplicedTranscripts <-
2323
combineUnsplicedTranscriptModels(readClassList, bpParameters,
@@ -88,40 +88,34 @@ sequentialCombineFeatureTibble <- function(readClassList,
8888

8989
#' @noRd
9090
updateStartEndReadCount <- function(combinedFeatureTibble){
91-
combinedFeatureTibble <- combinedFeatureTibble %>%
92-
mutate(rowID = row_number())
93-
94-
startEndCountTibble <- combinedFeatureTibble %>%
95-
select(rowID, starts_with("start"),starts_with("end"),
96-
starts_with("readCount")) %>%
97-
tidyr::pivot_longer(c(starts_with("start"),starts_with("end"),
98-
starts_with("readCount")), names_to = c(".value","set"),
99-
names_pattern = "(.*)\\.(.)") %>%
100-
group_by(rowID) %>%
101-
mutate(sumReadCount = sum(readCount,na.rm = TRUE))
91+
setDT(combinedFeatureTibble)
92+
combinedFeatureTibble[, rowID := .I]
10293

103-
startTibble <- select(startEndCountTibble, rowID, start, readCount,
104-
sumReadCount) %>%
105-
arrange(start) %>%
106-
filter(cumsum(readCount)/sumReadCount>=0.5) %>%
107-
filter(row_number()==1)
108-
endTibble <- select(startEndCountTibble, rowID, end, readCount,
109-
sumReadCount) %>%
110-
arrange(end) %>%
111-
filter(cumsum(readCount)/sumReadCount>=0.5) %>%
112-
filter(row_number()==1)
94+
colNames <- colnames(combinedFeatureTibble)
95+
readCountCols <- sort(colNames[grep("^readCount", colNames)]) # to make sure it's ordered by sample name
96+
startCols <- sort(colNames[grep("^start", colNames)])
97+
endCols <- sort(colNames[grep("^end", colNames)])
11398

114-
combinedFeatureTibble <- combinedFeatureTibble %>%
115-
dplyr::select(intronStarts, intronEnds, chr, strand, maxTxScore,
116-
maxTxScore.noFit, NSampleReadCount, NSampleReadProp,
117-
NSampleTxScore, rowID) %>%
118-
full_join(select(startTibble, rowID, start), by = "rowID") %>%
119-
full_join(select(endTibble, rowID, end, readCount=sumReadCount),
120-
by = "rowID") %>%
121-
select(-rowID)
99+
startEndDt <- combinedFeatureTibble[,
100+
.(start = readCountWeightedMedian(.SD,x,y),
101+
end = readCountWeightedMedian(.SD,z,y),
102+
readCount = sum(.SD[,y], na.rm = TRUE)),
103+
by = rowID, env = I(list(x = startCols, y = readCountCols,z = endCols))]
104+
105+
combinedFeatureTibble <- startEndDt[combinedFeatureTibble[,.(intronStarts, intronEnds, chr, strand, maxTxScore,
106+
maxTxScore.noFit, NSampleReadCount, NSampleReadProp,
107+
NSampleTxScore, rowID)], on = "rowID"]
108+
combinedFeatureTibble[, rowID := NULL]
122109
return(combinedFeatureTibble)
123110
}
124111

112+
#' Function to get median value without interpolation using certain column names
113+
#' @noRd
114+
readCountWeightedMedian <- function(dt, valuevar, timesvar){
115+
sortVector <- rep(na.omit(unlist(dt[,..valuevar])),
116+
times = as.integer(na.omit(unlist(dt[,..timesvar]))))
117+
return(min(sortVector[sortVector>=quantile(sortVector, probs = 0.5)]))
118+
}
125119

126120

127121
#' Function to combine featureTibble and create the NSample variables

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,16 @@ rowData(se)
498498

499499
### Release History
500500

501+
**bambu v3.8.2**
502+
503+
Release date: 2025-02-06
504+
505+
Minor changes:
506+
507+
- Fix large number of samples [issue](https://github.com/GoekeLab/bambu/issues/450)
508+
- Fix denovo bug issue
509+
510+
501511
**bambu v3.2.5**
502512

503513
Release date: 2023-July-07

0 commit comments

Comments
 (0)