-
Notifications
You must be signed in to change notification settings - Fork 28
Summarise by exon #558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: devel_pre_v4
Are you sure you want to change the base?
Summarise by exon #558
Changes from 2 commits
b4277ca
dbe2af9
1664813
eefbe16
1039570
1d99a73
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,81 @@ | ||||||||||||
| #' Summarise transcript expression to exon-level expression | ||||||||||||
| #' @title summarise by exon | ||||||||||||
| #' @param se a \code{SummarizedExperiment} object from \code{\link{bambu}} | ||||||||||||
| #' @return A \code{RangedSummarizedExperiment} with exon-level counts | ||||||||||||
| #' @details Counts are summed across all transcripts that share the same exon | ||||||||||||
| #' (defined by identical seqnames, start, end, and strand). The returned | ||||||||||||
| #' counts therefore represent the total evidence attributed to each unique | ||||||||||||
| #' exonic locus across all overlapping transcripts. | ||||||||||||
| #' @import data.table | ||||||||||||
| #' @importFrom Matrix sparseMatrix | ||||||||||||
| #' @importFrom SummarizedExperiment assays rowRanges rowData colData SummarizedExperiment | ||||||||||||
| #' @importFrom GenomicRanges GRanges seqnames start end strand | ||||||||||||
| #' @importFrom IRanges IRanges | ||||||||||||
| #' @export | ||||||||||||
| summariseByExon <- function(se) { | ||||||||||||
| # Unlist GRangesList: one row per exon-transcript combination | ||||||||||||
| exonRanges <- unlist(rowRanges(se), use.names = TRUE) | ||||||||||||
|
|
||||||||||||
| # Build a data.table of exon-transcript pairs | ||||||||||||
| txNames <- rownames(se) | ||||||||||||
| exonDt <- data.table( | ||||||||||||
| TXNAME = names(exonRanges), | ||||||||||||
|
||||||||||||
| exonDt <- data.table( | |
| TXNAME = names(exonRanges), | |
| exonTxNames <- rep(txNames, lengths(rowRanges(se))) | |
| exonDt <- data.table( | |
| TXNAME = exonTxNames, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think original code is good, names(exonRanges) is simpler
Copilot
AI
Apr 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SummarizedExperiment(assays = ...) is passed a base list, but the rest of the codebase consistently uses SimpleList(...) for assays when constructing SummarizedExperiment objects. Using SimpleList here would keep the return value consistent with other constructors and avoid any subtle differences in downstream behavior.
| assays = list(counts = exonCounts), | |
| assays = S4Vectors::SimpleList(counts = exonCounts), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new exported function introduces non-trivial aggregation logic (mapping transcript-by-exon membership and summing counts) but there are no accompanying unit tests. Please add a
testthattest that runssummariseByExon()on an existingextdataseobject and asserts basic invariants (e.g., output class, column data preserved, and a few known exon-level totals).