@@ -338,15 +338,17 @@ merge_wrapper <- function(x,y){
338338}
339339
340340# ' Add exon rank and exon endRank to GRangesList
341- # ' @param grlist A GRangesList object
342- # ' @param strand_info Character vector of strand information ("+", "-", or "*")
343- # ' @return A list with two elements: exon_rank and exon_endRank
341+ # ' @param size_list A list of integers representing the number of exons per transcript.
342+ # ' Typically obtained from elementNROWS(grlist) or width(partitioning).
343+ # ' @param strand_info Character vector of strand information ("+", "-", or "*") with
344+ # ' length equal to length(size_list). One strand value per transcript.
345+ # ' @return A list with two elements: exon_rank and exon_endRank, both as lists of integer vectors
344346# ' @details This function creates exon rankings based on strand information.
345347# ' For negative strand transcripts, exon_rank is reversed. exon_endRank is
346348# ' always the reverse of exon_rank.
347349# ' @noRd
348- createExonRankings <- function (grlist , strand_info ) {
349- exon_rank <- lapply(elementNROWS( grlist ) , seq , from = 1 )
350+ createExonRankings <- function (size_list , strand_info ) {
351+ exon_rank <- lapply(size_list , seq , from = 1 )
350352 negative_strand <- which(strand_info == " -" )
351353 exon_rank [negative_strand ] <- lapply(exon_rank [negative_strand ], rev )
352354 exon_endRank <- lapply(exon_rank , rev )
@@ -360,11 +362,16 @@ createExonRankings <- function(grlist, strand_info) {
360362# ' @return A data.table object
361363# ' @details This function provides a convenient way to extract rowData from
362364# ' a SummarizedExperiment object and convert it to a data.table in one step.
365+ # ' If columns are specified, they will be validated against available columns.
363366# ' @importFrom data.table data.table
364367# ' @noRd
365368extractRowDataAsDataTable <- function (se , columns = NULL , keep.rownames = FALSE ) {
366369 rd <- as.data.frame(rowData(se ))
367370 if (! is.null(columns )) {
371+ missing_cols <- setdiff(columns , colnames(rd ))
372+ if (length(missing_cols ) > 0 ) {
373+ stop(" Columns not found in rowData: " , paste(missing_cols , collapse = " , " ))
374+ }
368375 rd <- rd [, columns , drop = FALSE ]
369376 }
370377 return (data.table(rd , keep.rownames = keep.rownames ))
0 commit comments