R/methods.R
, R/methods_SE.R
aggregate_duplicates-methods.Rd
aggregate_duplicates() takes as input A `tbl` (with at least three columns for sample, feature and transcript abundance) or `SummarizedExperiment` (more convenient if abstracted to tibble with library(tidySummarizedExperiment)) and returns a consistent object (to the input) with aggregated transcripts that were duplicated.
aggregate_duplicates(
.data,
.sample = NULL,
.transcript = NULL,
.abundance = NULL,
aggregation_function = sum,
keep_integer = TRUE
)
# S4 method for class 'spec_tbl_df'
aggregate_duplicates(
.data,
.sample = NULL,
.transcript = NULL,
.abundance = NULL,
aggregation_function = sum,
keep_integer = TRUE
)
# S4 method for class 'tbl_df'
aggregate_duplicates(
.data,
.sample = NULL,
.transcript = NULL,
.abundance = NULL,
aggregation_function = sum,
keep_integer = TRUE
)
# S4 method for class 'tidybulk'
aggregate_duplicates(
.data,
.sample = NULL,
.transcript = NULL,
.abundance = NULL,
aggregation_function = sum,
keep_integer = TRUE
)
# S4 method for class 'SummarizedExperiment'
aggregate_duplicates(
.data,
.sample = NULL,
.transcript = NULL,
.abundance = NULL,
aggregation_function = sum,
keep_integer = TRUE
)
# S4 method for class 'RangedSummarizedExperiment'
aggregate_duplicates(
.data,
.sample = NULL,
.transcript = NULL,
.abundance = NULL,
aggregation_function = sum,
keep_integer = TRUE
)
A `tbl` (with at least three columns for sample, feature and transcript abundance) or `SummarizedExperiment` (more convenient if abstracted to tibble with library(tidySummarizedExperiment))
The name of the sample column
The name of the transcript/gene column
The name of the transcript/gene abundance column
A function for counts aggregation (e.g., sum, median, or mean)
A boolean. Whether to force the aggregated counts to integer
A consistent object (to the input) with aggregated transcript abundance and annotation
A consistent object (to the input) with aggregated transcript abundance and annotation
A consistent object (to the input) with aggregated transcript abundance and annotation
A consistent object (to the input) with aggregated transcript abundance and annotation
A `SummarizedExperiment` object
A `SummarizedExperiment` object
`r lifecycle::badge("maturing")`
This function aggregates duplicated transcripts (e.g., isoforms, ensembl). For example, we often have to convert ensembl symbols to gene/transcript symbol, but in doing so we have to deal with duplicates. `aggregate_duplicates` takes a tibble and column names (as symbols; for `sample`, `transcript` and `count`) as arguments and returns a tibble with aggregate transcript with the same name. All the rest of the column are appended, and factors and boolean are appended as characters.
Underlying custom method: data |> filter(n_aggr > 1) |> group_by(!!.sample,!!.transcript) |> dplyr::mutate(!!.abundance := !!.abundance |> aggregation_function())
# Create a aggregation column
se_mini = tidybulk::se_mini
SummarizedExperiment::rowData(se_mini )$gene_name = rownames(se_mini )
aggregate_duplicates(
se_mini,
.transcript = gene_name
)
#> tidybulk says: your object does not have duplicates along the gene_name column. The input dataset is returned.
#> class: SummarizedExperiment
#> dim: 527 5
#> metadata(0):
#> assays(1): count
#> rownames(527): ABCB4 ABCB9 ... ZNF324 ZNF442
#> rowData names(2): entrez gene_name
#> colnames(5): SRR1740034 SRR1740035 SRR1740043 SRR1740058 SRR1740067
#> colData names(5): Cell.type time condition days dead