charles-plessy / CAGEr

Mirror of Bioconductor's CAGEr package repository
https://bioconductor.org/packages/CAGEr
6 stars 4 forks source link

Suggestion: a new, maybe private, acessor CTSScoordinatesGRL #99

Open charles-plessy opened 1 year ago

charles-plessy commented 1 year ago

I am wondering about adding a new accessor that returns a GRangesList of CTSS objects with the score of their sample. In these objects the non-expressed CTSSes are not represented, therefore the data can not be represented as a DataFrame or a SummarizedExperiment since each sample is a vector of a different length.

CTSScoordinatesGRL <- function(object) {
  grl <- lapply(sampleLabels(object), CTSStagCountGR, object = object) |> GRangesList()
  names(grl) <- unname(sampleLabels(object))
  # Also pass the original colData?
  grl@metadata$colData <- colData(object)
  grl
}

This function would be useful when looping over CTSSes. I am not sure if it is worth to make it public or better to keep it private.

A similar function may be useful for consensus clusters.

The tagClustersGR function's name is actually misleading, as it also returns a GRL. But let's not change that.

charles-plessy commented 1 year ago

However …

consensusClustersGRL <- function(object) {
  grl <- lapply(sampleLabels(object), consensusClustersGR, object = object) |> GRangesList()
  names(grl) <- unname(sampleLabels(object))
  # Also pass the original colData?
  grl@metadata$colData <- colData(object)
  grl
}
clustersGRL <- consensusClustersGRL(ce_SL)

##  Error in validObject(ans) : 
##   invalid class "ConsensusClusters" object: Consensus clusters must not overlap with each ## other.

I think that this is because GRangesList objects may be GRanges behind the scenes.