-
Notifications
You must be signed in to change notification settings - Fork 28
Tidy readClassList and quantData #565
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
Open
lingminhao
wants to merge
25
commits into
devel_pre_v4
Choose a base branch
from
tidy_readClassFile_quantData
base: devel_pre_v4
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
bf32099
convert quantData into an object storing list of S4 object
lingminhao abc7411
Refactor quantData: remove countMatrix and replace with list columns …
lingminhao ce1259e
remove redundant stored data in quantData
lingminhao 9ce39c1
add readToTranscriptMaps to final se when trackReads is TRUE
lingminhao c7ed6d3
Add gene and unique count matrix helpers from quantData
lingminhao ce96f7b
add colnames and colData to readClassList
lingminhao ed08825
name readClassList, quantData, readToTranscriptMaps, and distTables l…
lingminhao 7f56d21
add nonuniqueCounts to quantData & se.
lingminhao a30a5fd
refactor generateUniqueCountsFromQuantData to return SummarizedExperi…
lingminhao acf4a45
refactor transcriptToGeneExpression to compute gene counts as uniqueC…
lingminhao 5366795
refactor constructQuantData class using claude
lingminhao e895bee
not storing nonuniqueCountMatrix in quantData
lingminhao 572ef70
revert transcriptToGeneExpression & remove nonuniqueCounts from final SE
lingminhao 4277d65
add seType tag to SE objects
lingminhao 8a6cb1e
remove summarizeExpression.R
lingminhao 192de76
fix gene index mapping in generateIncompatibleCounts
lingminhao 4368f7a
reorder incompatibleCounts to annotation order
lingminhao b7a33ba
pass incompatibleCounts as single-column matrix to bambu.quantify
lingminhao 219b2b1
convert clusters barcode string to integer
lingminhao f0e5658
define SE_TYPES vocabulary and document quantData slots
lingminhao bf99de5
tidy up code
lingminhao 97018f7
fix duplicated sample name prefix in SE colnames for demultiplexed data
lingminhao ac7cd4f
move generateNonUniqueCountMatrix to transcriptToGeneExpression_utili…
lingminhao 3012744
Merge branch 'devel_pre_v4' into tidy_readClassFile_quantData
lingminhao 53d3728
fix: correct wrong variable names from merge conflict
lingminhao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| #' @import methods | ||
| #' @importFrom Matrix Matrix | ||
| #' @importFrom data.table data.table | ||
| #' @importClassesFrom Matrix Matrix | ||
| #' @importClassesFrom data.table data.table | ||
|
|
||
| # Valid values for metadata(se)$seType, which identifies the SE variant: | ||
| # EMCounts — transcript-level SE with EM-estimated counts (main bambu output) | ||
| # geneCounts — gene-level SE derived by collapsing transcript counts | ||
| # uniqueCounts — transcript-level SE with uniquely-assigned counts only, no EM | ||
| SE_TYPES <- c( | ||
| EMCounts = "EMCounts", | ||
| geneCounts = "geneCounts", | ||
| uniqueCounts = "uniqueCounts" | ||
| ) | ||
|
|
||
| # quantData holds per-sample intermediate results from the assignDist step. | ||
| # distTable and readToTranscriptMap are optional: populated only when | ||
| # returnDistTable=TRUE or trackReads=TRUE respectively, and lifted into | ||
| # metadata(countsSe) at the end of bambu(). | ||
| setClass("quantData", | ||
| slots = c( | ||
| sampleData = "data.frame", # per-sample metadata (id, sampleName) | ||
| readClassDt = "data.table", # read-class-level count and assignment data | ||
| incompatibleCounts = "sparseMatrix", # counts of reads incompatible with any annotation | ||
| distTable = "ANY", # read-class-to-transcript compatibility table (DataFrame or NULL) | ||
| readToTranscriptMap = "ANY" # per-read assignment to transcripts (tibble or NULL) | ||
| ), | ||
| prototype = list( | ||
| sampleData = data.frame(id = integer(), sampleName = character()), | ||
| readClassDt = data.table::data.table() | ||
| ), | ||
| validity = function(object) { | ||
| errs <- character() | ||
| if (!all(c("id", "sampleName") %in% names(object@sampleData))) | ||
| errs <- c(errs, "sampleData must have columns 'id' and 'sampleName'") | ||
| if (!is.null(object@distTable) && !is(object@distTable, "DataFrame")) | ||
| errs <- c(errs, "distTable must be a DataFrame or NULL") | ||
| if (!is.null(object@readToTranscriptMap) && !is(object@readToTranscriptMap, "tbl_df")) | ||
| errs <- c(errs, "readToTranscriptMap must be a tibble or NULL") | ||
| if (length(errs)) errs else TRUE | ||
| }) | ||
|
|
||
| #' Construct a quantData object | ||
| #' @noRd | ||
| constructQuantData <- function(sampleData, readClassDt, | ||
| incompatibleCounts, | ||
| distTable = NULL, | ||
| readToTranscriptMap = NULL) { | ||
| new("quantData", | ||
| sampleData = sampleData, | ||
| readClassDt = readClassDt, | ||
| incompatibleCounts = incompatibleCounts, | ||
| distTable = distTable, | ||
| readToTranscriptMap = readToTranscriptMap) | ||
| } | ||
|
|
||
| #' @noRd | ||
| setGeneric("getSampleData", function(x) standardGeneric("getSampleData")) | ||
| #' @noRd | ||
| setGeneric("getReadClassDt", function(x) standardGeneric("getReadClassDt")) | ||
| #' @noRd | ||
| setGeneric("getIncompatibleCounts", function(x) standardGeneric("getIncompatibleCounts")) | ||
| #' @noRd | ||
| setGeneric("getDistTable", function(x) standardGeneric("getDistTable")) | ||
| #' @noRd | ||
| setGeneric("getReadToTranscriptMap", function(x) standardGeneric("getReadToTranscriptMap")) | ||
|
|
||
| #' @noRd | ||
| setMethod("getSampleData", "quantData", function(x) x@sampleData) | ||
| #' @noRd | ||
| setMethod("getReadClassDt", "quantData", function(x) x@readClassDt) | ||
| #' @noRd | ||
| setMethod("getIncompatibleCounts", "quantData", function(x) x@incompatibleCounts) | ||
| #' @noRd | ||
| setMethod("getDistTable", "quantData", function(x) x@distTable) | ||
| #' @noRd | ||
| setMethod("getReadToTranscriptMap", "quantData", function(x) x@readToTranscriptMap) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.