Skip to contents

Sums the values of all isoforms of a gene. A length assay is combined as the abundance-weighted mean when an abundance assay is supplied in the same list (the tximport convention). This is the function used by gene_assays() and can be called directly on matrices.

Usage

summarize_to_gene(x, tx_to_gene)

Arguments

x

A numeric matrix (transcripts in rows) or a named list of such matrices sharing row names.

tx_to_gene

Data frame with transcript_id and gene_id columns.

Value

A matrix, or a named list of matrices, with genes in rows.

Examples

iso <- example_isoformic()
g <- summarize_to_gene(assay(iso, "abundance"), tx_to_gene(iso))
head(g)
#>                    SRR11498039 SRR11498040 SRR11498041 SRR11498042 SRR11498043
#> ENSG00000005007.12    3253.512    2563.848    2656.175    3295.886    4497.997
#> ENSG00000005206.17    1727.018    1515.008    1807.224    1551.435     986.158
#> ENSG00000007384.15    1970.727    1612.095    2188.516    2179.135    1910.157
#> ENSG00000007541.16     550.154     526.270     745.990     723.957     498.251
#> ENSG00000008838.20    1058.643    1018.991     978.694    1061.083    1152.704
#> ENSG00000009413.16     724.057     599.019     675.888     696.338     419.116
#>                    SRR11498044 SRR11498045 SRR11498046 SRR11498063 SRR11498064
#> ENSG00000005007.12    4732.194    2686.639    3904.654    3335.450    3699.352
#> ENSG00000005206.17    1850.509     609.902    1492.657    2069.531    2048.620
#> ENSG00000007384.15    2708.052    2264.347    3182.521    2966.487    3382.728
#> ENSG00000007541.16     962.738     245.692     969.690     958.960    1220.914
#> ENSG00000008838.20    1700.362    1002.685    1392.596    1419.984    1543.717
#> ENSG00000009413.16     824.227    1010.559    1235.516     837.198    1042.775
#>                    SRR11498065 SRR11498066 SRR11498067 SRR11498068 SRR11498069
#> ENSG00000005007.12    2405.434    2521.298    2951.488    2412.240    3125.850
#> ENSG00000005206.17    1502.081    1117.840    1625.626    1202.581    1971.119
#> ENSG00000007384.15    2154.739    1830.455    2151.931    2016.009    2502.582
#> ENSG00000007541.16     758.946     604.632     712.162     563.255     840.969
#> ENSG00000008838.20    1133.716     996.395    1158.077     867.589    1375.700
#> ENSG00000009413.16     981.165     736.211     844.466     923.871     996.592
#>                    SRR11498070 SRR11498071 SRR11498072 SRR11498073 SRR11498074
#> ENSG00000005007.12    4497.310    2265.091    3065.700    2692.038    3329.921
#> ENSG00000005206.17    2303.939    1076.992    1372.618    1172.162    1693.740
#> ENSG00000007384.15    3482.066    1743.023    2339.072    2031.263    2347.569
#> ENSG00000007541.16    1170.131     528.531     626.839     608.772     803.845
#> ENSG00000008838.20    1783.556     927.626     953.281    1095.061    1114.967
#> ENSG00000009413.16    1375.634     715.627     462.376     620.009     733.193
#>                    SRR11498075 SRR11498076 SRR11498077 SRR11498078 SRR11498079
#> ENSG00000005007.12    3200.173    3211.790    2886.842    2522.062    3415.826
#> ENSG00000005206.17    1728.208    1544.569    1448.556    1375.868    1866.532
#> ENSG00000007384.15    2321.575    2703.154    2317.905    2011.830    3311.084
#> ENSG00000007541.16     701.155     760.047     646.552     600.129     922.636
#> ENSG00000008838.20    1117.793    1124.630    1119.471     952.758    1333.459
#> ENSG00000009413.16     924.570     742.140     629.304     927.810    1091.680