You can subset variants by identifier or by position using the
`[`
operator.
Usage
# S4 method for variants,missing,missing,missing
[(x, i, j, ..., drop = FALSE)
# S4 method for variants,numeric,missing,missing
[(x, i, j, ..., drop = FALSE)
# S4 method for variants,character,missing,missing
[(x, i, j, ..., drop = FALSE)
Arguments
- x
A variants object.
- i
Position of the identifier or the name of the identifier itself.
- j
Not used.
- ...
Additional arguments not used here.
- drop
Not used.
Value
A variants object.
Examples
# Subset a variants object by identifier
variants_ex01['rs4725504']
#> An object of class "variants"
#> Slot "variants":
#> # A tibble: 1 × 7
#> variant_id merged functional_class chromosome_name chromosome_position
#> <chr> <int> <chr> <chr> <int>
#> 1 rs4725504 0 intergenic_variant 7 153608338
#> # ℹ 2 more variables: chromosome_region <chr>, last_update_date <dttm>
#>
#> Slot "genomic_contexts":
#> # A tibble: 4 × 11
#> variant_id gene_name chromosome_name chromosome_position distance
#> <chr> <chr> <chr> <int> <int>
#> 1 rs4725504 DPP6 7 153608338 278759
#> 2 rs4725504 DPP6 7 153608338 139795
#> 3 rs4725504 PAXBP1P1 7 153608338 158463
#> 4 rs4725504 LOC107986750 7 153608338 84107
#> # ℹ 6 more variables: is_closest_gene <lgl>, is_intergenic <lgl>,
#> # is_upstream <lgl>, is_downstream <lgl>, source <chr>, mapping_method <chr>
#>
#> Slot "ensembl_ids":
#> # A tibble: 2 × 3
#> variant_id gene_name ensembl_id
#> <chr> <chr> <chr>
#> 1 rs4725504 DPP6 ENSG00000130226
#> 2 rs4725504 PAXBP1P1 ENSG00000233489
#>
#> Slot "entrez_ids":
#> # A tibble: 3 × 3
#> variant_id gene_name entrez_id
#> <chr> <chr> <chr>
#> 1 rs4725504 DPP6 1804
#> 2 rs4725504 PAXBP1P1 106481704
#> 3 rs4725504 LOC107986750 107986750
#>
# Or by its position in table variants
variants_ex01[3]
#> An object of class "variants"
#> Slot "variants":
#> # A tibble: 1 × 7
#> variant_id merged functional_class chromosome_name chromosome_position
#> <chr> <int> <chr> <chr> <int>
#> 1 rs4725504 0 intergenic_variant 7 153608338
#> # ℹ 2 more variables: chromosome_region <chr>, last_update_date <dttm>
#>
#> Slot "genomic_contexts":
#> # A tibble: 4 × 11
#> variant_id gene_name chromosome_name chromosome_position distance
#> <chr> <chr> <chr> <int> <int>
#> 1 rs4725504 DPP6 7 153608338 278759
#> 2 rs4725504 DPP6 7 153608338 139795
#> 3 rs4725504 PAXBP1P1 7 153608338 158463
#> 4 rs4725504 LOC107986750 7 153608338 84107
#> # ℹ 6 more variables: is_closest_gene <lgl>, is_intergenic <lgl>,
#> # is_upstream <lgl>, is_downstream <lgl>, source <chr>, mapping_method <chr>
#>
#> Slot "ensembl_ids":
#> # A tibble: 2 × 3
#> variant_id gene_name ensembl_id
#> <chr> <chr> <chr>
#> 1 rs4725504 DPP6 ENSG00000130226
#> 2 rs4725504 PAXBP1P1 ENSG00000233489
#>
#> Slot "entrez_ids":
#> # A tibble: 3 × 3
#> variant_id gene_name entrez_id
#> <chr> <chr> <chr>
#> 1 rs4725504 DPP6 1804
#> 2 rs4725504 PAXBP1P1 106481704
#> 3 rs4725504 LOC107986750 107986750
#>
# Keep all variants except the third
variants_ex01[-3]
#> An object of class "variants"
#> Slot "variants":
#> # A tibble: 2 × 7
#> variant_id merged functional_class chromosome_name chromosome_position
#> <chr> <int> <chr> <chr> <int>
#> 1 rs146992477 0 regulatory_region_vari… 8 36984538
#> 2 rs56261590 0 intron_variant 4 73189781
#> # ℹ 2 more variables: chromosome_region <chr>, last_update_date <dttm>
#>
#> Slot "genomic_contexts":
#> # A tibble: 17 × 11
#> variant_id gene_name chromosome_name chromosome_position distance
#> <chr> <chr> <chr> <int> <int>
#> 1 rs146992477 LOC105379377 8 36984538 81555
#> 2 rs146992477 KCNU1 8 36984538 48413
#> 3 rs146992477 LOC105379376 8 36984538 2533
#> 4 rs146992477 TPT1P8 8 36984538 95231
#> 5 rs146992477 RPL26P25 8 36984538 3392
#> 6 rs146992477 KCNU1 8 36984538 48413
#> 7 rs146992477 AC090453.1 8 36984538 3439
#> 8 rs146992477 TPT1P8 8 36984538 95008
#> 9 rs146992477 AC092818.1 8 36984538 82903
#> 10 rs146992477 LOC105379375 8 36984538 59331
#> 11 rs56261590 ANKRD17 4 73189781 0
#> 12 rs56261590 ANKRD17 4 73189781 0
#> 13 rs56261590 HMGA1P2 4 73189781 90636
#> 14 rs56261590 HMGA1P2 4 73189781 89275
#> 15 rs56261590 LOC102724832 4 73189781 69394
#> 16 rs56261590 AC053527.1 4 73189781 69428
#> 17 rs56261590 RF00334 4 73189781 74179
#> # ℹ 6 more variables: is_closest_gene <lgl>, is_intergenic <lgl>,
#> # is_upstream <lgl>, is_downstream <lgl>, source <chr>, mapping_method <chr>
#>
#> Slot "ensembl_ids":
#> # A tibble: 8 × 3
#> variant_id gene_name ensembl_id
#> <chr> <chr> <chr>
#> 1 rs146992477 KCNU1 ENSG00000215262
#> 2 rs146992477 TPT1P8 ENSG00000219491
#> 3 rs146992477 AC090453.1 ENSG00000243503
#> 4 rs146992477 AC092818.1 ENSG00000254038
#> 5 rs56261590 ANKRD17 ENSG00000132466
#> 6 rs56261590 HMGA1P2 ENSG00000248641
#> 7 rs56261590 AC053527.1 ENSG00000250220
#> 8 rs56261590 RF00334 ENSG00000221093
#>
#> Slot "entrez_ids":
#> # A tibble: 9 × 3
#> variant_id gene_name entrez_id
#> <chr> <chr> <chr>
#> 1 rs146992477 LOC105379377 105379377
#> 2 rs146992477 KCNU1 157855
#> 3 rs146992477 LOC105379376 105379376
#> 4 rs146992477 TPT1P8 59347
#> 5 rs146992477 RPL26P25 100270966
#> 6 rs146992477 LOC105379375 105379375
#> 7 rs56261590 ANKRD17 26057
#> 8 rs56261590 HMGA1P2 171559
#> 9 rs56261590 LOC102724832 102724832
#>