Transform Copy Number Table

transform_seg_table(
  data,
  genome_build = c("hg19", "hg38", "T2T", "mm10", "mm9", "ce11"),
  ref_type = c("cytoband", "gene"),
  values_fill = NA,
  values_fn = function(x, ...) {
     round(mean(x, ...))
 },
  resolution_factor = 1L
)

Arguments

data

a CopyNumber object or a data.frame containing at least 'chromosome', 'start', 'end', 'segVal', 'sample' these columns.

genome_build

genome build version, used when data is a data.frame, should be 'hg19' or 'hg38'.

ref_type

annotation data type used for constructing matrix.

values_fill

Optionally, a (scalar) value that specifies what each value should be filled in with when missing.

This can be a named list if you want to apply different fill values to different value columns.

values_fn

Optionally, a function applied to the value in each cell in the output. You will typically use this when the combination of id_cols and names_from columns does not uniquely identify an observation.

This can be a named list if you want to apply different aggregations to different values_from columns.

resolution_factor

an integer to control the resolution. When it is 1 (default), compute frequency in each cytoband. When it is 2, use compute frequency in each half cytoband.

Value

a data.table.

Examples

# \donttest{
load(system.file("extdata", "toy_copynumber.RData",
  package = "sigminer", mustWork = TRUE
))
# Compute the mean segVal in each cytoband
x <- transform_seg_table(cn, resolution_factor = 1)
x
#>      chromosome     start       end  label  stain TCGA-05-4417-01A-22D-1854-01
#>          <char>     <int>     <int> <char> <char>                        <num>
#>   1:       chr1   2300001   5400000 p36.32 gpos25                            2
#>   2:       chr1   5400001   7200000 p36.31   gneg                            2
#>   3:       chr1   7200001   9200000 p36.23 gpos25                            2
#>   4:       chr1   9200001  12700000 p36.22   gneg                            2
#>   5:       chr1  12700001  16200000 p36.21 gpos50                            2
#>  ---                                                                          
#> 782:       chr9 130300001 133500000 q34.11   gneg                            3
#> 783:       chr9 133500001 134000000 q34.12 gpos25                            3
#> 784:       chr9 134000001 135900000 q34.13   gneg                            3
#> 785:       chr9 135900001 137400000  q34.2 gpos25                            3
#> 786:       chr9 137400001 141213431  q34.3   gneg                            3
#>      TCGA-06-0644-01A-02D-0310-01 TCGA-19-2621-01B-01D-0911-01
#>                             <num>                        <num>
#>   1:                            2                            2
#>   2:                            2                            2
#>   3:                            2                            2
#>   4:                            2                            2
#>   5:                            2                            2
#>  ---                                                          
#> 782:                            2                            2
#> 783:                            2                            2
#> 784:                            2                            2
#> 785:                            2                            2
#> 786:                            2                            2
#>      TCGA-26-6174-01A-21D-1842-01 TCGA-99-7458-01A-11D-2035-01
#>                             <num>                        <num>
#>   1:                            2                            3
#>   2:                            2                            3
#>   3:                            2                            3
#>   4:                            2                            3
#>   5:                            2                            3
#>  ---                                                          
#> 782:                            3                            2
#> 783:                            3                            2
#> 784:                            3                            2
#> 785:                            3                            2
#> 786:                            3                            2
#>      TCGA-A5-A0G2-01A-11D-A042-01 TCGA-A8-A07S-01A-11D-A036-01
#>                             <num>                        <num>
#>   1:                            1                            2
#>   2:                            1                            2
#>   3:                            1                            2
#>   4:                            1                            2
#>   5:                            1                            2
#>  ---                                                          
#> 782:                            2                            2
#> 783:                            2                            2
#> 784:                            2                            2
#> 785:                            2                            2
#> 786:                            2                            2
#>      TCGA-B6-A0X5-01A-21D-A107-01 TCGA-CV-7432-01A-11D-2128-01
#>                             <num>                        <num>
#>   1:                            2                            2
#>   2:                            2                            2
#>   3:                            2                            2
#>   4:                            2                            2
#>   5:                            2                            2
#>  ---                                                          
#> 782:                            2                            3
#> 783:                            2                            3
#> 784:                            2                            3
#> 785:                            2                            3
#> 786:                            2                            3
#>      TCGA-DF-A2KN-01A-11D-A17U-01
#>                             <num>
#>   1:                            2
#>   2:                            2
#>   3:                            2
#>   4:                            2
#>   5:                            2
#>  ---                             
#> 782:                            2
#> 783:                            2
#> 784:                            2
#> 785:                            2
#> 786:                            2
# Compute the mean segVal in each half-cytoband
x2 <- transform_seg_table(cn, resolution_factor = 2)
x2
#>       chromosome     start       end          label
#>           <char>     <num>     <num>         <char>
#>    1:       chr1   2300001   3849999 p36.32-chunk-1
#>    2:       chr1   3850000   5400000 p36.32-chunk-2
#>    3:       chr1   5400001   6299999 p36.31-chunk-1
#>    4:       chr1   6300000   7200000 p36.31-chunk-2
#>    5:       chr1   7200001   8199999 p36.23-chunk-1
#>   ---                                              
#> 1561:       chr9 134950000 135900000 q34.13-chunk-2
#> 1562:       chr9 135900001 136649999  q34.2-chunk-1
#> 1563:       chr9 136650000 137400000  q34.2-chunk-2
#> 1564:       chr9 137400001 139306715  q34.3-chunk-1
#> 1565:       chr9 139306716 141213431  q34.3-chunk-2
#>       TCGA-05-4417-01A-22D-1854-01 TCGA-06-0644-01A-02D-0310-01
#>                              <num>                        <num>
#>    1:                            2                            2
#>    2:                            2                            2
#>    3:                            2                            2
#>    4:                            2                            2
#>    5:                            2                            2
#>   ---                                                          
#> 1561:                            3                            2
#> 1562:                            3                            2
#> 1563:                            3                            2
#> 1564:                            3                            2
#> 1565:                            3                            2
#>       TCGA-19-2621-01B-01D-0911-01 TCGA-26-6174-01A-21D-1842-01
#>                              <num>                        <num>
#>    1:                            2                            2
#>    2:                            2                            2
#>    3:                            2                            2
#>    4:                            2                            2
#>    5:                            2                            2
#>   ---                                                          
#> 1561:                            2                            3
#> 1562:                            2                            3
#> 1563:                            2                            3
#> 1564:                            2                            3
#> 1565:                            2                            3
#>       TCGA-99-7458-01A-11D-2035-01 TCGA-A5-A0G2-01A-11D-A042-01
#>                              <num>                        <num>
#>    1:                            3                            1
#>    2:                            3                            1
#>    3:                            3                            1
#>    4:                            3                            1
#>    5:                            3                            1
#>   ---                                                          
#> 1561:                            2                            2
#> 1562:                            2                            2
#> 1563:                            2                            2
#> 1564:                            2                            2
#> 1565:                            2                            2
#>       TCGA-A8-A07S-01A-11D-A036-01 TCGA-B6-A0X5-01A-21D-A107-01
#>                              <num>                        <num>
#>    1:                            2                            2
#>    2:                            2                            2
#>    3:                            2                            2
#>    4:                            2                            2
#>    5:                            2                            2
#>   ---                                                          
#> 1561:                            2                            2
#> 1562:                            2                            2
#> 1563:                            2                            2
#> 1564:                            2                            2
#> 1565:                            2                            2
#>       TCGA-CV-7432-01A-11D-2128-01 TCGA-DF-A2KN-01A-11D-A17U-01
#>                              <num>                        <num>
#>    1:                            2                            2
#>    2:                            2                            2
#>    3:                            2                            2
#>    4:                            2                            2
#>    5:                            2                            2
#>   ---                                                          
#> 1561:                            3                            2
#> 1562:                            3                            2
#> 1563:                            3                            2
#> 1564:                            3                            2
#> 1565:                            3                            2
# }